Skip to content

Commit

Permalink
store: Tolerate a missing source for a copy
Browse files Browse the repository at this point in the history
When we check whether we should perform on_sync actions, tolerate the
source having been deleted.
  • Loading branch information
lutter committed Feb 23, 2023
1 parent fa986ba commit b933657
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions store/postgres/src/writable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,14 @@ impl SyncStore {
.await
}

fn maybe_find_site(&self, src: DeploymentId) -> Result<Option<Arc<Site>>, StoreError> {
match self.store.find_site(src) {
Ok(site) => Ok(Some(site)),
Err(StoreError::DeploymentNotFound(_)) => Ok(None),
Err(e) => Err(e),
}
}

fn deployment_synced(&self) -> Result<(), StoreError> {
self.retry("deployment_synced", || {
let event = {
Expand All @@ -361,15 +369,16 @@ impl SyncStore {
// grafts) so we make sure that the source, if it exists, has
// the same hash as `self.site`
if let Some(src) = self.writable.source_of_copy(&self.site)? {
let site = self.store.find_site(src)?;
if site.deployment == self.site.deployment {
let on_sync = self.writable.on_sync(&self.site)?;
if on_sync.activate() {
let pconn = self.store.primary_conn()?;
pconn.activate(&self.site.as_ref().into())?;
}
if on_sync.replace() {
self.unassign_subgraph(&site)?;
if let Some(src) = self.maybe_find_site(src)? {
if src.deployment == self.site.deployment {
let on_sync = self.writable.on_sync(&self.site)?;
if on_sync.activate() {
let pconn = self.store.primary_conn()?;
pconn.activate(&self.site.as_ref().into())?;
}
if on_sync.replace() {
self.unassign_subgraph(&src)?;
}
}
}
}
Expand Down

0 comments on commit b933657

Please sign in to comment.