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

store: Better error message for missing template during grafting #5464

Merged
merged 2 commits into from
Jul 8, 2024
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
20 changes: 13 additions & 7 deletions store/postgres/src/copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -748,15 +748,21 @@ impl Connection {
self.conn.transaction(|conn| f(conn))
}

/// Copy private data sources if the source uses a schema version that
/// has a private data sources table. The copying is done in its own
/// transaction.
fn copy_private_data_sources(&mut self, state: &CopyState) -> Result<(), StoreError> {
if state.src.site.schema_version.private_data_sources() {
DataSourcesTable::new(state.src.site.namespace.clone()).copy_to(
&mut self.conn,
&DataSourcesTable::new(state.dst.site.namespace.clone()),
state.target_block.number,
&self.src_manifest_idx_and_name,
&self.dst_manifest_idx_and_name,
)?;
let conn = &mut self.conn;
conn.transaction(|conn| {
DataSourcesTable::new(state.src.site.namespace.clone()).copy_to(
conn,
&DataSourcesTable::new(state.dst.site.namespace.clone()),
state.target_block.number,
&self.src_manifest_idx_and_name,
&self.dst_manifest_idx_and_name,
)
})?;
}
Ok(())
}
Expand Down
18 changes: 15 additions & 3 deletions store/postgres/src/dynds/private.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use diesel::{
};

use graph::{
anyhow::Context,
anyhow::{anyhow, Context},
components::store::{write, StoredDynamicDataSource},
constraint_violation,
data_source::CausalityRegion,
Expand Down Expand Up @@ -258,12 +258,24 @@ impl DataSourcesTable {
let name = &src_manifest_idx_and_name
.iter()
.find(|(idx, _)| idx == &src_manifest_idx)
.context("manifest_idx not found in src")?
.with_context(|| {
anyhow!(
"the source {} does not have a template with index {}",
self.namespace,
src_manifest_idx
)
})?
.1;
let dst_manifest_idx = dst_manifest_idx_and_name
.iter()
.find(|(_, n)| n == name)
.context("name not found in dst")?
.with_context(|| {
anyhow!(
"the destination {} is missing a template with name {}. The source {} created one at block {:?}",
dst.namespace,
name, self.namespace, block_range.0
)
})?
.0;

let query = format!(
Expand Down
Loading