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

[typed-store/graphql] add util to sync all read only tables #14910

Merged
merged 2 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -659,46 +659,8 @@ impl NodeStateGetter for PersistedStoreInnerReadOnlyWrapper {

impl PersistedStoreInnerReadOnlyWrapper {
pub fn sync(&self) {
// Todo: add macro utility for this in typed store derive
self.inner
.checkpoint_digest_to_sequence_number
.try_catch_up_with_primary()
.expect("Fatal: DB sync failed");
self.inner
.checkpoints
.try_catch_up_with_primary()
.expect("Fatal: DB sync failed");
self.inner
.effects
.try_catch_up_with_primary()
.expect("Fatal: DB sync failed");
self.inner
.epoch_to_committee
.try_catch_up_with_primary()
.expect("Fatal: DB sync failed");
self.inner
.events
.try_catch_up_with_primary()
.expect("Fatal: DB sync failed");
self.inner
.events_tx_digest_index
.try_catch_up_with_primary()
.expect("Fatal: DB sync failed");
self.inner
.live_objects
.try_catch_up_with_primary()
.expect("Fatal: DB sync failed");
self.inner
.objects
.try_catch_up_with_primary()
.expect("Fatal: DB sync failed");
self.inner
.transactions
.try_catch_up_with_primary()
.expect("Fatal: DB sync failed");
self.inner
.checkpoint_contents
.try_catch_up_with_primary()
.try_catch_up_with_primary_all()
.expect("Fatal: DB sync failed");
}
}
Expand Down
9 changes: 9 additions & 0 deletions crates/typed-store-derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,15 @@ pub fn derive_dbmap_utils_general(input: TokenStream) -> TokenStream {
(stringify!(#field_names).to_owned(), (stringify!(#key_names).to_owned(), stringify!(#value_names).to_owned())),
)*].into_iter().collect()
}

/// Try catch up with primary for all tables. This can be a slow operation
/// Tables must be opened in read only mode using `open_tables_read_only`
pub fn try_catch_up_with_primary_all(&self) -> eyre::Result<()> {
#(
typed_store::traits::Map::try_catch_up_with_primary(&self.#field_names)?;
)*
Ok(())
}
}

impl <
Expand Down
Loading