FoundationDB / fdb-record-layer

A record-oriented store built on FoundationDB
Apache License 2.0
589 stars 104 forks source link

RecordStore has incorrect index state after metadata change #917

Open ScottDugas opened 4 years ago

ScottDugas commented 4 years ago

In the event that a store is opened, even with calling checkVersion if the RecordMetaDataProvider later returns a newer (or older) metadata, the record store will immediately start using the new metadata, without calling checkVersion. One such issue with this is that the index state is incorrect (indexes will appear readable, even though they haven't been built yet). Another issue is that the records stored might not align with the metadata version in the store header.

As part of my fix to #489 I have added at least one test for this.

MMcM commented 4 years ago

Perhaps a record store should copy the metadata from the provider into its own field at some sensible point in its open lifecycle and have a separate, explicit, operation to refresh it.

ScottDugas commented 4 years ago

More precisely, I think it should do so during checkVersion. and then calling checkVersion again should refresh the metadata. While we're at it, the UserVersionChecker should probably become a field of the FDBRecordStore rather than just a part of the builder.

MMcM commented 4 years ago

The StoreExistenceCheck parameter to checkVersion may only make sense the first time after build, as part of open. An open store presumably exists.