Skip to content

Commit

Permalink
MB-42668-FTS multi-collection index reports wrong number of docs
Browse files Browse the repository at this point in the history
During the data insert operations of multicollection indexes,
we decorate the key with the collectionID as a prefix. Same key
decoration has to be applied during the data delete operations as well.

Change-Id: Ie2e755513bb3c1efb401a837da107d932ca3757a
Reviewed-on: http://review.couchbase.org/c/cbft/+/140095
Well-Formed: Build Bot <build@couchbase.com>
Tested-by: Sreekanth Sivasankaran <sreekanth.sivasankaran@couchbase.com>
Reviewed-by: Abhinav Dangeti <abhinav@couchbase.com>
  • Loading branch information
sreekanth-cb committed Nov 12, 2020
1 parent 04ce34f commit aff87b9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pindex_bleve.go
Expand Up @@ -2025,6 +2025,11 @@ func (t *BleveDestPartition) DataDelete(partition string,
return fmt.Errorf("bleve: DataDelete nil batch")
}

// need to apply the key decoration with multicollection indexes.
if t.bdest.bleveDocConfig.multiCollection() {
key = append(extras[4:8], key...)
}

t.batch.Delete(string(key)) // TODO: string(key) makes garbage?

revNeedsUpdate, err := t.updateSeqLOCKED(seq)
Expand Down
4 changes: 4 additions & 0 deletions pindex_bleve_doc.go
Expand Up @@ -138,6 +138,10 @@ func (b *BleveDocumentConfig) MarshalJSON() ([]byte, error) {
return json.Marshal(&tmp)
}

func (b *BleveDocumentConfig) multiCollection() bool {
return len(b.CollPrefixLookup) > 1
}

func (b *BleveDocumentConfig) BuildDocumentEx(key, val []byte,
defaultType string, extrasType cbgt.DestExtrasType,
extras []byte) (*BleveDocument, []byte, error) {
Expand Down

0 comments on commit aff87b9

Please sign in to comment.