Skip to content

Commit 3f33606

Browse files
committed
NC | NSFS | Panic printings added + try-catch in memory_monitor + default event logging to false
Signed-off-by: shirady <57721533+shirady@users.noreply.github.com> increase the number of LimitNOFILE to 600k Signed-off-by: shirady <57721533+shirady@users.noreply.github.com> CR changes Signed-off-by: shirady <57721533+shirady@users.noreply.github.com>
1 parent 58f9ebc commit 3f33606

File tree

5 files changed

+34
-23
lines changed

5 files changed

+34
-23
lines changed

config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ config.DEBUG_MODE_PERIOD = 10 * 60 * 1000; // 10 minutes for increased debug lev
493493
config.dbg_log_level = 0;
494494
config.DEBUG_FACILITY = 'LOG_LOCAL0';
495495
config.EVENT_FACILITY = 'LOG_LOCAL2';
496-
config.EVENT_LOGGING_ENABLED = true;
496+
config.EVENT_LOGGING_ENABLED = false; // should be changed in NC NSFS configuration
497497
config.EVENT_LEVEL = 5;
498498

499499
config.LOG_TO_STDERR_ENABLED = true;

src/cmd/nsfs.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ class NsfsAccountSDK extends AccountSDK {
244244
async function main(argv = minimist(process.argv.slice(2))) {
245245
try {
246246
config.DB_TYPE = 'none';
247+
config.EVENT_LOGGING_ENABLED = true;
247248
config.NSFS_VERSIONING_ENABLED = true;
248249
// when using data buckets on noobaa standalone we should set it to true
249250
config.ENABLE_OBJECT_IO_SEMAPHORE_MONITOR = false;

src/deploy/noobaa.service

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ ExecStart=/usr/local/noobaa-core/bin/node /usr/local/noobaa-core/src/cmd/nsfs.js
1111
EnvironmentFile=-/etc/sysconfig/noobaa
1212
ExecStop=/bin/kill $MAINPID
1313
WorkingDirectory=/usr/local/noobaa-core/
14-
LimitNOFILE=65536
14+
LimitNOFILE=600000
1515

1616
[Install]
1717
WantedBy=multi-user.target

src/util/debug_module.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,6 @@ function log_syslog_builder(syslevel) {
509509
*/
510510
function log_event(event) {
511511
if (!config.EVENT_LOGGING_ENABLED) {
512-
console.info('Event logging not enabled');
513512
return;
514513
}
515514
event.pid = process.pid;

src/util/panic.js

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,16 @@ const child_process = require('child_process');
88
process.on('uncaughtException', err => panic('process uncaughtException', err));
99

1010
function panic(message, err) {
11+
// this printing is duplicated here in case LOOP_ON_PANIC is true (the process will not be exit)
1112
console.error('PANIC:', message, err.stack || err);
1213
while (process.env.LOOP_ON_PANIC === 'true') {
1314
console.warn('Encountered an error, holding the process on an infinite loop');
1415
child_process.execSync('sleep 10');
1516
}
16-
process.exit(1);
17+
// to avoid cases where the process can exit without printing the error
18+
process.stderr.write('PANIC: ' + message + (err.stack || err) + '\n', () => {
19+
process.exit(1);
20+
});
1721
}
1822

1923
// dump heap with kill -USR2 <pid>
@@ -37,25 +41,32 @@ function enable_heapdump(name, next_mb, step_mb) {
3741
}
3842

3943
function memory_monitor() {
40-
const m = process.memoryUsage();
41-
const c = memory_monitor_config;
42-
const h = c.heapdump;
43-
const current = m.heapUsed;
44-
if (c.logging_threshold &&
45-
c.logging_threshold <= current) {
46-
const usage = (m.heapUsed / 1024 / 1024).toFixed(0);
47-
const total = (m.heapTotal / 1024 / 1024).toFixed(0);
48-
const resident = (m.rss / 1024 / 1024).toFixed(0);
49-
console.log(`memory_monitor: heap ${usage} MB | total ${total} MB | resident ${resident} MB`);
50-
}
51-
if (h && h.next && h.next <= current) {
52-
const size_mb = (current / 1024 / 1024).toFixed(0);
53-
const snapshot_name = `heapdump-${h.name}-${process.pid}-${new Date().toISOString()}-${size_mb}MB.heapsnapshot`;
54-
console.log(`memory_monitor: writing ${snapshot_name}`);
55-
heapdump.writeSnapshot(snapshot_name);
56-
const increase = current - h.next;
57-
const align = h.step - (increase % h.step);
58-
h.next += increase + align;
44+
try {
45+
const m = process.memoryUsage();
46+
const c = memory_monitor_config;
47+
const h = c.heapdump;
48+
const current = m.heapUsed;
49+
if (c.logging_threshold &&
50+
c.logging_threshold <= current) {
51+
const usage = (m.heapUsed / 1024 / 1024).toFixed(0);
52+
const total = (m.heapTotal / 1024 / 1024).toFixed(0);
53+
const resident = (m.rss / 1024 / 1024).toFixed(0);
54+
console.log(`memory_monitor: heap ${usage} MB | total ${total} MB | resident ${resident} MB`);
55+
}
56+
if (h && h.next && h.next <= current) {
57+
const size_mb = (current / 1024 / 1024).toFixed(0);
58+
const snapshot_name = `heapdump-${h.name}-${process.pid}-${new Date().toISOString()}-${size_mb}MB.heapsnapshot`;
59+
console.log(`memory_monitor: writing ${snapshot_name}`);
60+
heapdump.writeSnapshot(snapshot_name);
61+
const increase = current - h.next;
62+
const align = h.step - (increase % h.step);
63+
h.next += increase + align;
64+
}
65+
} catch (err) {
66+
console.error('memory_monitor got an error', err);
67+
// we saw cases where the number of open files (file descriptors) was a reason for uncaught error during the memory_monitor
68+
// we don't want the process to fail on that
69+
if (err.code !== 'EMFILE') throw err;
5970
}
6071
}
6172

0 commit comments

Comments
 (0)