From 6354c44a870c2fd22edcc3a2e581380c823da076 Mon Sep 17 00:00:00 2001 From: Varun Velamuri Date: Tue, 15 Feb 2022 14:59:01 +0530 Subject: [PATCH] MB-50958 Return NIL collection or scope ID's when bucket is not found 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 --- secondary/common/cluster_info_lite.go | 18 ++++++++++++++++++ secondary/common/cluster_info_provider.go | 1 + 2 files changed, 19 insertions(+) diff --git a/secondary/common/cluster_info_lite.go b/secondary/common/cluster_info_lite.go index 9eff99c6c..bdc17ad21 100644 --- a/secondary/common/cluster_info_lite.go +++ b/secondary/common/cluster_info_lite.go @@ -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 } @@ -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 } diff --git a/secondary/common/cluster_info_provider.go b/secondary/common/cluster_info_provider.go index 666db5f8a..a12dda7c6 100644 --- a/secondary/common/cluster_info_provider.go +++ b/secondary/common/cluster_info_provider.go @@ -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