-
Notifications
You must be signed in to change notification settings - Fork 132
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
Bug 1644359: Support error reporting in Python bindings #1039
Conversation
a68436f
to
54727fd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice, looks good with one small nit.
data_dir: FfiStr, | ||
language_binding_name: FfiStr, | ||
) -> u8 { | ||
pub unsafe extern "C" fn glean_initialize_for_subprocess(cfg: *const FfiConfiguration) -> u8 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if two processes write/open the database at the same time? Thin of the 'pingsender' case on Windows: FOG might be still running while the pingsender is being used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My understanding is that LMDB handles this for us. See the Threads and Processes section here.
What isn't supported is opening the DB multiple times from the same process.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's very interesting. Would you mind adding a small comment about this guarantee here or in some other place? It would also be great to have test coverage for this, but I guess it's fine to do this as a follow-up (or at least just file a bug)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new Python tests in this PR are already sort of testing this case. Even in test mode, it fires off a subprocess (the difference is that it "joins" and waits for it to finish). To be extra sure, we could write a test that repeatedly changes metrics while the ping uploader is running and reporting network errors... Should be easy enough, so I might as well do that now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wrong about testing mode still using real subprocesses. So good catch -- I updated the tests to actually do that so we are testing things running on separate processes, and also added one that sets metrics from both processes at the same time.
1dc1f88
to
fa693d8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r+!
This works by initializing a full Glean in the subprocess that *doesn't* do any startup work such as setting metrics or submitting pings. This makes it safe to initialize Glean in the subprocess, and thus errors can be reported there.
fa693d8
to
14d9928
Compare
This works by initializing a full Glean in the subprocess that
doesn't do any startup work such as setting metrics or submitting
pings. This makes it safe to initialize Glean in the subprocess,
and thus errors can be reported there.