Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
37 changes: 21 additions & 16 deletions db/indextest/indextest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,24 +370,29 @@ func getPartitionCount(t *testing.T, bucket *base.GocbV2Bucket, dsName sgbucket.
username, password, _ = bucket.Spec.Auth.GetCredentials()
}
ctx := base.TestCtx(t)
var partitionCount uint32
for _, gsiEp := range gsiEps {
uri := fmt.Sprintf("/api/v1/stats/%s.%s.%s/%s?partition=true", bucket.BucketName(), dsName.ScopeName(), dsName.CollectionName(), indexName)
respBytes, statusCode, err := base.MgmtRequest(bucket.HttpClient(ctx), gsiEp, http.MethodGet, uri, "application/json", username, password, nil)
require.NoError(t, err)
// on a non partitioned index, the index might not be found on a given index node
if statusCode == http.StatusNotFound {
uri := "/getIndexStatus"
respBytes, statusCode, err := base.MgmtRequest(bucket.HttpClient(ctx), gsiEps[0], http.MethodGet, uri, "application/json", username, password, nil)
require.NoError(t, err)
require.Equal(t, http.StatusOK, statusCode, "unexpected status code for %s", respBytes)
var output struct {
Status []struct {
IndexName string `json:"indexName"`
Bucket string `json:"bucket"`
Collection string `json:"collection"`
Scope string `json:"scope"`
NumPartition uint32 `json:"numPartition"`
} `json:"status"`
}
require.NoError(t, base.JSONUnmarshal(respBytes, &output), "error unmarshalling %s", respBytes)
for _, idx := range output.Status {
if idx.Bucket != bucket.BucketName() || idx.Collection != dsName.CollectionName() || idx.Scope != dsName.ScopeName() {
continue
}
require.Equal(t, http.StatusOK, statusCode, "unexpected status code for %s", respBytes)
var output map[string]any
require.NoError(t, base.JSONUnmarshal(respBytes, &output))
for key := range output {
fmt.Printf("Key: %s\n", key)
if strings.HasPrefix(key, "Partition-") {
partitionCount++
}
if idx.IndexName != indexName {
continue
}
return idx.NumPartition
}
return partitionCount
require.Failf(t, "index not found", "index %s not found in %+v", indexName, output)
return 0
}
16 changes: 15 additions & 1 deletion docs/api/components/schemas.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1719,9 +1719,23 @@ Database:
default: true
deprecated: true
num_index_replicas:
description: This is the number of Global Secondary Indexes (GSI) to use for core indexes.
description: |-
**Deprecated, please use the database setting `index.num_replicas` instead**
deprecated: true
type: number
default: 1
index:
type: object
description: Settings for Global Secondary Indexes (GSI).
properties:
num_replicas:
description: This is the number of Global Secondary Indexes (GSI) to use for core indexes.
type: number
default: 1
num_partitions:
description: The number of partitions to use for the Global Secondary Indexes (GSI) for large indexes. It is not recommended to set this unless you have performance issues. If set, the recommended number is 8.
type: number
default: 1
use_views:
description: Force the use of views instead of GSI.
type: boolean
Expand Down
2 changes: 1 addition & 1 deletion integration-test/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
services:
couchbase:
container_name: couchbase
image: "couchbase/server:${COUCHBASE_DOCKER_IMAGE_NAME:-enterprise-7.1.4}"
image: "couchbase/server:${COUCHBASE_DOCKER_IMAGE_NAME:-enterprise-7.6.5}"
ports:
- 8091:8091
- 8092:8092
Expand Down
1 change: 1 addition & 0 deletions rest/config_database.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ func DefaultDbConfig(sc *StartupConfig, useXattrs bool) *DbConfig {
if base.IsEnterpriseEdition() {
dbConfig.ImportPartitions = base.Uint16Ptr(base.GetDefaultImportPartitions(sc.IsServerless()))
}
dbConfig.Index.NumPartitions = base.Ptr(db.DefaultNumIndexPartitions)
} else {
dbConfig.AutoImport = base.BoolPtr(false)
}
Expand Down
Loading