Skip to content

Commit 256006d

Browse files
committed
Merge remote-tracking branch 'origin/main' into ci-improve-shell-scripts
2 parents 9980374 + 33563a6 commit 256006d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1125
-1130
lines changed

.editorconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
; https://editorconfig.org/
2+
3+
root = true
4+
5+
[*]
6+
charset = utf-8
7+
end_of_line = lf
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[manifest/**.{json,xml}]
12+
indent_size = 4
13+
114
[*.sh]
215
indent_style = space
316
indent_size = 4
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Copyright 2022-Present Couchbase, Inc.
2+
#
3+
# Use of this software is governed by the Business Source License included in
4+
# the file licenses/BSL-Couchbase.txt. As of the Change Date specified in that
5+
# file, in accordance with the Business Source License, use of this software
6+
# will be governed by the Apache License, Version 2.0, included in the file
7+
# licenses/APL2.txt.
8+
9+
name: manifestvalidation
10+
permissions:
11+
contents: read
12+
13+
on:
14+
push:
15+
paths:
16+
- 'manifest/**'
17+
- '.github/workflows/manifestvalidation.yml'
18+
branches:
19+
- 'master'
20+
- 'main'
21+
- 'release/*'
22+
- 'feature/*'
23+
- 'CBG*'
24+
- 'ci-*'
25+
pull_request:
26+
paths:
27+
- 'manifest/**'
28+
- '.github/workflows/manifestvalidation.yml'
29+
branches:
30+
- 'master'
31+
- 'main'
32+
- 'release/*'
33+
34+
concurrency:
35+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
36+
cancel-in-progress: ${{ !contains(github.ref, 'release/')}}
37+
38+
jobs:
39+
manifest_validation:
40+
runs-on: ubuntu-latest
41+
steps:
42+
- uses: actions/checkout@v4
43+
- name: Ensure manifest product-config properties are sorted
44+
id: validate
45+
run: |
46+
diff <(jq --sort-keys . manifest/product-config.json) <(jq . manifest/product-config.json)

base/collection.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -357,12 +357,19 @@ func (b *GocbV2Bucket) GetCCVSettings(ctx context.Context) (ccvEnabled bool, max
357357
if err != nil {
358358
return false, nil, fmt.Errorf("error getting vbucket count: %v", err)
359359
}
360-
// we'd always expect a CAS value per vbucket if CCV is enabled and has propagated correctly - so fail if that's not the case
360+
361+
highCAS := make(map[VBNo]uint64, numVBuckets)
362+
// we'd always expect a CAS value per vbucket if CCV is enabled and has propagated correctly
363+
// except after a bucket flushed in Server < 7.6.8 see MB-64705
364+
// Treating this as ECCV=true with startingCas=0, which will mean imports will all get tagged with bucket SourceID.
361365
if len(response.VBucketsMaxCas) != int(numVBuckets) {
362-
return false, nil, fmt.Errorf("error getting vbucket CAS, expected %d vbucket CAS values, got %q", numVBuckets, response.VBucketsMaxCas)
366+
InfofCtx(ctx, KeyBucket, "Bucket %q has enableCrossClusterVersioning=true but unexpected number of vbucket CAS values - expected %d, got %+v. Treating all imports as originating on this Couchbase Server cluster.", MD(b.GetName()), numVBuckets, response.VBucketsMaxCas)
367+
for i := range numVBuckets {
368+
highCAS[VBNo(i)] = 0
369+
}
370+
return true, highCAS, nil
363371
}
364372

365-
highCAS := make(map[VBNo]uint64, numVBuckets)
366373
for i, casStr := range response.VBucketsMaxCas {
367374
cas, err := strconv.ParseUint(casStr, 10, 64)
368375
if err != nil {

base/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const (
2020
ProductName = "Couchbase Sync Gateway"
2121

2222
ProductAPIVersionMajor = "4"
23-
ProductAPIVersionMinor = "0"
23+
ProductAPIVersionMinor = "1"
2424
ProductAPIVersion = ProductAPIVersionMajor + "." + ProductAPIVersionMinor
2525
)
2626

db/crud.go

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,7 +1051,7 @@ func (db *DatabaseCollectionWithUser) updateHLV(ctx context.Context, d *Document
10511051

10521052
// MigrateAttachmentMetadata will move any attachment metadata defined in sync data to global sync xattr
10531053
func (c *DatabaseCollectionWithUser) MigrateAttachmentMetadata(ctx context.Context, docID string, cas uint64, syncData *SyncData) error {
1054-
xattrs, _, err := c.dataStore.GetXattrs(ctx, docID, []string{base.GlobalXattrName})
1054+
xattrs, _, err := c.dataStore.GetXattrs(ctx, docID, []string{base.GlobalXattrName, base.VirtualXattrRevSeqNo})
10551055
if err != nil && !base.IsXattrNotFoundError(err) {
10561056
return err
10571057
}
@@ -1073,14 +1073,32 @@ func (c *DatabaseCollectionWithUser) MigrateAttachmentMetadata(ctx context.Conte
10731073
if err != nil {
10741074
return base.RedactErrorf("Failed to Marshal sync data when attempting to migrate sync data attachments to global xattr with id: %s. Error: %v", base.UD(docID), err)
10751075
}
1076+
revSeqNo, err := unmarshalRevSeqNo(xattrs[base.VirtualXattrRevSeqNo])
1077+
if err != nil {
1078+
base.InfofCtx(ctx, base.KeyCRUD, "Could not determine revSeqNo found when attempting to migrate sync data attachments to global xattr for doc %q. Assuming 0. Error: %v", base.UD(docID), err)
1079+
}
1080+
1081+
metadataOnlyUpdate := &MetadataOnlyUpdate{
1082+
HexCAS: expandMacroCASValueString, // when non-empty, this is replaced with cas macro expansion
1083+
PreviousHexCAS: syncData.Cas,
1084+
PreviousRevSeqNo: revSeqNo,
1085+
}
1086+
rawMouXattr, err := base.JSONMarshal(metadataOnlyUpdate)
1087+
if err != nil {
1088+
return base.RedactErrorf("Failed to marshal _mou when attempting to migrate sync data attachments to global xattr with id: %s. Error: %v", base.UD(docID), err)
1089+
}
10761090

10771091
// build macro expansion for sync data. This will avoid the update to xattrs causing an extra import event (i.e. sync cas will be == to doc cas)
10781092
opts := &sgbucket.MutateInOptions{}
1079-
spec := macroExpandSpec(base.SyncXattrName)
1093+
spec := append(macroExpandSpec(base.SyncXattrName), sgbucket.NewMacroExpansionSpec(XattrMouCasPath(), sgbucket.MacroCas))
10801094
opts.MacroExpansion = spec
10811095
opts.PreserveExpiry = true // if doc has expiry, we should preserve this
10821096

1083-
updatedXattr := map[string][]byte{base.SyncXattrName: rawSyncXattr, base.GlobalXattrName: globalXattr}
1097+
updatedXattr := map[string][]byte{
1098+
base.SyncXattrName: rawSyncXattr,
1099+
base.GlobalXattrName: globalXattr,
1100+
base.MouXattrName: rawMouXattr,
1101+
}
10841102
_, err = c.dataStore.UpdateXattrs(ctx, docID, 0, cas, updatedXattr, opts)
10851103
return err
10861104
}
@@ -2667,6 +2685,11 @@ func (db *DatabaseCollectionWithUser) updateAndReturnDoc(ctx context.Context, do
26672685
skipObsoleteAttachmentsRemoval := false
26682686
isNewDocCreation := false
26692687

2688+
// Don't remove obsolete attachments if using ECCV - the other cluster may still need them!
2689+
if db.dbCtx.CachedCCVEnabled.Load() {
2690+
skipObsoleteAttachmentsRemoval = true
2691+
}
2692+
26702693
if db.UseXattrs() || upgradeInProgress {
26712694
var casOut uint64
26722695
// Update the document, storing metadata in extended attribute

db/database.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1681,7 +1681,11 @@ func (db *DatabaseContext) GetVersionPruningWindow(ctx context.Context, forceRef
16811681
func (db *DatabaseContext) updateCCVSettings(ctx context.Context) error {
16821682
cbStore, ok := base.AsCouchbaseBucketStore(db.Bucket)
16831683
if !ok {
1684-
db.CachedCCVEnabled.Store(false)
1684+
// for rosmar, ECCV is always enabled, mark starting cas as 0
1685+
db.CachedCCVEnabled.Store(true)
1686+
for vbNo := range db.numVBuckets {
1687+
db.CachedCCVStartingCas.Store(base.VBNo(vbNo), 0)
1688+
}
16851689
return nil
16861690
}
16871691

db/import_test.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,6 @@ func TestFeedImport(t *testing.T) {
119119
}
120120
for _, testCase := range testCases {
121121
t.Run(testCase.name, func(t *testing.T) {
122-
if base.UnitTestUrlIsWalrus() {
123-
t.Skip("rosmar does not support vBuckets and unknownSource")
124-
}
125122
docID := SafeDocumentName(t, t.Name())
126123
db.CachedCCVEnabled.Store(testCase.eccv)
127124
for vBucket := range db.numVBuckets {
@@ -282,9 +279,6 @@ func TestOnDemandImport(t *testing.T) {
282279
}
283280
for _, testCase := range testCases {
284281
t.Run(testCase.name, func(t *testing.T) {
285-
if base.UnitTestUrlIsWalrus() {
286-
t.Skip("rosmar does not support vBuckets and unknownSource")
287-
}
288282
docID := SafeDocumentName(t, t.Name())
289283
db.CachedCCVEnabled.Store(testCase.eccv)
290284
for vBucket := range db.numVBuckets {

docs/api/admin-capella.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ openapi: 3.0.3
1010
info:
1111
title: App Services Admin API
1212
description: 'App Services manages access and synchronization between Couchbase Lite and Couchbase Capella'
13-
version: '4.0'
13+
version: '4.1'
1414
license:
1515
name: Business Source License 1.1 (BSL)
1616
url: 'https://github.com/couchbase/sync_gateway/blob/master/LICENSE'

docs/api/admin.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ info:
1313
# Introduction
1414
1515
The Sync Gateway Admin REST API is used to administer user accounts and roles, and to run administrative tasks in superuser mode.
16-
version: '4.0'
16+
version: '4.1'
1717
license:
1818
name: Business Source License 1.1 (BSL)
1919
url: 'https://github.com/couchbase/sync_gateway/blob/master/LICENSE'

docs/api/components/schemas.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1577,9 +1577,7 @@ Database:
15771577
$ref: '#/Replication'
15781578
revs_limit:
15791579
description: |-
1580-
The maximum depth a document's revision tree can grow too.
1581-
1582-
The minimum is `20` if conflicts are allowed and 0 if not. It is not recommended to go below `100` when conflicts are allowed. The default is `100` if conflicts are allowed and `50` if not.
1580+
The maximum depth a document's revision tree can grow to.
15831581
type: number
15841582
default: 50
15851583
minimum: 0

0 commit comments

Comments
 (0)