Skip to content

Commit

Permalink
fix(store): Fix cross shard grafting
Browse files Browse the repository at this point in the history
  • Loading branch information
leoyvens committed Oct 4, 2022
1 parent 35db8fa commit 9ce7f67
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
9 changes: 3 additions & 6 deletions store/postgres/src/deployment_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1305,23 +1305,20 @@ impl DeploymentStore {
&self,
logger: &Logger,
site: Arc<Site>,
graft_src: Option<(Arc<Layout>, BlockPtr)>,
graft_src: Option<(Arc<Layout>, BlockPtr, SubgraphDeploymentEntity)>,
) -> Result<(), StoreError> {
let dst = self.find_layout(site.cheap_clone())?;

// If `graft_src` is `Some`, then there is a pending graft.
if let Some((src, block)) = graft_src {
if let Some((src, block, src_deployment)) = graft_src {
info!(
logger,
"Initializing graft by copying data from {} to {}",
src.catalog.site.namespace,
dst.catalog.site.namespace
);

let src_manifest_idx_and_name = self
.load_deployment(&src.site)?
.manifest
.template_idx_and_name()?;
let src_manifest_idx_and_name = src_deployment.manifest.template_idx_and_name()?;
let dst_manifest_idx_and_name = self
.load_deployment(&dst.site)?
.manifest
Expand Down
10 changes: 8 additions & 2 deletions store/postgres/src/writable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ use graph::components::store::ReadStore;
use graph::data::subgraph::schema;
use graph::env::env_var;
use graph::prelude::{
BlockNumber, Entity, MetricsRegistry, Schema, SubgraphStore as _, BLOCK_NUMBER_MAX,
BlockNumber, Entity, MetricsRegistry, Schema, SubgraphDeploymentEntity, SubgraphStore as _,
BLOCK_NUMBER_MAX,
};
use graph::slog::info;
use graph::util::bounded_queue::BoundedQueue;
Expand Down Expand Up @@ -58,6 +59,10 @@ impl WritableSubgraphStore {
fn layout(&self, id: &DeploymentHash) -> Result<Arc<Layout>, StoreError> {
self.0.layout(id)
}

fn load_deployment(&self, site: &Site) -> Result<SubgraphDeploymentEntity, StoreError> {
self.0.load_deployment(site)
}
}

/// Write synchronously to the actual store, i.e., once a method returns,
Expand Down Expand Up @@ -171,7 +176,8 @@ impl SyncStore {
let graft_base = match self.writable.graft_pending(&self.site.deployment)? {
Some((base_id, base_ptr)) => {
let src = self.store.layout(&base_id)?;
Some((src, base_ptr))
let deployment_entity = self.store.load_deployment(&src.site)?;
Some((src, base_ptr, deployment_entity))
}
None => None,
};
Expand Down

0 comments on commit 9ce7f67

Please sign in to comment.