mirror of
https://github.com/qwibitai/nanoclaw.git
synced 2026-06-12 18:11:51 +08:00
Merge pull request #2209 from cfis/fix/host-sweep-test-uses-in-memory-db
fix(host-sweep): orphan-claim delete missed in tests (regression from #2183)
This commit is contained in:
+7
-8
@@ -256,7 +256,7 @@ export function _resetStuckProcessingRowsForTesting(
|
||||
session: Session,
|
||||
reason: string,
|
||||
): void {
|
||||
resetStuckProcessingRows(inDb, outDb, session, reason);
|
||||
resetStuckProcessingRows(inDb, outDb, session, reason, outDb);
|
||||
}
|
||||
|
||||
function resetStuckProcessingRows(
|
||||
@@ -264,6 +264,7 @@ function resetStuckProcessingRows(
|
||||
outDb: Database.Database,
|
||||
session: Session,
|
||||
reason: string,
|
||||
writableOutDb?: Database.Database,
|
||||
): void {
|
||||
const claims = getProcessingClaims(outDb);
|
||||
const now = Date.now();
|
||||
@@ -300,19 +301,17 @@ function resetStuckProcessingRows(
|
||||
// would re-read them, see the old status_changed timestamp, conclude the
|
||||
// freshly respawned container is stuck, and SIGKILL it before its
|
||||
// agent-runner has a chance to run clearStaleProcessingAcks() on startup.
|
||||
// We're safe to write outbound.db here because we just killed the container
|
||||
// that owned it (or it crashed and left no writer behind).
|
||||
// outDb was opened readonly for reads above; reopen with write access for this delete.
|
||||
let outDbRw: Database.Database | null = null;
|
||||
const ownsDb = !writableOutDb;
|
||||
let useDb: Database.Database | null = writableOutDb ?? null;
|
||||
try {
|
||||
outDbRw = openOutboundDbRw(session.agent_group_id, session.id);
|
||||
const cleared = deleteOrphanProcessingClaims(outDbRw);
|
||||
if (!useDb) useDb = openOutboundDbRw(session.agent_group_id, session.id);
|
||||
const cleared = deleteOrphanProcessingClaims(useDb);
|
||||
if (cleared > 0) {
|
||||
log.info('Cleared orphan processing claims', { sessionId: session.id, cleared, reason });
|
||||
}
|
||||
} catch (err) {
|
||||
log.warn('Failed to clear orphan processing claims', { sessionId: session.id, err });
|
||||
} finally {
|
||||
outDbRw?.close();
|
||||
if (ownsDb) useDb?.close();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user