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

Fix race condition in DoesNotHave #1287

Merged
merged 4 commits into from
Apr 8, 2020
Merged

Fix race condition in DoesNotHave #1287

merged 4 commits into from
Apr 8, 2020

Conversation

jarifibrahim
Copy link
Contributor

@jarifibrahim jarifibrahim commented Apr 1, 2020

There is a race condition in the t.bf variable if table.LoadBloomsOnOpen is set to false.
This issue was also seen in hypermodeinc/dgraph#4689 (comment)

==================
WARNING: DATA RACE
Read at 0x00c00028eed8 by goroutine 20:
  github.com/dgraph-io/badger/v2/table.(*Table).DoesNotHave()
      /home/aman/gocode/pkg/mod/github.com/dgraph-io/badger/v2@v2.0.1-rc1.0.20200316175624-91c31ebe8c22/table/table.go:515 +0x3f8
  github.com/dgraph-io/badger/v2.(*IteratorOptions).pickTables()
      /home/aman/gocode/pkg/mod/github.com/dgraph-io/badger/v2@v2.0.1-rc1.0.20200316175624-91c31ebe8c22/iterator.go:407 +0x29e
  github.com/dgraph-io/badger/v2.(*levelHandler).appendIterators()
      /home/aman/gocode/pkg/mod/github.com/dgraph-io/badger/v2@v2.0.1-rc1.0.20200316175624-91c31ebe8c22/level_handler.go:308 +0x38e
  github.com/dgraph-io/badger/v2.(*levelsController).appendIterators()
      /home/aman/gocode/pkg/mod/github.com/dgraph-io/badger/v2@v2.0.1-rc1.0.20200316175624-91c31ebe8c22/levels.go:1025 +0xcc
  github.com/dgraph-io/badger/v2.(*Txn).NewIterator()
      /home/aman/gocode/pkg/mod/github.com/dgraph-io/badger/v2@v2.0.1-rc1.0.20200316175624-91c31ebe8c22/iterator.go:468 +0x4d3
  github.com/dgraph-io/badger/v2.(*Txn).NewKeyIterator()
      /home/aman/gocode/pkg/mod/github.com/dgraph-io/badger/v2@v2.0.1-rc1.0.20200316175624-91c31ebe8c22/iterator.go:489 +0xfb
  github.com/dgraph-io/dgraph/posting.getNew()
      /home/aman/gocode/src/github.com/dgraph-io/dgraph/posting/mvcc.go:345 +0x20c
  github.com/dgraph-io/dgraph/posting.(*LocalCache).getInternal()
      /home/aman/gocode/src/github.com/dgraph-io/dgraph/posting/lists.go:208 +0x4d6
  github.com/dgraph-io/dgraph/worker.(*queryState).handleUidPostings.func1()
      /home/aman/gocode/src/github.com/dgraph-io/dgraph/posting/lists.go:241 +0x416
  github.com/dgraph-io/dgraph/worker.(*queryState).handleUidPostings.func2()
      /home/aman/gocode/src/github.com/dgraph-io/dgraph/worker/task.go:811 +0x47

This change is Reviewable

Copy link
Contributor

@mangalaman93 mangalaman93 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 2 of 2 files at r1.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @ashish-goswami and @manishrjain)

Copy link
Contributor

@manishrjain manishrjain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 2 of 2 files at r1.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @ashish-goswami and @jarifibrahim)


table/table.go, line 385 at r1 (raw file):

	if t.opt.LoadBloomsOnOpen {
		// We don't need to acquire lock here because this will be called in sequential manner.

Just add the lock here as well.

Copy link
Contributor Author

@jarifibrahim jarifibrahim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 1 of 2 files reviewed, 1 unresolved discussion (waiting on @ashish-goswami, @mangalaman93, and @manishrjain)


table/table.go, line 385 at r1 (raw file):

Previously, manishrjain (Manish R Jain) wrote…

Just add the lock here as well.

Done.

@jarifibrahim jarifibrahim merged commit 6e032c0 into master Apr 8, 2020
@jarifibrahim jarifibrahim deleted the ibrahim/table-race branch April 8, 2020 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants