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

Bug 1644359: Support error reporting in Python bindings #1039

Merged
merged 4 commits into from
Jul 8, 2020

Conversation

mdboom
Copy link
Contributor

@mdboom mdboom commented Jul 6, 2020

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.

@auto-assign auto-assign bot requested a review from brizental July 6, 2020 18:57
@mdboom mdboom force-pushed the python-upload-error-reporting branch from a68436f to 54727fd Compare July 6, 2020 19:00
glean-core/src/lib.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@brizental brizental left a 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 {
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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)

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

@mdboom mdboom requested a review from Dexterp37 July 7, 2020 16:29
@mdboom mdboom force-pushed the python-upload-error-reporting branch 4 times, most recently from 1dc1f88 to fa693d8 Compare July 7, 2020 22:11
Copy link
Contributor

@Dexterp37 Dexterp37 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r+!

mdboom added 4 commits July 8, 2020 10:26
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.
@mdboom mdboom force-pushed the python-upload-error-reporting branch from fa693d8 to 14d9928 Compare July 8, 2020 14:26
@mdboom mdboom merged commit 3165681 into mozilla:main Jul 8, 2020
@mdboom mdboom deleted the python-upload-error-reporting branch July 8, 2020 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants