Commit 1ec3092
committed
[fix](editlog) Fix concurrency bugs and robustness issues in editlog subsystem
1. EditLog.txId data race: Convert `txId` from plain `long` to `AtomicLong`.
The flusher thread and DDL caller threads both read/write `txId` without
synchronization, causing torn reads on 64-bit values.
2. EditLog.logEdit(op, List<T>) missing roll check: This bulk-write path
incremented txId but never checked against `edit_log_roll_num`, so the
edit log would never roll when this path was used.
3. BDBEnvironment.close() not thread-safe: `close()` iterated
`openedDatabases` without holding `lock.writeLock()`, while
`openDatabase()` concurrently modifies the same list under the write
lock. This causes ConcurrentModificationException when a RollbackException
triggers close() on the replayer thread while HTTP/heartbeat/RPC threads
call openDatabase() via getMaxJournalId().
4. EditLog.flushEditLog() silent hang on fatal error: When `System.exit(-1)`
is called after a write failure, producer threads blocked on
`req.lock.wait()` are never notified. If `System.exit` is delayed by
shutdown hooks, those threads hang indefinitely.
5. BDBJEJournal.write() burns journal IDs on failure: Both single and batch
write methods called `nextJournalId.getAndIncrement/getAndAdd` before
the actual write, so a failed write permanently skips journal IDs.
Now IDs are only advanced after successful commit.
6. BDBEnvironment.removeDatabase() index corruption: Manual index tracking
with `openedDatabases.remove(index)` computed wrong index when the
target was not the first element. Replaced with `iterator.remove()`.
7. JournalObservable.upperBound() off-by-one: The binary search used
`right = size - 1` and `right = middle - 1`, which could miss notifying
observers whose targetJournalVersion exactly equals the journalId.
Fixed to standard upper_bound pattern.
8. Remove dead `editStream` field and `getEditLogSize()` method from
EditLog. The field was never assigned (always null), so
`getEditLogSize()` would always NPE.1 parent 9ecfd40 commit 1ec3092
File tree
4 files changed
+67
-62
lines changed- fe/fe-core/src/main/java/org/apache/doris
- journal/bdbje
- persist
- qe
4 files changed
+67
-62
lines changedLines changed: 29 additions & 30 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
312 | 312 | | |
313 | 313 | | |
314 | 314 | | |
315 | | - | |
316 | | - | |
317 | | - | |
| 315 | + | |
| 316 | + | |
318 | 317 | | |
319 | 318 | | |
320 | 319 | | |
321 | 320 | | |
322 | | - | |
| 321 | + | |
323 | 322 | | |
324 | 323 | | |
325 | | - | |
326 | | - | |
327 | | - | |
328 | | - | |
329 | | - | |
330 | 324 | | |
331 | 325 | | |
332 | 326 | | |
| |||
481 | 475 | | |
482 | 476 | | |
483 | 477 | | |
484 | | - | |
485 | | - | |
486 | | - | |
487 | | - | |
488 | | - | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
489 | 486 | | |
490 | | - | |
491 | | - | |
| 487 | + | |
492 | 488 | | |
493 | | - | |
494 | | - | |
495 | | - | |
496 | | - | |
497 | | - | |
498 | | - | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
499 | 496 | | |
500 | | - | |
501 | 497 | | |
502 | | - | |
503 | | - | |
504 | | - | |
505 | | - | |
506 | | - | |
507 | | - | |
508 | | - | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
509 | 506 | | |
| 507 | + | |
| 508 | + | |
510 | 509 | | |
511 | 510 | | |
512 | 511 | | |
| |||
Lines changed: 7 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
134 | | - | |
| 134 | + | |
| 135 | + | |
135 | 136 | | |
136 | 137 | | |
137 | 138 | | |
| |||
155 | 156 | | |
156 | 157 | | |
157 | 158 | | |
| 159 | + | |
158 | 160 | | |
159 | 161 | | |
160 | 162 | | |
| |||
237 | 239 | | |
238 | 240 | | |
239 | 241 | | |
240 | | - | |
241 | | - | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
242 | 245 | | |
243 | 246 | | |
244 | 247 | | |
| |||
273 | 276 | | |
274 | 277 | | |
275 | 278 | | |
| 279 | + | |
276 | 280 | | |
277 | 281 | | |
278 | 282 | | |
| |||
Lines changed: 25 additions & 20 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
167 | 167 | | |
168 | 168 | | |
169 | 169 | | |
170 | | - | |
171 | | - | |
172 | | - | |
| 170 | + | |
173 | 171 | | |
174 | 172 | | |
175 | 173 | | |
| |||
255 | 253 | | |
256 | 254 | | |
257 | 255 | | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
258 | 264 | | |
259 | 265 | | |
260 | 266 | | |
| |||
264 | 270 | | |
265 | 271 | | |
266 | 272 | | |
267 | | - | |
| 273 | + | |
268 | 274 | | |
269 | | - | |
270 | | - | |
| 275 | + | |
| 276 | + | |
271 | 277 | | |
272 | 278 | | |
273 | | - | |
| 279 | + | |
274 | 280 | | |
275 | 281 | | |
276 | 282 | | |
| |||
1557 | 1563 | | |
1558 | 1564 | | |
1559 | 1565 | | |
1560 | | - | |
| 1566 | + | |
| 1567 | + | |
| 1568 | + | |
| 1569 | + | |
| 1570 | + | |
| 1571 | + | |
| 1572 | + | |
1561 | 1573 | | |
1562 | 1574 | | |
1563 | 1575 | | |
| |||
1654 | 1666 | | |
1655 | 1667 | | |
1656 | 1668 | | |
1657 | | - | |
| 1669 | + | |
1658 | 1670 | | |
1659 | | - | |
1660 | | - | |
| 1671 | + | |
| 1672 | + | |
1661 | 1673 | | |
1662 | 1674 | | |
1663 | | - | |
| 1675 | + | |
1664 | 1676 | | |
1665 | 1677 | | |
1666 | 1678 | | |
| |||
1709 | 1721 | | |
1710 | 1722 | | |
1711 | 1723 | | |
1712 | | - | |
| 1724 | + | |
1713 | 1725 | | |
1714 | 1726 | | |
1715 | 1727 | | |
1716 | 1728 | | |
1717 | 1729 | | |
1718 | | - | |
1719 | | - | |
1720 | | - | |
1721 | | - | |
1722 | | - | |
1723 | | - | |
1724 | | - | |
1725 | 1730 | | |
1726 | 1731 | | |
1727 | 1732 | | |
| |||
Lines changed: 6 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | | - | |
| 66 | + | |
| 67 | + | |
67 | 68 | | |
68 | 69 | | |
69 | | - | |
| 70 | + | |
70 | 71 | | |
71 | 72 | | |
72 | | - | |
| 73 | + | |
73 | 74 | | |
74 | 75 | | |
75 | | - | |
| 76 | + | |
76 | 77 | | |
77 | 78 | | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
| 79 | + | |
83 | 80 | | |
84 | 81 | | |
85 | 82 | | |
| |||
0 commit comments