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 1749510 - RLB: Wait for uploader on shutdown using new shutdown mechanism #2332

Merged
merged 2 commits into from
Feb 3, 2023

Conversation

badboy
Copy link
Member

@badboy badboy commented Jan 10, 2023

RLB: Wait for uploader on shutdown using new shutdown mechanism

On shutdown we now wait up to 30s for the upload thread to finish.
This gets done just after we drain and shut down the dispatcher,
but before Glean is considered fully shutdown.

The callback MUST NOT put any new tasks on the dispatcher.
The callback SHOULD NOT block arbitrarily long.

The RLB implementation of that callback instructs a potential uploader
thread to end operation after it finished one upload.
It also blocks any new upload thread from getting started.
This means an in-flight upload can finish as usual, but no new one
is launched.
If the upload thread is currently sleeping, it gets one more upload.

This also adds a new test.
The only way to reliably test this is from the outside,
so the test invokes an example implementation and checks that the
pending_pings directory is empty after the program ends.
The uploader inside sleeps for a short period of time.
Without waiting for this uploader the main thread would end and kill the
uploader thread before it wakes up.
With waiting the uploader finishes correctly before the main thread
exits.

Copy link
Contributor

@chutten chutten left a comment

Choose a reason for hiding this comment

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

Nothing that's not surmountable, I think.

glean-core/rlb/src/lib.rs Outdated Show resolved Hide resolved
glean-core/src/lib.rs Outdated Show resolved Hide resolved
glean-core/rlb/src/net/mod.rs Outdated Show resolved Hide resolved
glean-core/rlb/src/net/mod.rs Show resolved Hide resolved
@badboy badboy marked this pull request as ready for review February 1, 2023 13:30
@badboy badboy requested a review from a team as a code owner February 1, 2023 13:30
Copy link
Contributor

@chutten chutten left a comment

Choose a reason for hiding this comment

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

r+ conditional on adding a CHANGELOG entry and some instrumentation.

.circleci/config.yml Outdated Show resolved Hide resolved
glean-core/rlb/src/net/mod.rs Show resolved Hide resolved
glean-core/src/lib.rs Show resolved Hide resolved
glean-core/rlb/src/net/mod.rs Show resolved Hide resolved
glean-core/src/lib.rs Show resolved Hide resolved
@badboy
Copy link
Member Author

badboy commented Feb 1, 2023

r+ conditional on adding a CHANGELOG entry and some instrumentation.

I would prefer to do the instrumentation in a followup. Because of how we upload this is ... not as easy as I would like and so to keep review on point doing that in a followup seems easier.

@chutten
Copy link
Contributor

chutten commented Feb 1, 2023

r+ conditional on adding a CHANGELOG entry and some instrumentation.

I would prefer to do the instrumentation in a followup. Because of how we upload this is ... not as easy as I would like and so to keep review on point doing that in a followup seems easier.

Very well, r+ conditional on adding a CHANGELOG entry and filing a follow-up for instrumentation

Copy link
Member

@travis79 travis79 left a comment

Choose a reason for hiding this comment

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

👍 Nothing to really add, this looks good! (And +1 on removing the "on" from the function names)

@badboy badboy force-pushed the 1749510-upload-shutdown branch 3 times, most recently from e564ae3 to 649ff48 Compare February 2, 2023 13:52
@badboy badboy changed the title Bug 1749510 - RLB: Wait for uploader on shutdown using new on_shutdown mechanism Bug 1749510 - RLB: Wait for uploader on shutdown using new shutdown mechanism Feb 2, 2023
On shutdown we now wait up to 30s for the upload thread to finish.
This gets done just after we drain and shut down the dispatcher,
but before Glean is considered fully shutdown.

The callback MUST NOT put any new tasks on the dispatcher.
The callback SHOULD NOT block arbitrarily long.

The RLB implementation of that callback instructs a potential uploader
thread to end operation after it finished one upload.
It also blocks any new upload thread from getting started.
This means an in-flight upload can finish as usual, but no new one
is launched.
If the upload thread is currently sleeping, it gets one more upload.

This also adds a new test.
The only way to reliably test this is from the outside,
so the test invokes an example implementation and checks that the
`pending_pings` directory is empty after the program ends.
The uploader inside sleeps for a short period of time.
Without waiting for this uploader the main thread would end and kill the
uploader thread before it wakes up.
With waiting the uploader finishes correctly before the main thread
exits.
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