Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Race against auditlog being committed #1428

Closed
eugeneia opened this issue Apr 22, 2019 · 2 comments · Fixed by #1442
Closed

Race against auditlog being committed #1428

eugeneia opened this issue Apr 22, 2019 · 2 comments · Fixed by #1442
Labels

Comments

@eugeneia
Copy link
Member

There is a race between when Snabb is started and when we open RaptorJIT’s audit log. When we exceed RaptorJIT’s temporary buffer before committing the audit log to file backed memory via jit.auditlog(shm.path("audit.log")), Snabb will crash with a message such as: core/app.lua:39: auditlog could not be opened (already open?)

It is possible to mitigate this by increasing the size of the temporary buffer for the audit log (see below), but I do wonder what is the correct fix? Should we try to open the audit log earlier than the first call to engine.main()?

As an aside, the resulting error message could probably be more descriptive of the underlying issue. Cc @lukego

modified   lib/luajit/src/lj_auditlog.c
@@ -13,7 +13,7 @@
 #include "lj_debuginfo.h"
 
 /* Maximum data to buffer in memory before file is opened. */
-#define MAX_MEM_BUFFER 10*1024*1024
+#define MAX_MEM_BUFFER 20*1024*1024
 /* State for initial in-memory stream. */
 static char *membuffer;
 static size_t membuffersize;
@eugeneia eugeneia added the bug label Apr 22, 2019
@lukego
Copy link
Member

lukego commented Apr 28, 2019

Hm! Yes it seems like we should open the auditlog earlier. Do we need an engine.init() method or the like? Something that we call as soon as we have decided that the process will be running the engine and having a shm directory but e.g. before configuration loading. Meanwhile bumping the size seems like a reasonable workaround to me.

@lukego
Copy link
Member

lukego commented Apr 28, 2019

Relatedly: I think the size of the auditlog can be shrunk quite a bit. We're logging raw C structs and some like jit_State are much bigger than they need to be. So a little refactoring in the RaptorJIT VM might be able to shrink things a bit. But yes really Snabb needs to be opening the log with only a bounded amount of data logged. Maybe also warning rather than erroring if the log can't be opened?

eugeneia added a commit to eugeneia/snabb that referenced this issue Sep 16, 2019
Open auditlog during initialization, instead of waiting for engine to start.

See snabbco#1428
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants