Skip to content

Commit cd806e5

Browse files
authored
store: Better error message for missing template during grafting (#5464)
* store: Better error message for missing template during grafting * store: Perform private data source copy in its own transaction Fixes #5465
1 parent 553b8f9 commit cd806e5

File tree

2 files changed

+28
-10
lines changed

2 files changed

+28
-10
lines changed

store/postgres/src/copy.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -750,15 +750,21 @@ impl Connection {
750750
self.conn.transaction(|conn| f(conn))
751751
}
752752

753+
/// Copy private data sources if the source uses a schema version that
754+
/// has a private data sources table. The copying is done in its own
755+
/// transaction.
753756
fn copy_private_data_sources(&mut self, state: &CopyState) -> Result<(), StoreError> {
754757
if state.src.site.schema_version.private_data_sources() {
755-
DataSourcesTable::new(state.src.site.namespace.clone()).copy_to(
756-
&mut self.conn,
757-
&DataSourcesTable::new(state.dst.site.namespace.clone()),
758-
state.target_block.number,
759-
&self.src_manifest_idx_and_name,
760-
&self.dst_manifest_idx_and_name,
761-
)?;
758+
let conn = &mut self.conn;
759+
conn.transaction(|conn| {
760+
DataSourcesTable::new(state.src.site.namespace.clone()).copy_to(
761+
conn,
762+
&DataSourcesTable::new(state.dst.site.namespace.clone()),
763+
state.target_block.number,
764+
&self.src_manifest_idx_and_name,
765+
&self.dst_manifest_idx_and_name,
766+
)
767+
})?;
762768
}
763769
Ok(())
764770
}

store/postgres/src/dynds/private.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use diesel::{
99
};
1010

1111
use graph::{
12-
anyhow::Context,
12+
anyhow::{anyhow, Context},
1313
components::store::{write, StoredDynamicDataSource},
1414
constraint_violation,
1515
data_source::CausalityRegion,
@@ -258,12 +258,24 @@ impl DataSourcesTable {
258258
let name = &src_manifest_idx_and_name
259259
.iter()
260260
.find(|(idx, _)| idx == &src_manifest_idx)
261-
.context("manifest_idx not found in src")?
261+
.with_context(|| {
262+
anyhow!(
263+
"the source {} does not have a template with index {}",
264+
self.namespace,
265+
src_manifest_idx
266+
)
267+
})?
262268
.1;
263269
let dst_manifest_idx = dst_manifest_idx_and_name
264270
.iter()
265271
.find(|(_, n)| n == name)
266-
.context("name not found in dst")?
272+
.with_context(|| {
273+
anyhow!(
274+
"the destination {} is missing a template with name {}. The source {} created one at block {:?}",
275+
dst.namespace,
276+
name, self.namespace, block_range.0
277+
)
278+
})?
267279
.0;
268280

269281
let query = format!(

0 commit comments

Comments
 (0)