Skip to content

Commit 8dfc428

Browse files
authored
CBG-5520 always use CBS preserve expiry feature (#8404)
1 parent 165da88 commit 8dfc428

3 files changed

Lines changed: 2 additions & 18 deletions

File tree

base/bucket_gocb_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2549,9 +2549,6 @@ func TestUpsertOptionPreserveExpiry(t *testing.T) {
25492549
bucket := GetTestBucket(t)
25502550
defer bucket.Close(ctx)
25512551
dataStore := bucket.GetSingleDataStore()
2552-
if !bucket.IsSupported(sgbucket.BucketStoreFeaturePreserveExpiry) {
2553-
t.Skip("Preserve expiry is not supported with this CBS version. Skipping test...")
2554-
}
25552552

25562553
testCases := []struct {
25572554
name string

db/crud.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2945,7 +2945,7 @@ func (db *DatabaseCollectionWithUser) updateAndReturnDoc(ctx context.Context, do
29452945
return
29462946
}
29472947
// If importing and the sync function has modified the expiry, allow sgbucket.MutateInOptions to modify the expiry
2948-
if db.dataStore.IsSupported(sgbucket.BucketStoreFeaturePreserveExpiry) && updatedDoc.Expiry != nil {
2948+
if updatedDoc.Expiry != nil {
29492949
opts.PreserveExpiry = false
29502950
}
29512951
docSequence = doc.Sequence

db/import.go

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -144,20 +144,7 @@ func (db *DatabaseCollectionWithUser) importDoc(ctx context.Context, docid strin
144144
var newRev string
145145
var alreadyImportedDoc *Document
146146

147-
mutationOptions := &sgbucket.MutateInOptions{}
148-
if db.dataStore.IsSupported(sgbucket.BucketStoreFeaturePreserveExpiry) {
149-
mutationOptions.PreserveExpiry = true
150-
} else {
151-
// Get the doc expiry if it wasn't passed in and preserve expiry is not supported
152-
if expiry == nil {
153-
getExpiry, getExpiryErr := db.dataStore.GetExpiry(ctx, docid)
154-
if getExpiryErr != nil {
155-
return nil, getExpiryErr
156-
}
157-
expiry = &getExpiry
158-
}
159-
existingDoc.Expiry = *expiry
160-
}
147+
mutationOptions := &sgbucket.MutateInOptions{PreserveExpiry: true}
161148

162149
docUpdateEvent := Import
163150
// do not update rev cache for any imports (CBG-4494 and CBG-4550)

0 commit comments

Comments
 (0)