Fix DuckDB lookup memory usage and failure recovery

This commit is contained in:
Intelli committed 2026-10-18 12:29:06 -06:00
1 parent bc46794bba
commit 38b6d87220
1 file changed
+10 -10
@@ -42,7 +42,6 @@ import net.coreprotect.model.lookup.LookupRollbackState;
import net.coreprotect.model.rollback.SignRollbackChange;
import net.coreprotect.utility.EntitySpawnTracking;
import net.coreprotect.utility.EntityUtils;
import net.coreprotect.utility.ErrorReporter;
import net.coreprotect.utility.DatabaseUtils;
import net.coreprotect.utility.MaterialUtils;
import net.coreprotect.utility.WorldUtils;
@@ -150,7 +149,7 @@ public class LookupRaw extends Queue {
return new RawLookupPage(totalRows, rows, nextCursor);
}
catch (Exception exception) {
ErrorReporter.report(exception);
Database.reportDatabaseFailure(exception);
return new RawLookupPage(knownTotalRows > 0L ? knownTotalRows : 0L, Collections.emptyList(), null);
}
finally {
@@ -381,7 +380,7 @@ public class LookupRaw extends Queue {
}
}
catch (Exception e) {
ErrorReporter.report(e);
Database.reportDatabaseFailure(e);
return null;
}
finally {
@@ -390,7 +389,7 @@ public class LookupRaw extends Queue {
results.close();
}
catch (Exception e) {
ErrorReporter.report(e);
Database.reportDatabaseFailure(e);
}
}
if (paused) {
@@ -1279,7 +1278,7 @@ public class LookupRaw extends Queue {
}
}
catch (Exception e) {
ErrorReporter.report(e);
Database.reportDatabaseFailure(e);
}
return results;
@@ -1565,11 +1564,12 @@ public class LookupRaw extends Queue {
if (includePlaced && includeOther) {
predicates.add("action=" + action);
}
else if (includePlaced) {
predicates.add("(action=" + action + " AND type IN(" + placedEntityTypes + "))");
}
else if (includeOther) {
predicates.add("(action=" + action + " AND type NOT IN(" + placedEntityTypes + "))");
else if (includePlaced || includeOther) {
String negation = includePlaced ? "" : "NOT ";
String typePredicate = ConfigHandler.databaseType.isDuckDB()
? negation + "list_contains([" + placedEntityTypes + "],type)"
: "type " + negation + "IN(" + placedEntityTypes + ")";
predicates.add("(action=" + action + " AND " + typePredicate + ")");
}
}