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
Multi-process mode: two processes opening a new model both backfill the same index #192
With AllowMultiProcessAccess, two processes can open the same database with a model that declares a new index at about the same time. Each sees no such index in its metadata snapshot, builds its own copy with its own root page (ApplyIndexBuilder → CreateUnregistered → RebuildIndexAsync), and calls Register → SaveMetadata.
SaveMetadata writes the process's whole in-memory CollectionMetadata; only SequenceValue is re-read from the file first. So the second save wins:
the first process's index pages are leaked;
the first process keeps maintaining an index whose root is no longer in the metadata, so its later writes are missing from the persisted index.
The same last-writer-wins applies to any other metadata change CollectionIndexManager makes in two processes. This was also the case before #175; index creation on open just didn't fill the index.
Possible fixes: take the cross-process writer lock around "check the stored metadata → build → register", and re-read the metadata under that lock before building, so the second process picks up the first one's index instead of building its own. Or make SaveMetadata merge index entries instead of overwriting them.
Activity