Commit cf5e6ff
Fix: remove close(l.buffer) to prevent send-on-closed-channel panic i… (#92)
* Fix: remove close(l.buffer) to prevent send-on-closed-channel panic in async loggers
A race existed between Write() and flushLoop() during shutdown: a goroutine
could pass the l.closed check, get preempted, and resume after close(l.buffer),
causing a panic. Closing the buffer channel is unnecessary since flushLoop exits
via l.done; the GC reclaims the channel. Drain now uses a non-blocking select
loop instead of range.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Fix: increase SQLite connection pool to unlock WAL concurrent reads
The single-connection pool (MaxOpenConns=1) serialized all DB access,
negating WAL mode's native support for concurrent readers. Dashboard
read queries blocked on background flush writes and vice versa.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Fix: add writes WaitGroup + idempotent Close() to audit logger
Mirrors the synchronization pattern already in usage/logger.go:
- writes WaitGroup tracks in-flight Write() calls so Close() waits
for them before signaling flushLoop to stop
- Double-check pattern in Write() closes the race window between
the first closed.Load() and writes.Add(1)
- Close() uses closed.Swap(true) for idempotency — safe to call
multiple times during shutdown
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Revert date-range helper inlining in usage readers
Restore sqliteDateRangeConditions(), pgDateRangeConditions(), and
mongoDateRangeFilter() helper functions. The inlining was an unrelated
refactoring regression that duplicated identical date-range logic across
12 call sites with no behavioral change.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent 8dcaa58 commit cf5e6ff
3 files changed
Lines changed: 47 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
58 | 59 | | |
59 | 60 | | |
60 | 61 | | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
61 | 71 | | |
62 | 72 | | |
63 | 73 | | |
| |||
81 | 91 | | |
82 | 92 | | |
83 | 93 | | |
| 94 | + | |
84 | 95 | | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
85 | 104 | | |
86 | 105 | | |
87 | 106 | | |
| |||
119 | 138 | | |
120 | 139 | | |
121 | 140 | | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
128 | 152 | | |
| 153 | + | |
129 | 154 | | |
130 | 155 | | |
131 | 156 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
147 | 152 | | |
| 153 | + | |
148 | 154 | | |
149 | 155 | | |
150 | 156 | | |
| |||
0 commit comments