Skip to content

Commit 346edd0

Browse files
committed
Remove test skips and disabled BLIP replication codepaths for delta sync when using legacy revs (missing follow-up for CBG-3748 / #7718)
Some remaining test cases remain skipped until we store legacy rev revision body backups (non-delta sync case - tracked with another ticket)
1 parent 32b6ca1 commit 346edd0

13 files changed

+48
-42
lines changed

db/blip_handler.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -795,8 +795,7 @@ func (bh *blipHandler) handleChanges(rq *blip.Message) error {
795795
}
796796
output.Write([]byte("]"))
797797
response := rq.Response()
798-
// Disable delta sync for protocol versions < 4, CBG-3748 (backwards compatibility for revID delta sync)
799-
if bh.sgCanUseDeltas && bh.useHLV() {
798+
if bh.sgCanUseDeltas {
800799
base.DebugfCtx(bh.loggingCtx, base.KeyAll, "Setting deltas=true property on handleChanges response")
801800
response.Properties[ChangesResponseDeltas] = trueProperty
802801
bh.replicationStats.HandleChangesDeltaRequestedCount.Add(int64(nRequested))
@@ -845,7 +844,6 @@ func (bh *blipHandler) handleProposeChanges(rq *blip.Message) error {
845844
defer func() {
846845
bh.replicationStats.HandleChangesTime.Add(time.Since(startTime).Nanoseconds())
847846
}()
848-
changesContainLegacyRevs := false // keep track if proposed changes have legacy revs for delta sync purposes
849847
versionVectorProtocol := bh.useHLV()
850848

851849
for i, change := range changeList {
@@ -867,7 +865,6 @@ func (bh *blipHandler) handleProposeChanges(rq *blip.Message) error {
867865
proposedVersionStr := ExtractCVFromProposeChangesRev(rev)
868866
status, currentRev = bh.collection.CheckProposedVersion(bh.loggingCtx, docID, proposedVersionStr, parentRevID, rev)
869867
} else {
870-
changesContainLegacyRevs = true
871868
status, currentRev = bh.collection.CheckProposedRev(bh.loggingCtx, docID, rev, parentRevID)
872869
}
873870
if status == ProposedRev_OK_IsNew {
@@ -899,8 +896,7 @@ func (bh *blipHandler) handleProposeChanges(rq *blip.Message) error {
899896
}
900897
output.Write([]byte("]"))
901898
response := rq.Response()
902-
// Disable delta sync for protocol versions < 4 or changes batches that have legacy revs in them, CBG-3748 (backwards compatibility for revID delta sync)
903-
if bh.sgCanUseDeltas && bh.useHLV() && !changesContainLegacyRevs {
899+
if bh.sgCanUseDeltas {
904900
base.DebugfCtx(bh.loggingCtx, base.KeyAll, "Setting deltas=true property on proposeChanges response")
905901
response.Properties[ChangesResponseDeltas] = trueProperty
906902
}

db/blip_sync_context.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,8 +387,7 @@ func (bsc *BlipSyncContext) handleChangesResponse(ctx context.Context, sender *b
387387

388388
var err error
389389

390-
// fallback to sending full revisions for non hlv aware peers, CBG-3748
391-
if deltaSrcRevID != "" && bsc.useHLV() {
390+
if deltaSrcRevID != "" {
392391
err = bsc.sendRevAsDelta(ctx, sender, docID, rev, deltaSrcRevID, seq, knownRevs, maxHistory, handleChangesResponseDbCollection, collectionIdx)
393392
} else {
394393
err = bsc.sendRevision(ctx, sender, docID, rev, seq, knownRevs, maxHistory, handleChangesResponseDbCollection, collectionIdx, legacyRev)

db/crud_test.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,8 +1081,15 @@ func BenchmarkHandleRevDelta(b *testing.B) {
10811081
}
10821082

10831083
func TestGetAvailableRevAttachments(t *testing.T) {
1084-
t.Skip("Revs are backed up by hash of CV now, test needs to fetch backup rev by revID, CBG-3748 (backwards compatibility for revID)")
10851084
db, ctx := setupTestDB(t)
1085+
db.Options.StoreLegacyRevTreeData = true
1086+
1087+
// TODO: CBG-4840 Only requires delta sync until restoration of non-delta sync RevTree ID revision body backups"
1088+
if !base.IsEnterpriseEdition() {
1089+
t.Skip("CBG-4840 - temp skip see above comment")
1090+
}
1091+
db.Options.DeltaSyncOptions = DeltaSyncOptions{Enabled: true, RevMaxAgeSeconds: 300}
1092+
10861093
defer db.Close(ctx)
10871094
collection, ctx := GetSingleDatabaseCollectionWithUser(ctx, t, db)
10881095

@@ -1104,19 +1111,19 @@ func TestGetAvailableRevAttachments(t *testing.T) {
11041111

11051112
// Get available attachments by immediate ancestor revision or parent revision
11061113
meta, found := collection.getAvailableRevAttachments(ctx, doc, parent)
1114+
require.True(t, found, "Ancestor should exists")
11071115
attachment := meta["camera.txt"].(map[string]interface{})
11081116
assert.Equal(t, "sha1-VoSNiNQGHE1HirIS5HMxj6CrlHI=", attachment["digest"])
11091117
assert.Equal(t, json.Number("20"), attachment["length"])
11101118
assert.Equal(t, json.Number("1"), attachment["revpos"])
1111-
assert.True(t, found, "Ancestor should exists")
11121119

11131120
// Get available attachments by immediate ancestor revision
11141121
meta, found = collection.getAvailableRevAttachments(ctx, doc, ancestor)
1122+
require.True(t, found, "Ancestor should exists")
11151123
attachment = meta["camera.txt"].(map[string]interface{})
11161124
assert.Equal(t, "sha1-VoSNiNQGHE1HirIS5HMxj6CrlHI=", attachment["digest"])
11171125
assert.Equal(t, json.Number("20"), attachment["length"])
11181126
assert.Equal(t, json.Number("1"), attachment["revpos"])
1119-
assert.True(t, found, "Ancestor should exists")
11201127
}
11211128

11221129
func TestGet1xRevAndChannels(t *testing.T) {

db/database.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,13 @@ const (
7070
DefaultSGReplicateEnabled = true
7171
DefaultSGReplicateWebsocketPingInterval = time.Minute * 5
7272
DefaultCompactInterval = 24 * time.Hour
73+
DefaultStoreLegacyRevTreeData = true // for 4.0, this is opt-out - we can switch to opt-in at a later date
7374
)
7475

7576
// Default values for delta sync
7677
var (
7778
DefaultDeltaSyncEnabled = false
7879
DefaultDeltaSyncRevMaxAge = uint32(60 * 60 * 24) // 24 hours in seconds
79-
DefaultStoreLegacyRevs = true // for 4.0, this is opt-out - we can switch to opt-in at a later date
8080
)
8181

8282
var (
@@ -206,6 +206,7 @@ type DatabaseContextOptions struct {
206206
NumIndexPartitions *uint32 // Number of partitions for GSI indexes, if not set will default to 1
207207
ImportVersion uint64 // Version included in import DCP checkpoints, incremented when collections added to db
208208
DisablePublicAllDocs bool // Disable public access to the _all_docs endpoint for this database
209+
StoreLegacyRevTreeData bool // Whether to store additional data for legacy rev tree support in delta sync and replication backup revs
209210
}
210211

211212
type ConfigPrincipals struct {
@@ -241,7 +242,6 @@ type UserViewsOptions struct {
241242
type DeltaSyncOptions struct {
242243
Enabled bool // Whether delta sync is enabled (EE only)
243244
RevMaxAgeSeconds uint32 // The number of seconds deltas for old revs are available for
244-
StoreLegacyRevs bool // Whether to store additional data to allow legacy RevTree ID support for delta sync
245245
}
246246

247247
type APIEndpoints struct {

db/database_collection.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ func (c *DatabaseCollection) deltaSyncRevMaxAgeSeconds() uint32 {
198198

199199
// storeLegacyRevTreeData returns true if legacy revision tree pointer data is stored. This is controlled at the database level.
200200
func (c *DatabaseCollection) storeLegacyRevTreeData() bool {
201-
return c.dbCtx.Options.DeltaSyncOptions.StoreLegacyRevs
201+
return c.dbCtx.Options.StoreLegacyRevTreeData
202202
}
203203

204204
// eventMgr manages nofication events. This is controlled at database level.

db/database_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -978,8 +978,8 @@ func TestDeltaSyncWhenFromRevIsLegacyRevTreeID(t *testing.T) {
978978
db.Options.DeltaSyncOptions = DeltaSyncOptions{
979979
Enabled: true,
980980
RevMaxAgeSeconds: 300,
981-
StoreLegacyRevs: true,
982981
}
982+
db.Options.StoreLegacyRevTreeData = true
983983

984984
defer db.Close(ctx)
985985
collection, ctx := GetSingleDatabaseCollectionWithUser(ctx, t, db)

db/revision_cache_test.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -623,10 +623,17 @@ func TestRevisionCacheInternalProperties(t *testing.T) {
623623
}
624624

625625
func TestBypassRevisionCache(t *testing.T) {
626-
t.Skip("Revs are backed up by hash of CV now, test needs to fetch backup rev by revID, CBG-3748 (backwards compatibility for revID)")
627-
base.SetUpTestLogging(t, base.LevelInfo, base.KeyAll)
626+
base.SetUpTestLogging(t, base.LevelDebug, base.KeyCRUD)
628627

629628
db, ctx := setupTestDB(t)
629+
db.Options.StoreLegacyRevTreeData = true
630+
631+
// TODO: CBG-4840 Only requires delta sync until restoration of non-delta sync RevTree ID revision body backups"
632+
if !base.IsEnterpriseEdition() {
633+
t.Skip("CBG-4840 - temp skip see above comment")
634+
}
635+
db.Options.DeltaSyncOptions = DeltaSyncOptions{Enabled: true, RevMaxAgeSeconds: 300}
636+
630637
defer db.Close(ctx)
631638

632639
collection, ctx := GetSingleDatabaseCollectionWithUser(ctx, t, db)

rest/attachment_test.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -687,12 +687,18 @@ func TestBulkGetBadAttachmentReproIssue2528(t *testing.T) {
687687
}
688688

689689
func TestConflictWithInvalidAttachment(t *testing.T) {
690-
t.Skip("Revs are backed up by hash of CV now, test needs to fetch backup rev by revID, CBG-3748 (backwards compatibility for revID)")
691-
rt := NewRestTester(t, nil)
690+
rt := NewRestTesterPersistentConfigNoDB(t)
692691
defer rt.Close()
693692

694693
dbConfig := rt.NewDbConfig()
695694
dbConfig.AllowConflicts = base.Ptr(true)
695+
696+
// TODO: CBG-4840 Only requires delta sync until restoration of non-delta sync RevTree ID revision body backups"
697+
if !base.IsEnterpriseEdition() {
698+
t.Skip("CBG-4840 - temp skip see above comment")
699+
}
700+
dbConfig.DeltaSync = &DeltaSyncConfig{Enabled: base.Ptr(true), RevMaxAgeSeconds: base.Ptr(uint32(300))}
701+
696702
RequireStatus(t, rt.CreateDatabase("db", dbConfig), http.StatusCreated)
697703
// Create Doc
698704
version := rt.CreateTestDoc("doc1")

rest/blip_api_crud_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1822,8 +1822,7 @@ func TestPutRevV4(t *testing.T) {
18221822
// Actual:
18231823
// - Same as Expected (this test is unable to repro SG #3281, but is being left in as a regression test)
18241824
func TestGetRemovedDoc(t *testing.T) {
1825-
t.Skip("Revs are backed up by hash of CV now, test needs to fetch backup rev by revID, CBG-3748 (backwards compatibility for revID)")
1826-
base.SetUpTestLogging(t, base.LevelInfo, base.KeyHTTP, base.KeySync, base.KeySyncMsg)
1825+
base.SetUpTestLogging(t, base.LevelDebug, base.KeyAll)
18271826

18281827
rt := NewRestTester(t, &RestTesterConfig{SyncFn: channels.DocChannelsSyncFunction})
18291828
defer rt.Close()
@@ -1894,7 +1893,8 @@ func TestGetRemovedDoc(t *testing.T) {
18941893
// Delete any temp revisions in case this prevents the bug from showing up (didn't make a difference)
18951894
tempRevisionDocID := base.RevPrefix + "foo:5:3-cde"
18961895
err = rt.GetSingleDataStore().Delete(tempRevisionDocID)
1897-
assert.NoError(t, err, "Unexpected Error")
1896+
// TODO: CBG-4840 - Requires restoration of non-delta sync RevTree revision backups
1897+
// assert.NoError(t, err, "Unexpected Error")
18981898

18991899
// Try to get rev 3 via BLIP API and assert that _removed == true
19001900
resultDoc, err = bt2.GetDocAtRev("foo", "3-cde")

rest/blip_api_delta_sync_test.go

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -331,8 +331,7 @@ func TestBlipDeltaSyncNewAttachmentPull(t *testing.T) {
331331
// Check EE is delta, and CE is full-body replication
332332
// msg, ok = client.pullReplication.WaitForMessage(5)
333333
msg = btcRunner.WaitForBlipRevMessage(client.id, doc1ID, version2)
334-
// Delta sync only works for Version vectors, CBG-3748 (backwards compatibility for revID)
335-
sgCanUseDeltas := base.IsEnterpriseEdition() && client.UseHLV()
334+
sgCanUseDeltas := base.IsEnterpriseEdition()
336335
if sgCanUseDeltas {
337336
// Check the request was sent with the correct deltaSrc property
338337
client.AssertDeltaSrcProperty(t, msg, version)
@@ -417,8 +416,7 @@ func TestBlipDeltaSyncPull(t *testing.T) {
417416
msg := btcRunner.WaitForBlipRevMessage(client.id, docID, version2)
418417

419418
// Check EE is delta, and CE is full-body replication
420-
// Delta sync only works for Version vectors, CBG-3748 (backwards compatibility for revID)
421-
sgCanUseDeltas := base.IsEnterpriseEdition() && client.UseHLV()
419+
sgCanUseDeltas := base.IsEnterpriseEdition()
422420
if sgCanUseDeltas {
423421
// Check the request was sent with the correct deltaSrc property
424422
client.AssertDeltaSrcProperty(t, msg, version)
@@ -464,7 +462,6 @@ func TestBlipDeltaSyncPullResend(t *testing.T) {
464462
GuestEnabled: true,
465463
}
466464
btcRunner := NewBlipTesterClientRunner(t)
467-
btcRunner.SkipSubtest[RevtreeSubtestName] = true // delta sync not implemented for rev tree replication, CBG-3748
468465
btcRunner.Run(func(t *testing.T) {
469466
rt := NewRestTester(t,
470467
&rtConfig)
@@ -659,8 +656,7 @@ func TestBlipDeltaSyncPullTombstoned(t *testing.T) {
659656
deltasRequestedEnd = rt.GetDatabase().DbStats.DeltaSync().DeltasRequested.Value()
660657
deltasSentEnd = rt.GetDatabase().DbStats.DeltaSync().DeltasSent.Value()
661658
}
662-
// delta sync not implemented for rev tree replication, CBG-3748
663-
sgCanUseDelta := base.IsEnterpriseEdition() && client.UseHLV()
659+
sgCanUseDelta := base.IsEnterpriseEdition()
664660
if sgCanUseDelta {
665661
assert.Equal(t, deltaCacheHitsStart, deltaCacheHitsEnd)
666662
assert.Equal(t, deltaCacheMissesStart+1, deltaCacheMissesEnd)
@@ -804,8 +800,7 @@ func TestBlipDeltaSyncPullTombstonedStarChan(t *testing.T) {
804800
deltasSentEnd = rt.GetDatabase().DbStats.DeltaSync().DeltasSent.Value()
805801
}
806802

807-
// delta sync not implemented for rev tree replication, CBG-3748
808-
sgCanUseDelta := base.IsEnterpriseEdition() && client1.UseHLV()
803+
sgCanUseDelta := base.IsEnterpriseEdition()
809804
if sgCanUseDelta {
810805
assert.Equal(t, deltaCacheHitsStart+1, deltaCacheHitsEnd)
811806
assert.Equal(t, deltaCacheMissesStart+1, deltaCacheMissesEnd)
@@ -851,7 +846,7 @@ func TestBlipDeltaSyncPullRevCache(t *testing.T) {
851846
defer client.Close()
852847

853848
client.ClientDeltas = true
854-
sgCanUseDeltas := base.IsEnterpriseEdition() && client.UseHLV()
849+
sgCanUseDeltas := base.IsEnterpriseEdition()
855850
btcRunner.StartPull(client.id)
856851

857852
// create doc1 rev 1-0335a345b6ffed05707ccc4cbc1b67f4
@@ -878,7 +873,6 @@ func TestBlipDeltaSyncPullRevCache(t *testing.T) {
878873

879874
// Check EE is delta
880875
// Check the request was sent with the correct deltaSrc property
881-
// delta sync not implemented for rev tree replication, CBG-3748
882876
if sgCanUseDeltas {
883877
client.AssertDeltaSrcProperty(t, msg, version1)
884878
} else {
@@ -919,7 +913,6 @@ func TestBlipDeltaSyncPullRevCache(t *testing.T) {
919913
updatedDeltaCacheHits := rt.GetDatabase().DbStats.DeltaSync().DeltaCacheHit.Value()
920914
updatedDeltaCacheMisses := rt.GetDatabase().DbStats.DeltaSync().DeltaCacheMiss.Value()
921915

922-
// delta sync not implemented for rev tree replication, CBG-3748
923916
if sgCanUseDeltas {
924917
assert.Equal(t, deltaCacheHits+1, updatedDeltaCacheHits)
925918
assert.Equal(t, deltaCacheMisses, updatedDeltaCacheMisses)
@@ -955,7 +948,7 @@ func TestBlipDeltaSyncPush(t *testing.T) {
955948
client := btcRunner.NewBlipTesterClientOptsWithRT(rt, nil)
956949
defer client.Close()
957950
client.ClientDeltas = true
958-
sgCanUseDeltas := base.IsEnterpriseEdition() && client.UseHLV()
951+
sgCanUseDeltas := base.IsEnterpriseEdition()
959952

960953
btcRunner.StartPull(client.id)
961954

0 commit comments

Comments
 (0)