Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions base/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ type CouchbaseClusterSpec struct {
type CouchbaseCluster struct {
server string
clusterOptions gocb.ClusterOptions
forcePerBucketAuth bool // Forces perBucketAuth authenticators to be used to connect to the bucket
perBucketAuth map[string]*gocb.Authenticator
bucketConnectionMode BucketConnectionMode // Whether to cache cluster connections
cachedClusterConnection *gocb.Cluster // Cached cluster connection, should only be used by GetConfigBuckets
Expand Down Expand Up @@ -236,7 +235,7 @@ var _ BootstrapConnection = &CouchbaseCluster{}
// _system._mobile is the source of truth and reads transparently fall back to _default._default
// for any keys that have not yet been migrated; when false, _default._default is used unconditionally.
func NewCouchbaseCluster(ctx context.Context, clusterSpec CouchbaseClusterSpec,
forcePerBucketAuth bool, perBucketCreds PerBucketCredentialsConfig,
perBucketCreds PerBucketCredentialsConfig,
useXattrConfig bool, useSystemMetadataCollection bool, bucketMode BucketConnectionMode) (*CouchbaseCluster, error) {
securityConfig, err := GoCBv2SecurityConfig(ctx, Ptr(clusterSpec.TLSSkipVerify), clusterSpec.CACertpath)
if err != nil {
Expand Down Expand Up @@ -273,7 +272,6 @@ func NewCouchbaseCluster(ctx context.Context, clusterSpec CouchbaseClusterSpec,

cbCluster := &CouchbaseCluster{
server: clusterSpec.Server,
forcePerBucketAuth: forcePerBucketAuth,
perBucketAuth: perBucketAuth,
clusterOptions: clusterOptions,
bucketConnectionMode: bucketMode,
Expand Down Expand Up @@ -1115,8 +1113,6 @@ func defaultCollectionExists(b *gocb.Bucket) (bool, error) {
func (cc *CouchbaseCluster) GetClusterConnectionForBucket(ctx context.Context, bucketName string) (connection *gocb.Cluster, teardownFn func(), err error) {
if bucketAuth, set := cc.perBucketAuth[bucketName]; set {
connection, err = cc.connect(bucketAuth)
} else if cc.forcePerBucketAuth {
return nil, nil, fmt.Errorf("unable to get bucket %q since credentials are not defined in bucket_credentials", MD(bucketName).Redact())
} else {
connection, err = cc.connect(nil)
}
Expand Down
9 changes: 4 additions & 5 deletions base/bootstrap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ func TestBootstrapRefCounting(t *testing.T) {
}, 2*time.Minute, 5*time.Millisecond) // Wait for bucket pool to be initialized, since GetConfigBuckets requires equal buckets to TestBucketPool.numBuckets

var perBucketCredentialsConfig map[string]*CredentialsConfig
forcePerBucketAuth := false
cluster, err := NewCouchbaseCluster(ctx, TestClusterSpec(t), forcePerBucketAuth, perBucketCredentialsConfig, TestUseXattrs(), false, CachedClusterConnections)
cluster, err := NewCouchbaseCluster(ctx, TestClusterSpec(t), perBucketCredentialsConfig, TestUseXattrs(), false, CachedClusterConnections)
require.NoError(t, err)
defer cluster.Close()
require.NotNil(t, cluster)
Expand Down Expand Up @@ -146,7 +145,7 @@ func newTestBootstrapConnection(t *testing.T) BootstrapConnection {
t.Cleanup(cluster.Close)
return cluster
}
cluster, err := NewCouchbaseCluster(ctx, TestClusterSpec(t), false, nil, TestUseXattrs(), false, CachedClusterConnections)
cluster, err := NewCouchbaseCluster(ctx, TestClusterSpec(t), nil, TestUseXattrs(), false, CachedClusterConnections)
require.NoError(t, err)
t.Cleanup(cluster.Close)
return cluster
Expand Down Expand Up @@ -360,7 +359,7 @@ func newCouchbaseBootstrapDualFixture(t *testing.T, useXattrs bool) bootstrapDua
assert.Equal(c, int32(GTestBucketPool.numBuckets), GTestBucketPool.stats.TotalBucketInitCount.Load())
}, 2*time.Minute, 5*time.Millisecond)

cluster, err := NewCouchbaseCluster(ctx, TestClusterSpec(t), false, nil, useXattrs, true, CachedClusterConnections)
cluster, err := NewCouchbaseCluster(ctx, TestClusterSpec(t), nil, useXattrs, true, CachedClusterConnections)
require.NoError(t, err)
t.Cleanup(cluster.Close)

Expand Down Expand Up @@ -469,7 +468,7 @@ func newCouchbaseBootstrapTwoBucketDualFixture(t *testing.T, useXattrs bool) boo
assert.Equal(c, int32(GTestBucketPool.numBuckets), GTestBucketPool.stats.TotalBucketInitCount.Load())
}, 2*time.Minute, 5*time.Millisecond)

cluster, err := NewCouchbaseCluster(ctx, TestClusterSpec(t), false, nil, useXattrs, true, CachedClusterConnections)
cluster, err := NewCouchbaseCluster(ctx, TestClusterSpec(t), nil, useXattrs, true, CachedClusterConnections)
require.NoError(t, err)
t.Cleanup(cluster.Close)

Expand Down
6 changes: 0 additions & 6 deletions base/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,6 @@ const (
// Number of kv connections (pipelines) per Couchbase Server node
DefaultGocbKvPoolSize = 2

// Number of kv connections (pipelines) per Couchbase Server node when running in serverless
DefaultGocbKvPoolSizeServerless = 1

// kv connections buffer size per Couchbase Server node when running in serverless
DefaultKvBufferSizeServerless = 1 * 1024 * 1024

// Number of connections used by DCP agents - must be 1
GoCBPoolSizeDCP = 1

Expand Down
23 changes: 7 additions & 16 deletions base/dcp_sharded.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,13 @@ import (
)

const (
CBGTIndexTypeSyncGatewayImport = "syncGateway-import-"
DefaultImportPartitions = 16
DefaultImportPartitionsServerless = 6
CBGTCfgIndexDefs = SyncDocPrefix + "cfgindexDefs"
CBGTCfgNodeDefsKnown = SyncDocPrefix + "cfgnodeDefs-known"
CBGTCfgNodeDefsWanted = SyncDocPrefix + "cfgnodeDefs-wanted"
CBGTCfgPlanPIndexes = SyncDocPrefix + "cfgplanPIndexes"
CBGTIndexTypeSyncGatewayResync = "syncGateway-resync"
CBGTIndexTypeSyncGatewayImport = "syncGateway-import-"
DefaultImportPartitions = 16
CBGTCfgIndexDefs = SyncDocPrefix + "cfgindexDefs"
CBGTCfgNodeDefsKnown = SyncDocPrefix + "cfgnodeDefs-known"
CBGTCfgNodeDefsWanted = SyncDocPrefix + "cfgnodeDefs-wanted"
CBGTCfgPlanPIndexes = SyncDocPrefix + "cfgplanPIndexes"
CBGTIndexTypeSyncGatewayResync = "syncGateway-resync"
)

// CbgtUnregisterFeedCallback is the function invoked by cbgt when a DCP feed shuts down.
Expand Down Expand Up @@ -910,14 +909,6 @@ func RemoveDestFactory(destKey string) {
cbgtDestFactoriesLock.Unlock()
}

func GetDefaultImportPartitions(serverless bool) uint16 {
if serverless {
return DefaultImportPartitionsServerless
} else {
return DefaultImportPartitions
}
}

type sgMgrEventHandlers struct {
ctx context.Context
ctxCancel context.CancelCauseFunc
Expand Down
11 changes: 1 addition & 10 deletions base/gocb_connection_string.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const (
kvPoolSizeKey = "kv_pool_size"
)

// GoCBConnStringParams represents parameters that are passed to gocb when creating a new connection string. These are the subset of values that are changed when running with serverless mode.
// GoCBConnStringParams represents parameters that are passed to gocb when creating a new connection string.
type GoCBConnStringParams struct {
KvPoolSize int // corresponds to kv_pool_size
KvBufferSize int // corresponds to kv_buffer_size
Expand All @@ -38,15 +38,6 @@ func DefaultGoCBConnStringParams() *GoCBConnStringParams {
}
}

// DefaultServerlessGoCBConnStringParams returns a GoCBConnStringParams with the default values for serverless deployments.
func DefaultServerlessGoCBConnStringParams() *GoCBConnStringParams {
return &GoCBConnStringParams{
KvPoolSize: DefaultGocbKvPoolSizeServerless,
KvBufferSize: DefaultKvBufferSizeServerless,
DcpBufferSize: DefaultDCPBufferServerless,
}
}

// getGoCBConnSpec returns a gocb connection spec based on the server string. The provided defaults will be used only when the corresponding property is not set in the connection string.
func getGoCBConnSpec(server string, defaults *GoCBConnStringParams) (*gocbconnstr.ConnSpec, error) {
connSpec, err := gocbconnstr.Parse(server)
Expand Down
24 changes: 0 additions & 24 deletions base/gocb_connection_string_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@ func TestGetGoCBConnStringWithDefaults(t *testing.T) {
connStr: "couchbase://127.0.0.1?idle_http_connection_timeout=90000&kv_pool_size=2&max_idle_http_connections=64000&max_perhost_idle_http_connections=256",
params: DefaultGoCBConnStringParams(),
},
{
name: "default, serverless params",
server: "couchbase://127.0.0.1",
connStr: "couchbase://127.0.0.1?dcp_buffer_size=1048576&idle_http_connection_timeout=90000&kv_buffer_size=1048576&kv_pool_size=1&max_idle_http_connections=64000&max_perhost_idle_http_connections=256",
params: DefaultServerlessGoCBConnStringParams(),
},
{
name: "kv_pool_size=8, no params",
server: "couchbase://127.0.0.1?kv_pool_size=8",
Expand All @@ -49,12 +43,6 @@ func TestGetGoCBConnStringWithDefaults(t *testing.T) {
connStr: "couchbase://127.0.0.1?idle_http_connection_timeout=90000&kv_pool_size=8&max_idle_http_connections=64000&max_perhost_idle_http_connections=256",
params: DefaultGoCBConnStringParams(),
},
{
name: "kv_pool_size=8, serverless params",
server: "couchbase://127.0.0.1?kv_pool_size=8",
connStr: "couchbase://127.0.0.1?dcp_buffer_size=1048576&idle_http_connection_timeout=90000&kv_buffer_size=1048576&kv_pool_size=8&max_idle_http_connections=64000&max_perhost_idle_http_connections=256",
params: DefaultServerlessGoCBConnStringParams(),
},
{
name: "kv_buffer_size=3, no params",
server: "couchbase://127.0.0.1?kv_buffer_size=3",
Expand All @@ -66,12 +54,6 @@ func TestGetGoCBConnStringWithDefaults(t *testing.T) {
connStr: "couchbase://127.0.0.1?idle_http_connection_timeout=90000&kv_buffer_size=3&kv_pool_size=2&max_idle_http_connections=64000&max_perhost_idle_http_connections=256",
params: DefaultGoCBConnStringParams(),
},
{
name: "kv_buffer_size=3, serverless params",
server: "couchbase://127.0.0.1?kv_buffer_size=3",
connStr: "couchbase://127.0.0.1?dcp_buffer_size=1048576&idle_http_connection_timeout=90000&kv_buffer_size=3&kv_pool_size=1&max_idle_http_connections=64000&max_perhost_idle_http_connections=256",
params: DefaultServerlessGoCBConnStringParams(),
},
{
name: "dcp_buffer_size=3, no params",
server: "couchbase://127.0.0.1?dcp_buffer_size=3",
Expand All @@ -83,12 +65,6 @@ func TestGetGoCBConnStringWithDefaults(t *testing.T) {
connStr: "couchbase://127.0.0.1?dcp_buffer_size=3&idle_http_connection_timeout=90000&kv_pool_size=2&max_idle_http_connections=64000&max_perhost_idle_http_connections=256",
params: DefaultGoCBConnStringParams(),
},
{
name: "dcp_pool_size=3, serverless params",
server: "couchbase://127.0.0.1?dcp_buffer_size=3",
connStr: "couchbase://127.0.0.1?dcp_buffer_size=3&idle_http_connection_timeout=90000&kv_buffer_size=1048576&kv_pool_size=1&max_idle_http_connections=64000&max_perhost_idle_http_connections=256",
params: DefaultServerlessGoCBConnStringParams(),
},
}
for _, testCase := range testCases {
t.Run(testCase.name, func(t *testing.T) {
Expand Down
3 changes: 0 additions & 3 deletions base/gocb_dcp_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ const openStreamTimeout = 30 * time.Second
const openRetryCount = uint32(10)
const DefaultNumWorkers = 8

// DCP buffer size if we are running in serverless
const DefaultDCPBufferServerless = 1 * 1024 * 1024

const getVbSeqnoTimeout = 30 * time.Second

const infiniteOpenStreamRetries = uint32(math.MaxUint32)
Expand Down
2 changes: 0 additions & 2 deletions base/rosmar_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -706,8 +706,6 @@ func (c *RosmarCluster) CachedBootstrapTargets() map[string]string {
func (c *RosmarCluster) Close() {
}

func (c *RosmarCluster) SetConnectionStringServerless() error { return nil }

// AsRosmarBucket returns a bucket as a rosmar.Bucket, or an error if it is not one.
func AsRosmarBucket(bucket Bucket) (*rosmar.Bucket, error) {
baseBucket := GetBaseBucket(bucket)
Expand Down
29 changes: 5 additions & 24 deletions docs/api/components/schemas.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1668,13 +1668,6 @@ Database:
Disable this when you are confident all clients use newer CV-based revisions and no longer require legacy RevTree ID lookups.
type: boolean
default: true
suspendable:
description: |-
Set to true to allow the database to be suspended.

Defaults to true when running in serverless mode otherwise defaults to false.
type: boolean
default: false
sync:
description: |-
The Javascript function that newly created documents are ran through for the default scope and collection.
Expand Down Expand Up @@ -1827,6 +1820,11 @@ Database:
The maximum number of revisions to store in the revision cache.
type: number
deprecated: true
suspendable:
description: This option has no effect.
type: boolean
default: false
deprecated: true
title: Database-config
Disabled-users-and-roles:
type: object
Expand Down Expand Up @@ -2174,21 +2172,6 @@ Compact-status:
- start_time
- last_error
title: Compact-status
Serverless:
description: Configuration for when SG is running in serverless mode
type: object
properties:
enabled:
description: Run SG in to serverless mode
type: boolean
readOnly: true
min_config_fetch_interval:
description: |-
How long database configs should be kept for in Sync Gateway before refreshing. Set to 0 to fetch configs everytime. This is used for requested databases that SG does not know about.

This is a duration and therefore can be provided with units "h", "m", "s", "ms", "us", and "ns". For example, 5 hours, 20 minutes, and 30 seconds would be `5h20m30s`.
type: string
default: 1s
Startup-config:
type: object
x-requirePropertiesSorted: true
Expand Down Expand Up @@ -2477,8 +2460,6 @@ Startup-config:
description: Whether HTTP2 support is enabled
type: boolean
default: false
serverless:
$ref: '#/Serverless'
stats_log_frequency:
description: |-
How often should stats be written to stats logs.
Expand Down
10 changes: 5 additions & 5 deletions rest/admin_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func (h *handler) handleCreateDB() error {

dbCreds, _ := h.server.Config.DatabaseCredentials[dbName]
bucketCreds, _ := h.server.Config.BucketCredentials[bucket]
if err := config.setup(h.ctx(), dbName, h.server.Config.Bootstrap, dbCreds, bucketCreds, h.server.Config.IsServerless()); err != nil {
if err := config.setup(h.ctx(), dbName, h.server.Config.Bootstrap, dbCreds, bucketCreds); err != nil {
return err
}

Expand Down Expand Up @@ -167,7 +167,7 @@ func (h *handler) handleCreateDB() error {
h.server._dbConfigs[dbName].cfgCas = cas
} else {
// Intentionally pass in an empty BootstrapConfig to avoid inheriting any credentials or server when running with a legacy config (CBG-1764)
if err := config.setup(h.ctx(), dbName, BootstrapConfig{}, nil, nil, false); err != nil {
if err := config.setup(h.ctx(), dbName, BootstrapConfig{}, nil, nil); err != nil {
return err
}

Expand Down Expand Up @@ -805,7 +805,7 @@ func (h *handler) updateConfigAndReloadDatabase(ctx base.NonCancellableContext,

dbCreds, _ := h.server.Config.DatabaseCredentials[dbName]
bucketCreds, _ := h.server.Config.BucketCredentials[bucket]
if err := updatedDbConfig.setup(ctx.Ctx, dbName, h.server.Config.Bootstrap, dbCreds, bucketCreds, h.server.Config.IsServerless()); err != nil {
if err := updatedDbConfig.setup(ctx.Ctx, dbName, h.server.Config.Bootstrap, dbCreds, bucketCreds); err != nil {
return err
}

Expand Down Expand Up @@ -839,7 +839,7 @@ func (h *handler) updateNonPersistentDbConfig(ctx base.NonCancellableContext, db
}

dbCreds, _ := h.server.Config.DatabaseCredentials[dbName]
if err := updatedDbConfig.setup(ctx.Ctx, dbName, h.server.Config.Bootstrap, dbCreds, nil, false); err != nil {
if err := updatedDbConfig.setup(ctx.Ctx, dbName, h.server.Config.Bootstrap, dbCreds, nil); err != nil {
return err
}
if err := h.server.ReloadDatabaseWithConfig(ctx, *updatedDbConfig); err != nil {
Expand Down Expand Up @@ -993,7 +993,7 @@ func (h *handler) handlePutDbConfig() (err error) {
tmpConfig.cfgCas = bucketDbConfig.cfgCas
dbCreds, _ := h.server.Config.DatabaseCredentials[dbName]
bucketCreds, _ := h.server.Config.BucketCredentials[bucket]
if err := tmpConfig.setup(h.ctx(), dbName, h.server.Config.Bootstrap, dbCreds, bucketCreds, h.server.Config.IsServerless()); err != nil {
if err := tmpConfig.setup(h.ctx(), dbName, h.server.Config.Bootstrap, dbCreds, bucketCreds); err != nil {
return nil, err
}

Expand Down
2 changes: 1 addition & 1 deletion rest/adminapitest/admin_api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ func TestLoggingKeys(t *testing.T) {
require.JSONEq(t, `{}`, response.BodyString())
}

func TestServerlessChangesEndpointLimit(t *testing.T) {
func TestChangesEndpointDuringConcurrentReplicationLimit(t *testing.T) {
base.RequireNumTestBuckets(t, 2)
base.SetUpTestLogging(t, base.LevelInfo, base.KeyReplicate, base.KeyHTTP, base.KeyHTTPResp, base.KeySync, base.KeySyncMsg, base.KeyChanges)
rt := rest.NewRestTester(t, &rest.RestTesterConfig{
Expand Down
Loading
Loading