Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MB-57871: Recover panic by GetCardinality #259

Closed
wants to merge 1 commit into from
Closed
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
18 changes: 18 additions & 0 deletions posting.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package zap
import (
"encoding/binary"
"fmt"
"log"
"math"
"reflect"

Expand Down Expand Up @@ -240,6 +241,23 @@ func (p *PostingsList) Count() uint64 {
e = 1
}
} else if p.postings != nil {
// A safeguard against panic by roaring.Bitmap.GetCardinality()
//
// See https://jira.issues.couchbase.com/browse/MB-57871
//
// A panic was observed in the wild in Bitmap.GetCardinality(),
// because of a nil pointer dereference, that happened due to
// presence of a nil container in the Bitmap.highlowcontainer.containers
//
// This is a temporary fix to help us recover from the panic, and to
// log bitmap stats to help us understand the issue better.
defer func() {
if r := recover(); r != nil {
log.Printf("zapx: PostingsList.Count() panic: %v"+
"\n\nBitmap Stats:%+v\n", r, p.postings.Stats())
}
}()

n = p.postings.GetCardinality()
if p.except != nil {
e = p.postings.AndCardinality(p.except)
Expand Down
Loading