Repository navigation
Commit c5bb7eb
fix: copy the catalog's stored name set instead of mutating it in place (#1296)
StoreCatalog.writeCollectionEntry (and the repository variants) read the
catalog document, wrapped it in MapMetaData, and added the new name to the
Set instance that MapMetaData had taken straight out of the document. On
MVStore that instance is the one held in the catalog page, and MVStore
serializes dirty pages on a background thread that any write can start
through tryCommit. Creating collections in a burst interleaved with writes,
which is what a data migration does, put the serializer's HashSet.writeObject
and the catalog's HashSet.add on the same set at the same time:
java.util.ConcurrentModificationException
at java.util.HashSet.writeObject
...
at org.h2.mvstore.type.ObjectDataType.serialize
at org.h2.mvstore.FileStore.serializeAndStore
org.h2.mvstore.MVStoreException: Could not serialize {mapNames=[...]}
at org.h2.mvstore.MVStore.panic
after which the store is closed and every later operation throws. Observed
on the first start after a Xodus-to-Nitrite migration that created eleven
collections in forty milliseconds.
MapMetaData now copies the stored set, so a write always puts a new set and
the instance a serializer may be reading is never touched, the same rule
WriteOperations.update already follows by cloning a document before
merging into it.
The test writes two entries and asserts that the set stored after the first
write is not the instance stored after the second and did not gain the
second name.
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>1 parent 8ed3f64 commit c5bb7eb
2 files changed
Lines changed: 63 additions & 4 deletions
File tree
- nitrite/src
- main/java/org/dizitart/no2/store
- test/java/org/dizitart/no2/store
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
58 | 60 | | |
59 | 61 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
0 commit comments