Commit a9df648
committed
[fix](editlog) Fix BDBEnvironment.close() not holding writeLock causing ConcurrentModificationException
BDBEnvironment.close() iterates openedDatabases without acquiring
lock.writeLock(), while openDatabase() concurrently modifies the same
ArrayList under the write lock. This causes ConcurrentModificationException
when a RollbackException triggers close() on the replayer thread while
HTTP/heartbeat/RPC handler threads call openDatabase() via getMaxJournalId().
The race window: replayer catches RollbackException in getDatabaseNames(),
calls bdbEnvironment.close() which iterates openedDatabases with for-each.
Concurrently, a SHOW FRONTENDS or heartbeat thread calls getMaxJournalId()
→ openDatabase() → openedDatabases.add(). The ArrayList iterator detects
the structural modification and throws ConcurrentModificationException.
This kills the replayer thread, causing the follower FE to fall permanently
behind the master.
Fix: wrap the entire close() body with lock.writeLock() to mutually exclude
with openDatabase() and removeDatabase().1 parent 9ecfd40 commit a9df648
1 file changed
Lines changed: 26 additions & 21 deletions
Lines changed: 26 additions & 21 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
481 | 481 | | |
482 | 482 | | |
483 | 483 | | |
484 | | - | |
485 | | - | |
486 | | - | |
487 | | - | |
488 | | - | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
489 | 492 | | |
490 | | - | |
491 | | - | |
| 493 | + | |
492 | 494 | | |
493 | | - | |
494 | | - | |
495 | | - | |
496 | | - | |
497 | | - | |
498 | | - | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
499 | 502 | | |
500 | | - | |
501 | 503 | | |
502 | | - | |
503 | | - | |
504 | | - | |
505 | | - | |
506 | | - | |
507 | | - | |
508 | | - | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
509 | 512 | | |
| 513 | + | |
| 514 | + | |
510 | 515 | | |
511 | 516 | | |
512 | 517 | | |
| |||
0 commit comments