Skip to content

Commit f1d1b0b

Browse files
committed
store: Asyncify VidBatcher.for_copy and for_prune
1 parent 372732a commit f1d1b0b

File tree

6 files changed

+13
-10
lines changed

6 files changed

+13
-10
lines changed

store/postgres/src/copy.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ impl TableState {
336336
dst: Arc<Table>,
337337
target_block: &BlockPtr,
338338
) -> Result<Self, StoreError> {
339-
let vid_range = VidRange::for_copy(conn, &src, target_block)?;
339+
let vid_range = VidRange::for_copy(conn, &src, target_block).await?;
340340
let batcher =
341341
VidBatcher::load(conn, &src_layout.site.namespace, src.as_ref(), vid_range).await?;
342342
Ok(Self {

store/postgres/src/deployment_store.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,7 +1091,7 @@ impl DeploymentStore {
10911091
let mut conn = self.get_conn().await?;
10921092
let layout = self.layout(&mut conn, site).await?;
10931093

1094-
layout.find_many(&mut conn, ids_for_type, block)
1094+
layout.find_many(&mut conn, ids_for_type, block).await
10951095
}
10961096

10971097
pub(crate) async fn get_range(
@@ -1103,7 +1103,9 @@ impl DeploymentStore {
11031103
) -> Result<BTreeMap<BlockNumber, Vec<EntitySourceOperation>>, StoreError> {
11041104
let mut conn = self.get_conn().await?;
11051105
let layout = self.layout(&mut conn, site).await?;
1106-
layout.find_range(&mut conn, entity_types, causality_region, block_range)
1106+
layout
1107+
.find_range(&mut conn, entity_types, causality_region, block_range)
1108+
.await
11071109
}
11081110

11091111
pub(crate) async fn get_derived(

store/postgres/src/relational.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ impl Layout {
481481
}
482482

483483
// An optimization when looking up multiple entities, it will generate a single sql query using `UNION ALL`.
484-
pub fn find_many(
484+
pub async fn find_many(
485485
&self,
486486
conn: &mut PgConnection,
487487
ids_for_type: &BTreeMap<(EntityType, CausalityRegion), IdList>,
@@ -517,7 +517,7 @@ impl Layout {
517517
Ok(entities)
518518
}
519519

520-
pub fn find_range(
520+
pub async fn find_range(
521521
&self,
522522
conn: &mut PgConnection,
523523
entity_types: Vec<EntityType>,

store/postgres/src/relational/prune.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ impl TablePair {
105105
let column_list = Arc::new(self.column_list());
106106

107107
// Determine the last vid that we need to copy
108-
let range = VidRange::for_prune(conn, &self.src, earliest_block, final_block)?;
108+
let range = VidRange::for_prune(conn, &self.src, earliest_block, final_block).await?;
109109
let mut batcher = VidBatcher::load(conn, &self.src_nsp, &self.src, range).await?;
110110
tracker.start_copy_final(conn, &self.src, range).await?;
111111

@@ -173,7 +173,7 @@ impl TablePair {
173173
let column_list = Arc::new(self.column_list());
174174

175175
// Determine the last vid that we need to copy
176-
let range = VidRange::for_prune(conn, &self.src, final_block + 1, BLOCK_NUMBER_MAX)?;
176+
let range = VidRange::for_prune(conn, &self.src, final_block + 1, BLOCK_NUMBER_MAX).await?;
177177
let mut batcher = VidBatcher::load(conn, &self.src.nsp, &self.src, range).await?;
178178
tracker.start_copy_nonfinal(conn, &self.src, range).await?;
179179

@@ -478,7 +478,7 @@ impl Layout {
478478
PruningStrategy::Delete => {
479479
// Delete all entity versions whose range was closed
480480
// before `req.earliest_block`
481-
let range = VidRange::for_prune(conn, &table, 0, req.earliest_block)?;
481+
let range = VidRange::for_prune(conn, &table, 0, req.earliest_block).await?;
482482
let mut batcher =
483483
VidBatcher::load(conn, &self.site.namespace, &table, range).await?;
484484

store/postgres/src/vid_batcher.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ impl VidRange {
274274
}
275275

276276
/// Return the full range of `vid` values in the table `src`
277-
pub fn for_copy(
277+
pub async fn for_copy(
278278
conn: &mut PgConnection,
279279
src: &Table,
280280
target_block: &BlockPtr,
@@ -303,7 +303,7 @@ impl VidRange {
303303
/// Return the first and last vid of any entity that is visible in the
304304
/// block range from `first_block` (inclusive) to `last_block`
305305
/// (exclusive)
306-
pub fn for_prune(
306+
pub async fn for_prune(
307307
conn: &mut PgConnection,
308308
src: &Table,
309309
first_block: BlockNumber,

store/test-store/tests/postgres/relational_bytes.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ async fn find_many() {
300300

301301
let entities = layout
302302
.find_many(conn, &id_map, BLOCK_NUMBER_MAX)
303+
.await
303304
.expect("Failed to read many things");
304305
assert_eq!(2, entities.len());
305306

0 commit comments

Comments
 (0)