You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 51f128e
Browse filesBrowse the repository at this point in the historyBrowse files
fix: one index instance and one map wrapper per name, and a drop that cannot run twice (#1309)
The first read of a non-unique index after a store reopens runs the lazy layout
migration in SingleFieldIndex, which drops the legacy map. That migration is
guarded per SingleFieldIndex instance, but ComparableIndexer.findNitriteIndex
created instances with an unsynchronized check-then-act, so several threads
arriving at once each got their own instance and each ran the migration.
NitriteMVMap.drop() likewise tested its dropped flag and then ignored the result
of its compare-and-set, and NitriteMVStore.openMap handed out one wrapper per
caller. Once the first thread had removed the map, MVMap.getName() answered null
for the rest, and NitriteMVStore.removeMap(null) died in ConcurrentHashMap.remove:
NullPointerException: Cannot invoke "Object.hashCode()" because "key" is null
at NitriteMVStore.removeMap
at NitriteMVMap.drop
at SingleFieldIndex.migrateLegacyIndex
A second shape of the same race is a NullPointerException from Attributes.set
via NitriteMap.updateLastModifiedTime, which read getName() several times.
Seen on a production system on the first multi-threaded lookup after every
restart, since every close left an empty map under the legacy name (fixed by
#1295) and every start had to drop it again.
- ComparableIndexer registers the index with computeIfAbsent, so the per-instance
guard in SingleFieldIndex is the guard.
- NitriteMVStore.openMap and openRTree register the wrapper with computeIfAbsent,
so every holder shares one dropped flag; removeMap ignores a null name and does
not open (and thereby create) a map that is no longer in the store.
- NitriteMVMap captures its name at open and acts only when its compare-and-set
succeeds, so drop() and close() run once and never ask MVMap for a name it no
longer has.
- NitriteMap.updateLastModifiedTime reads the name once.
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
0 commit comments