From 19bf8afece43b2d6d48accf8f88dfbd9b9bfd98b Mon Sep 17 00:00:00 2001 From: CalDescent Date: Fri, 24 Sep 2021 20:52:45 +0100 Subject: [PATCH] Fixed bug in pruning phase on node startup This was causing very recent AT states to be deleted accidentally, because we weren't rebuilding the LatestATStates table before running the query. We should add unit tests to cover this process in case there are any other undiscovered problems. --- .../org/qortal/repository/hsqldb/HSQLDBDatabasePruning.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/org/qortal/repository/hsqldb/HSQLDBDatabasePruning.java b/src/main/java/org/qortal/repository/hsqldb/HSQLDBDatabasePruning.java index 7cbd933f..e9c92800 100644 --- a/src/main/java/org/qortal/repository/hsqldb/HSQLDBDatabasePruning.java +++ b/src/main/java/org/qortal/repository/hsqldb/HSQLDBDatabasePruning.java @@ -96,6 +96,10 @@ public class HSQLDBDatabasePruning { final int blockStep = 10000; + // It's essential that we rebuild the latest AT states here, as we are using this data in the next query. + // Failing to do this will result in important AT states being deleted, rendering the database unusable. + repository.getATRepository().rebuildLatestAtStates(); + // Loop through all the LatestATStates and copy them to the new table LOGGER.info("Copying AT states...");