You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: memory-bank/decisionLog.md
+40Lines changed: 40 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,46 @@
2
2
3
3
## Technical Decisions
4
4
5
+
### 2026-04-10: Queue Processing Deadlock Fix
6
+
7
+
**Decision**: Track `pending` counter to detect synchronous operations in `Database::Process()`
8
+
9
+
**Rationale**:
10
+
- Bug: When using `db.serialize()`, synchronous operations like `configure()` would cause subsequent operations to get stuck in the queue indefinitely
11
+
- Root cause: `Process()` loop breaks after exclusive operations, but synchronous operations don't increment `pending`, leaving `locked=true` with no async work pending
12
+
- Solution detects synchronous completion by checking if `pending` counter changed during callback execution
13
+
14
+
**Implementation**:
15
+
```cpp
16
+
// Track pending before callback to detect synchronous operations
17
+
unsignedint before_pending = pending;
18
+
call->callback(call->baton);
19
+
20
+
// If operation was synchronous (pending unchanged) and we're in exclusive mode,
21
+
// reset locked and continue processing the queue.
22
+
if (locked && pending == before_pending) {
23
+
locked = false;
24
+
continue;
25
+
}
26
+
```
27
+
28
+
**Files Changed**:
29
+
- `src/database.cc`: Modified `Database::Process()` function
30
+
- `test/serialization.test.js`: Added test cases for queue processing bug
0 commit comments