Skip to content
This repository has been archived by the owner on Jul 26, 2024. It is now read-only.

fix: reduce the work done while holding the updater write lock #504

Merged
merged 1 commit into from
Jan 16, 2023

Conversation

pjenvey
Copy link
Member

@pjenvey pjenvey commented Jan 14, 2023

also fix a bug in the updater's handling of all_include_regions

DISCO-2203 & DISCO-2204

Closes #502
Closes #503

also fix a bug in the updater's handling of all_include_regions

DISCO-2203 & DISCO-2204

Closes #502
Closes #503
@pjenvey pjenvey requested a review from jrconlin January 14, 2023 00:38
@pjenvey pjenvey requested a review from a team as a code owner January 14, 2023 00:38
@pjenvey pjenvey removed the request for review from jrconlin January 14, 2023 00:38
) {
// Do the check before matching so that the read lock can be released right away.
let result = filter.read().await.fetch_new_settings(storage_client).await;
match result {
Copy link
Member

Choose a reason for hiding this comment

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

we could probably combine these two.

metrics: &Arc<StatsdClient>,
) {
// Do the check before matching so that the read lock can be released right away.
let result = filter.read().await.fetch_new_settings(storage_client).await;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, I didn't know that calling fetch_new_settings(&self) would also drop the lock guard from the current scope. TIL!

}
Ok(())
self.last_updated = Some(chrono::Utc::now());
Copy link
Collaborator

@ncloudioj ncloudioj Jan 16, 2023

Choose a reason for hiding this comment

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

Instead of the current timestamp, we might want to store the last modified timestamp of the remote file to avoid some subtle ambiguities because filter::update() might be done significantly after filter::fetch_new_settings() (e.g. due to a long wait for the write lock). If there is any new update published between filter:fetch_new_settings() and filter:update(), Contile will be unable to pick it up (lost-update) at the next update check due to that obj.updated < self.last_updated check in fetch_new_settings().

It's quite subtle, aslo we're not making that much publish at the moment, so this can be handled later with a follow-up.

Copy link
Collaborator

@ncloudioj ncloudioj left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants