fix(android): drop object lock on diagnostic record to avoid deadlock (#386)

AgentDiagnosticStore.record() held the helper monitor (@Synchronized) while
waiting for the SQLite write connection, while failure-snapshot and sync
diagnostic transactions held the connection and re-entered
getWritableDatabase() (same monitor). The inverted lock order deadlocked and
blocked the sync/heartbeat thread forever (seen on purchase device 1).
record() only touches locals inside its own transaction and is called from a
single-thread executor, so the monitor is unnecessary.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NTDbDcwbDw1TSAcE6wfh2F
This commit is contained in:
QiuSW
2026-10-13 09:22:04 +08:00
co-authored by Claude Opus 5.5
parent d4cf2bbb3e
commit 71165b1fe7
@@ -166,7 +166,6 @@ class AgentDiagnosticStore(context: Context) : SQLiteOpenHelper(context, DATABAS
}
}
@Synchronized
fun record(event: AgentDiagnosticEvent) {
require(event.taskId > 0)
require(event.taskType in setOf("collection", "purchase"))