cache updater: fix race with saving archives and computing archive hashes

The tasks submitted to the executor compute and set the archive hashes, but the hashes are required by CacheStorage to save them. Ensure the tasks are complete first before saving.
This commit is contained in:
Adam
2021-03-07 23:26:23 -05:00
parent 5ba3e510dc
commit aa46b11731

View File

@@ -120,7 +120,6 @@ public class CacheUpdater implements CommandLineRunner
CacheEntry newCache = created ? cache : cacheDao.createCache(con, rsVersion, Instant.now());
storage.setCacheEntry(newCache);
store.save();
// ensure objects are added to the store before they become
// visible in the database
@@ -130,6 +129,10 @@ public class CacheUpdater implements CommandLineRunner
logger.debug("Waiting for termination of executor...");
}
// CacheStorage requires archive hashes to be set, which is set in the executor tasks, so it must be
// run after shutdown
store.save();
// commit database
con.commit();
}