Skip to content

Commit

Permalink
MB-50958 Return NIL collection or scope ID's when bucket is not found
Browse files Browse the repository at this point in the history
The current cinfo lite infra will return ErrBucketNotFound when
retrieving the collection info if bucket is not existing in the
cluster. This will lead to subsequent operations being skipped.
(E.g., monitorKeyspace will try to getCollectionID but as
GetCollectionInfoProvider returns ErrBucketNotFound, it returns
without cleaning up indexes)

This patch addresses the problem by returning COLLECTION_ID_NIL
and SCOPE_ID_NIL when bucket is not found

Change-Id: Iba4b69d5cd6a537a2b6c4798c678527667879641
  • Loading branch information
varunv-cb committed Feb 16, 2022
1 parent 6677db8 commit 6354c44
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
18 changes: 18 additions & 0 deletions secondary/common/cluster_info_lite.go
Expand Up @@ -1611,6 +1611,12 @@ func (cicl *ClusterInfoCacheLiteClient) GetNodesInfoProvider() (NodesInfoProvide
func (cicl *ClusterInfoCacheLiteClient) GetCollectionInfoProvider(bucketName string) (
CollectionInfoProvider, error) {
ci, err := cicl.GetCollectionInfo(bucketName)

if err == ErrBucketNotFound {
ci := newCollectionInfoWithErr(bucketName, err)
return CollectionInfoProvider(ci), nil
}

if err != nil {
return nil, err
}
Expand Down Expand Up @@ -2321,18 +2327,30 @@ func (c *ClusterInfoCacheLiteClient) GetCollectionInfo(bucketName string) (
}

func (ci *collectionInfo) CollectionID(bucket, scope, collection string) string {
if len(ci.errList) > 0 && ci.errList[0] == ErrBucketNotFound {
return collections.COLLECTION_ID_NIL
}
return ci.manifest.GetCollectionID(scope, collection)
}

func (ci *collectionInfo) ScopeID(bucket, scope string) string {
if len(ci.errList) > 0 && ci.errList[0] == ErrBucketNotFound {
return collections.SCOPE_ID_NIL
}
return ci.manifest.GetScopeID(scope)
}

func (ci *collectionInfo) ScopeAndCollectionID(bucket, scope, collection string) (string, string) {
if len(ci.errList) > 0 && ci.errList[0] == ErrBucketNotFound {
return collections.SCOPE_ID_NIL, collections.COLLECTION_ID_NIL
}
return ci.manifest.GetScopeAndCollectionID(scope, collection)
}

func (ci *collectionInfo) GetIndexScopeLimit(bucket, scope string) (uint32, error) {
if len(ci.errList) > 0 && ci.errList[0] == ErrBucketNotFound {
return collections.NUM_INDEXES_NIL, nil
}
return ci.manifest.GetIndexScopeLimit(scope), nil
}

Expand Down
1 change: 1 addition & 0 deletions secondary/common/cluster_info_provider.go
Expand Up @@ -130,6 +130,7 @@ type CollectionInfoProvider interface {
CollectionID(bucket, scope, collection string) string
ScopeID(bucket, scope string) string
ScopeAndCollectionID(bucket, scope, collection string) (string, string)
GetIndexScopeLimit(bucket, scope string) (uint32, error)

RWLockable // Stub to make ClusterInfoCache replaceable with CollectionInfo
FetchBucketInfo(bucketName string) error
Expand Down

0 comments on commit 6354c44

Please sign in to comment.