Skip to content

Commit

Permalink
CBL-4840: Test "Database Upgrade From 2.7 to Version Vectors" Fails
Browse files Browse the repository at this point in the history
  • Loading branch information
callumbirks authored Oct 5, 2023
1 parent 7c777bf commit 650240d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion C/tests/c4DatabaseTest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1233,7 +1233,7 @@ TEST_CASE("Database Upgrade From 2.7", "[Database][Upgrade][C]") {
}

// This one is failing due to CBL-4840
TEST_CASE("Database Upgrade From 2.7 to Version Vectors", "[.failing][Database][Upgrade][C]") {
TEST_CASE("Database Upgrade From 2.7 to Version Vectors", "[Database][Upgrade][C]") {
testOpeningOlderDBFixture("upgrade_2.7.cblite2", kC4DB_VersionVectors);
}

Expand Down
10 changes: 10 additions & 0 deletions LiteCore/Database/DatabaseImpl+Upgrade.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,21 @@ namespace litecore {
options.sortOption = kUnsorted;
options.includeDeleted = true;
options.contentOption = kEntireBody;

// CBL-4840: When a document with `kDeleted` flag is upgraded to version vectors, it will be placed
// in `del_` keystore. If the original rev-tree doc was not in `del_` keystore, the BothKeyStore
// enumerator may attempt to read it again once it reaches the `del_` keystore. We can prevent
// this from causing an error by making sure we don't bother parsing any records that have already
// been upgraded to VV.
auto isVersionVector = [](const Record& rec) { return revid(rec.version()).isVersion(); };

RecordEnumerator e(_dataFile->getKeyStore(ksName), options);
while ( e.next() ) {
// Read the doc as a RevTreeRecord. This will correctly read both the old 2.x style
// record (with no `extra`) and the new 3.x style.
const Record& rec = e.record();
// CBL-4840
if ( isVersionVector(rec) ) continue;
RevTreeRecord revTree(defaultKeyStore(), rec);
if ( newVersioning == kC4VectorVersioning ) {
// Upgrade from rev-trees (v2 or v3) to version-vectors:
Expand Down

0 comments on commit 650240d

Please sign in to comment.