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
[sys-4816] handle rocksdb upgrade to 7.10 in backwards compatible way (#277)
A new per-file entity called epoch number was introduced in v7.10, which is used to sort L0 files (previously sorted by largest_seqno). We need to make sure this number matches in leader follower. This is quite tricky during leaf deploy.
* leader is on new version while follower is on old version. This is fine actually. epoch number will just be skipped on follower
* follower is on new version while leader is on old version. This is the tricky one and this entire PR is to deal with this case.
The hack we use is to make follower to ignore epoch number from leader but simply calculating the epoch number on the fly. There are two cases:
* flush which generates L0 files. epoch number is allocated based on next_epoch_number of each CF. The L0 files are sorted based on largest seqno.
* compaction which merges files in lower levels to higher levels. epoch number = min epoch number of input files.
This is mostly fine, except when db is reopened. Rocksdb doesn't track next_epoch_number in manifest file. When db is
reopened, it calculates the next_epoch_number based on max epoch number of existing live files. So it's possible for the next_epoch_number to go backwards when db is reopened. Following two cases are possible:
* leader reopens db, causing next_epoch_number on leader to go backwards. So follower needs to rewind it.
* follower reopens db, causing next_epoch_number on follower to go backwards. So follower needs to advance it.
A new replication option: AR_RESET_IF_EPOCH_MISMATCH is added to help with this issue. rewind and advance are handled carefully to make sure it doesn't break existing file ordering.
The change in this PR is quite hacky, but fortunately we can remove most of them once rocksdb is fully upgraded
0 commit comments