mirror of
https://github.com/aljazceru/turso.git
synced 2026-02-19 15:05:47 +01:00
mvcc: fix logic bug in MvStore::insert_version_raw()
In insert_version_raw(), we correctly iterate the versions backwards because we want to find the newest version that is still older than the one we are inserting. However, the order of `.enumerate()` and `.rev()` was wrong, so the insertion position was calculated based on the position in the _reversed_ iterator, not the original iterator.
This commit is contained in:
@@ -1609,8 +1609,8 @@ impl<Clock: LogicalClock> MvStore<Clock> {
|
||||
// we can either switch to a tree-like structure, or at least use partition_point()
|
||||
// which performs a binary search for the insertion point.
|
||||
let mut position = 0_usize;
|
||||
for (i, v) in versions.iter().rev().enumerate() {
|
||||
if self.get_begin_timestamp(&v.begin) < self.get_begin_timestamp(&row_version.begin) {
|
||||
for (i, v) in versions.iter().enumerate().rev() {
|
||||
if self.get_begin_timestamp(&v.begin) <= self.get_begin_timestamp(&row_version.begin) {
|
||||
position = i + 1;
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user