From aa46b117311f3625c455ca51756bba01d7d7d288 Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 7 Mar 2021 23:26:23 -0500 Subject: [PATCH] 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. --- .../main/java/net/runelite/cache/updater/CacheUpdater.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cache-updater/src/main/java/net/runelite/cache/updater/CacheUpdater.java b/cache-updater/src/main/java/net/runelite/cache/updater/CacheUpdater.java index 1a8f81c5ec..817ba7fbe2 100644 --- a/cache-updater/src/main/java/net/runelite/cache/updater/CacheUpdater.java +++ b/cache-updater/src/main/java/net/runelite/cache/updater/CacheUpdater.java @@ -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(); }