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

another batch data race #1149

Closed
mschoch opened this issue Mar 3, 2019 · 0 comments
Closed

another batch data race #1149

mschoch opened this issue Mar 3, 2019 · 0 comments
Assignees

Comments

@mschoch
Copy link
Contributor

mschoch commented Mar 3, 2019

Another corner case can lead to a race when resetting a batch, in this case it happens when batch just contains a delete (or more likely as it was found in the wild, when a batch contains ONLY deletes)

Here is the race with scorch:

=== RUN   TestBatchRaceBugXXX
==================
WARNING: DATA RACE
Write at 0x00c0003484a0 by goroutine 10:
  github.com/blevesearch/bleve.TestBatchRaceBugXXX()
      /home/mschoch/dev/go/src/github.com/blevesearch/bleve/index/index.go:310 +0x320
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:827 +0x162

Previous read at 0x00c0003484a0 by goroutine 15:
  github.com/blevesearch/bleve/index/scorch.(*Scorch).Batch.func2()
      /home/mschoch/dev/go/src/github.com/blevesearch/bleve/index/scorch/scorch.go:317 +0x52

Similar observation with upsidedown:

=== RUN   TestBatchRaceBugXXX
==================
WARNING: DATA RACE
Write at 0x00c000352440 by goroutine 10:
  github.com/blevesearch/bleve.TestBatchRaceBugXXX()
      /home/mschoch/dev/go/src/github.com/blevesearch/bleve/index/index.go:310 +0x2dc
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:827 +0x162

Previous read at 0x00c000352440 by goroutine 11:
  github.com/blevesearch/bleve/index/upsidedown.(*UpsideDownCouch).Batch.func1()
      /home/mschoch/dev/go/src/github.com/blevesearch/bleve/index/upsidedown/upsidedown.go:815 +0x52

The code to reproduce is:

func TestBatchRaceBugXXX(t *testing.T) {
	defer func() {
		err := os.RemoveAll("testidx")
		if err != nil {
			t.Fatal(err)
		}
	}()
	//i, err := New("testidx", NewIndexMapping())
	i, err := NewUsing("testidx", NewIndexMapping(), "scorch", "scorch", nil)
	if err != nil {
		t.Fatal(err)
	}
	defer func() {
		err := i.Close()
		if err != nil {
			t.Fatal(err)
		}
	}()
	b := i.NewBatch()
	b.Delete("1")
	err = i.Batch(b)
	if err != nil {
		t.Fatal(err)
	}
	b.Reset()
	err = i.Batch(b)
	if err != nil {
		t.Fatal(err)
	}
	b.Reset()
}
@mschoch mschoch self-assigned this Mar 3, 2019
@mschoch mschoch closed this as completed in a91b427 Mar 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant