Steve Yegge
a9b2f9f553
Fix race condition in auto-flush mechanism (issue bd-52)
...
Critical fixes to code review findings:
1. Remove global state access from flushToJSONLWithState
- FlushManager now has true single ownership of flush state
- No more race conditions from concurrent global state access
- flushToJSONLWithState trusts only the flushState parameter
- Legacy wrapper handles success detection via failure count
2. Fix shutdown timeout data loss risk
- Increased timeout from 5s → 30s to prevent data loss
- Added detailed comments explaining the timeout rationale
- Better error message indicates potential data loss scenario
Implementation details:
- New FlushManager uses event-driven single-owner pattern
- Channels eliminate shared mutable state (markDirtyCh, flushNowCh, etc.)
- Comprehensive race detector tests verify concurrency safety
- Backward compatible with existing tests via legacy code path
- ARCHITECTURE.md documents design principles and guarantees
Test results:
- All race detector tests pass (TestFlushManager*)
- Legacy API compatibility verified (TestMarkDirtyAndScheduleFlush*)
- No race conditions detected under concurrent load
Future improvements tracked as beads:
- bd-gdn: Add functional tests for flush correctness verification
- bd-5xt: Log errors from timer-triggered flushes
- bd-i00: Convert magic numbers to named constants
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-11-20 21:24:31 -05:00
..
2025-11-20 19:37:01 -05:00
2025-11-12 10:48:36 -08:00
2025-11-09 14:58:03 -08:00
2025-11-04 00:23:25 -08:00
2025-11-20 21:24:31 -05:00
2025-11-02 10:01:38 -08:00
2025-11-02 10:38:24 -08:00
2025-10-27 20:08:50 -07:00
2025-11-20 20:21:37 -05:00
2025-11-07 22:06:50 -08:00
2025-11-20 19:11:27 -05:00
2025-11-03 22:23:36 -08:00
2025-11-03 22:23:36 -08:00
2025-11-01 11:11:20 -07:00
2025-11-20 20:58:57 -05:00
2025-10-26 21:55:01 -07:00
2025-11-02 15:37:57 -08:00
2025-11-04 23:12:42 -08:00
2025-11-20 20:39:23 -05:00
2025-11-05 20:39:47 -08:00
2025-11-06 20:14:34 -08:00
2025-11-05 21:04:00 -08:00
2025-11-07 21:17:24 -08:00
2025-11-05 10:26:58 -08:00
2025-10-29 22:55:13 -07:00
2025-11-07 18:57:43 -08:00
2025-11-07 21:29:22 -08:00
2025-11-05 20:39:47 -08:00
2025-10-22 13:59:58 -07:00
2025-11-02 22:17:08 -08:00
2025-10-22 13:59:58 -07:00
2025-11-07 18:57:43 -08:00
2025-11-01 19:20:01 -07:00
2025-11-07 18:57:43 -08:00
2025-10-20 21:08:49 -07:00
2025-11-10 10:22:03 -08:00
2025-11-05 20:39:47 -08:00
2025-11-20 19:00:36 -05:00
2025-11-01 21:27:09 -07:00
2025-11-19 05:06:12 -05:00
2025-11-05 20:39:47 -08:00
2025-10-20 21:08:49 -07:00
2025-11-02 22:17:08 -08:00
2025-11-05 20:39:47 -08:00
2025-11-05 20:39:47 -08:00
2025-11-20 08:13:06 -08:00
2025-10-20 21:08:49 -07:00
2025-11-19 05:07:16 -05:00
2025-10-31 18:40:32 -07:00
2025-11-20 08:13:06 -08:00
2025-11-08 03:10:12 -08:00
2025-11-02 18:52:44 -08:00
2025-11-08 02:20:33 -08:00
2025-11-15 12:52:34 -08:00
2025-10-31 15:11:29 -07:00
2025-11-02 22:34:24 -08:00
2025-11-02 08:09:58 -08:00
2025-10-26 22:31:24 -07:00
2025-11-08 18:16:39 -08:00
2025-11-18 05:20:11 -05:00
2025-11-20 19:37:01 -05:00
2025-10-24 13:45:04 -07:00
2025-11-20 20:58:57 -05:00
2025-11-01 11:11:20 -07:00
2025-11-02 18:52:44 -08:00
2025-11-05 10:26:58 -08:00
2025-11-01 20:29:13 -07:00
2025-11-19 05:06:12 -05:00
2025-11-07 20:07:59 -08:00
2025-11-05 14:31:41 -08:00
2025-11-19 05:06:12 -05:00
2025-11-20 19:11:27 -05:00
2025-11-20 21:24:31 -05:00
2025-11-20 21:24:31 -05:00
2025-11-05 20:39:47 -08:00
2025-11-09 14:53:59 -08:00
2025-11-17 10:06:35 -07:00
2025-11-17 10:12:46 -07:00
2025-10-31 01:07:42 -07:00
2025-10-27 20:00:49 -07:00
2025-11-19 05:06:12 -05:00
2025-11-09 14:53:59 -08:00
2025-10-30 22:24:42 -07:00
2025-11-06 13:01:44 -08:00
2025-11-08 00:00:43 -08:00
2025-11-20 19:00:36 -05:00
2025-11-08 02:28:54 -08:00
2025-11-20 20:45:39 -05:00
2025-11-17 10:12:46 -07:00
2025-11-17 10:06:35 -07:00
2025-11-05 19:04:14 -08:00
2025-11-09 14:13:48 -08:00
2025-11-20 19:24:26 -05:00
2025-11-20 21:23:26 -05:00
2025-11-01 22:01:41 -07:00
2025-11-20 21:23:26 -05:00
2025-11-01 20:29:13 -07:00
2025-10-26 22:31:24 -07:00
2025-11-02 22:34:24 -08:00
2025-11-06 20:00:08 -08:00
2025-11-20 20:45:39 -05:00
2025-11-08 13:09:42 -08:00
2025-11-20 21:24:31 -05:00
2025-10-20 21:08:49 -07:00
2025-11-20 19:11:27 -05:00
2025-11-20 20:24:36 -05:00
2025-11-15 12:52:34 -08:00
2025-11-20 19:01:30 -05:00
2025-11-20 19:01:30 -05:00
2025-11-17 10:12:46 -07:00
2025-11-02 14:31:22 -08:00
2025-11-08 18:16:39 -08:00
2025-11-09 14:53:59 -08:00
2025-11-09 14:53:59 -08:00
2025-11-17 11:32:37 -07:00
2025-11-17 11:32:37 -07:00
2025-10-18 18:21:17 -07:00
2025-11-17 10:12:46 -07:00
2025-10-14 01:10:18 -07:00
2025-10-27 20:08:50 -07:00
2025-11-20 20:45:39 -05:00
2025-11-02 11:02:58 -08:00
2025-10-27 22:59:19 -07:00
2025-10-20 21:08:49 -07:00
2025-10-27 18:31:01 +00:00
2025-10-26 22:31:24 -07:00
2025-11-02 22:34:24 -08:00
2025-10-29 12:56:51 -07:00
2025-11-01 23:56:03 -07:00
2025-11-04 23:12:41 -08:00
2025-10-31 19:44:43 -07:00
2025-10-31 22:39:53 -07:00
2025-11-04 11:25:36 -08:00
2025-11-12 10:48:36 -08:00
2025-11-20 20:45:39 -05:00
2025-10-27 20:38:13 -07:00
2025-11-17 10:12:46 -07:00
2025-10-31 23:03:56 -07:00
2025-11-20 20:45:39 -05:00
2025-11-20 20:45:39 -05:00
2025-11-06 18:49:07 -08:00
2025-11-20 20:45:39 -05:00
2025-11-09 16:16:45 -08:00
2025-11-05 18:10:06 -08:00
2025-11-02 17:09:39 -08:00
2025-11-20 20:33:52 -05:00
2025-11-03 20:31:11 -08:00
2025-11-03 20:31:11 -08:00
2025-11-03 22:01:37 -08:00
2025-11-07 21:58:22 -08:00
2025-11-04 01:10:18 -08:00
2025-10-31 19:44:43 -07:00
2025-11-20 20:45:39 -05:00
2025-11-05 17:37:53 -08:00
2025-11-16 18:10:46 -07:00
2025-11-08 18:22:28 -08:00
2025-11-05 21:04:00 -08:00