Skip to content

Commit

Permalink
[typed-store/graphql] add util to sync all read only tables (#14910)
Browse files Browse the repository at this point in the history
  • Loading branch information
oxade authored Nov 20, 2023
1 parent 4d4c247 commit c9c624c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 39 deletions.
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

2 comments on commit c9c624c

@vercel
Copy link

@vercel vercel bot commented on c9c624c Nov 20, 2023

Choose a reason for hiding this comment

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

@vercel
Copy link

@vercel vercel bot commented on c9c624c Nov 20, 2023

Choose a reason for hiding this comment

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

Please sign in to comment.