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

concurrent map write found while running tests #360

Closed
mschoch opened this issue Mar 20, 2016 · 1 comment
Closed

concurrent map write found while running tests #360

mschoch opened this issue Mar 20, 2016 · 1 comment

Comments

@mschoch
Copy link
Contributor

mschoch commented Mar 20, 2016

=== RUN   TestBatchCrashBug195
fatal error: concurrent map read and map write

goroutine 45 [running]:
runtime.throw(0x6a16a0, 0x21)
    /Users/mschoch/Documents/research/gosrc/src/runtime/panic.go:530 +0x90 fp=0xc820108888 sp=0xc820108870
runtime.mapaccessK(0x48e680, 0xc820143740, 0xc820070b28, 0x61f7d8, 0x5)
    /Users/mschoch/Documents/research/gosrc/src/runtime/hashmap.go:389 +0x5a fp=0xc8201088d0 sp=0xc820108888
runtime.mapiternext(0xc820108cf0)
    /Users/mschoch/Documents/research/gosrc/src/runtime/hashmap.go:774 +0x63e fp=0xc820108960 sp=0xc8201088d0
github.com/blevesearch/bleve/index/upside_down.(*UpsideDownCouch).Batch(0xc82007c280, 0xc820149bb0, 0x0, 0x0)
    /Users/mschoch/go/src/github.com/blevesearch/bleve/index/upside_down/upside_down.go:798 +0x184 fp=0xc820108ea8 sp=0xc820108960
github.com/blevesearch/bleve.(*indexImpl).Batch(0xc820052310, 0xc82015a420, 0x0, 0x0)
    /Users/mschoch/go/src/github.com/blevesearch/bleve/index_impl.go:319 +0x122 fp=0xc820108f10 sp=0xc820108ea8
github.com/blevesearch/bleve.TestBatchCrashBug195.func2(0xc82018f8c0, 0xa791f8, 0xc820052310, 0xc82015a420, 0xc820080480)
    /Users/mschoch/go/src/github.com/blevesearch/bleve/index_race_test.go:55 +0x71 fp=0xc820108f88 sp=0xc820108f10
runtime.goexit()
    /Users/mschoch/Documents/research/gosrc/src/runtime/asm_amd64.s:1998 +0x1 fp=0xc820108f90 sp=0xc820108f88
created by github.com/blevesearch/bleve.TestBatchCrashBug195
    /Users/mschoch/go/src/github.com/blevesearch/bleve/index_race_test.go:59 +0x5bc

goroutine 1 [chan receive]:
testing.RunTests(0x729460, 0x923e40, 0x3a, 0x3a, 0xa78901)
    /Users/mschoch/Documents/research/gosrc/src/testing/testing.go:583 +0x8d2
testing.(*M).Run(0xc82004fef8, 0xd)
    /Users/mschoch/Documents/research/gosrc/src/testing/testing.go:515 +0x81
github.com/blevesearch/bleve.TestMain(0xc82004fef8)
    /Users/mschoch/go/src/github.com/blevesearch/bleve/examples_test.go:30 +0xa8
main.main()
    github.com/blevesearch/bleve/_test/_testmain.go:220 +0x114

goroutine 17 [syscall, locked to thread]:
runtime.goexit()
    /Users/mschoch/Documents/research/gosrc/src/runtime/asm_amd64.s:1998 +0x1

goroutine 5 [select]:
github.com/blevesearch/bleve/index.AnalysisWorker(0xc82005c2a0, 0xc82005c300)
    /Users/mschoch/go/src/github.com/blevesearch/bleve/index/analysis.go:70 +0x14e
created by github.com/blevesearch/bleve/index.NewAnalysisQueue
    /Users/mschoch/go/src/github.com/blevesearch/bleve/index/analysis.go:62 +0xf2

goroutine 6 [select]:
github.com/blevesearch/bleve/index.AnalysisWorker(0xc82005c2a0, 0xc82005c300)
    /Users/mschoch/go/src/github.com/blevesearch/bleve/index/analysis.go:70 +0x14e
created by github.com/blevesearch/bleve/index.NewAnalysisQueue
    /Users/mschoch/go/src/github.com/blevesearch/bleve/index/analysis.go:62 +0xf2

goroutine 7 [select]:
github.com/blevesearch/bleve/index.AnalysisWorker(0xc82005c2a0, 0xc82005c300)
    /Users/mschoch/go/src/github.com/blevesearch/bleve/index/analysis.go:70 +0x14e
created by github.com/blevesearch/bleve/index.NewAnalysisQueue
    /Users/mschoch/go/src/github.com/blevesearch/bleve/index/analysis.go:62 +0xf2

goroutine 8 [select]:
github.com/blevesearch/bleve/index.AnalysisWorker(0xc82005c2a0, 0xc82005c300)
    /Users/mschoch/go/src/github.com/blevesearch/bleve/index/analysis.go:70 +0x14e
created by github.com/blevesearch/bleve/index.NewAnalysisQueue
    /Users/mschoch/go/src/github.com/blevesearch/bleve/index/analysis.go:62 +0xf2

goroutine 44 [runnable]:
github.com/blevesearch/bleve/document.NewCompositeFieldWithIndexingOptions(0x61fca8, 0x4, 0x1, 0xc820051b78, 0x0, 0x0, 0x943c18, 0x0, 0x0, 0x5, ...)
    /Users/mschoch/go/src/github.com/blevesearch/bleve/document/field_composite.go:38 +0x87
github.com/blevesearch/bleve.(*IndexMapping).mapDocument(0xc820080510, 0xc8201a7f90, 0x49fb80, 0xc8201a4a70, 0x0, 0x0)
    /Users/mschoch/go/src/github.com/blevesearch/bleve/mapping_index.go:426 +0x54e
github.com/blevesearch/bleve.(*Batch).Index(0xc82015a420, 0xc8201a4a50, 0x3, 0x49fb80, 0xc8201a4a70, 0x0, 0x0)
    /Users/mschoch/go/src/github.com/blevesearch/bleve/index.go:38 +0x266
github.com/blevesearch/bleve.TestBatchCrashBug195(0xc820080480)
    /Users/mschoch/go/src/github.com/blevesearch/bleve/index_race_test.go:63 +0x859
testing.tRunner(0xc820080480, 0x923f60)
    /Users/mschoch/Documents/research/gosrc/src/testing/testing.go:473 +0x98
created by testing.RunTests
    /Users/mschoch/Documents/research/gosrc/src/testing/testing.go:582 +0x892

goroutine 41 [sleep]:
time.Sleep(0x2faf080)
    /Users/mschoch/Documents/research/gosrc/src/runtime/time.go:59 +0xf9
github.com/blevesearch/bleve.TestIndexAliasMultipleLayer.func2(0xc820012d20, 0x0, 0x0)
    /Users/mschoch/go/src/github.com/blevesearch/bleve/index_alias_impl_test.go:1057 +0x2c
github.com/blevesearch/bleve.(*stubIndex).SearchInContext(0xc8200e0500, 0xf00030, 0xc820104660, 0xc820012d20, 0xc8200f219c, 0x0, 0x0)
    /Users/mschoch/go/src/github.com/blevesearch/bleve/index_alias_impl_test.go:1191 +0x45
github.com/blevesearch/bleve.wrapSearch(0xf00030, 0xc820104660, 0xa78a58, 0xc8200e0500, 0xc820012d20, 0x729a18)
    /Users/mschoch/go/src/github.com/blevesearch/bleve/index_alias_impl.go:489 +0xfa
github.com/blevesearch/bleve.wrapSearchTimeout.func1(0xc82005c8a0, 0xf00030, 0xc820104660, 0xa78a58, 0xc8200e0500, 0xc820012d20)
    /Users/mschoch/go/src/github.com/blevesearch/bleve/index_alias_impl.go:495 +0x49
created by github.com/blevesearch/bleve.wrapSearchTimeout
    /Users/mschoch/go/src/github.com/blevesearch/bleve/index_alias_impl.go:495 +0xa3

goroutine 32 [chan send]:
github.com/blevesearch/bleve.wrapSearchTimeout.func1(0xc8200e4480, 0xf00030, 0xc8200e43c0, 0xa78a58, 0xc8200e0200, 0xc8200fe4b0)
    /Users/mschoch/go/src/github.com/blevesearch/bleve/index_alias_impl.go:495 +0x77
created by github.com/blevesearch/bleve.wrapSearchTimeout
    /Users/mschoch/go/src/github.com/blevesearch/bleve/index_alias_impl.go:495 +0xa3

goroutine 97 [sleep]:
time.Sleep(0x2faf080)
    /Users/mschoch/Documents/research/gosrc/src/runtime/time.go:59 +0xf9
github.com/blevesearch/bleve.TestIndexAliasMultipleLayer.func1(0xc8200feaf0, 0x0, 0x0)
    /Users/mschoch/go/src/github.com/blevesearch/bleve/index_alias_impl_test.go:1033 +0x2c
github.com/blevesearch/bleve.(*stubIndex).SearchInContext(0xc8200e04c0, 0xf00030, 0xc820104660, 0xc8200feaf0, 0x180001, 0x0, 0x0)
    /Users/mschoch/go/src/github.com/blevesearch/bleve/index_alias_impl_test.go:1191 +0x45
github.com/blevesearch/bleve.wrapSearch(0xf00030, 0xc820104660, 0xa78a58, 0xc8200e04c0, 0xc8200feaf0, 0x729a18)
    /Users/mschoch/go/src/github.com/blevesearch/bleve/index_alias_impl.go:489 +0xfa
github.com/blevesearch/bleve.wrapSearchTimeout.func1(0xc8200e49c0, 0xf00030, 0xc820104660, 0xa78a58, 0xc8200e04c0, 0xc8200feaf0)
    /Users/mschoch/go/src/github.com/blevesearch/bleve/index_alias_impl.go:495 +0x49
created by github.com/blevesearch/bleve.wrapSearchTimeout
    /Users/mschoch/go/src/github.com/blevesearch/bleve/index_alias_impl.go:495 +0xa3

goroutine 37 [chan send]:
github.com/blevesearch/bleve.wrapSearchTimeout.func1(0xc82005c7e0, 0xf00030, 0xc8200e47e0, 0xa78a58, 0xc8200c8500, 0xc8200fea50)
    /Users/mschoch/go/src/github.com/blevesearch/bleve/index_alias_impl.go:495 +0x77
created by github.com/blevesearch/bleve.wrapSearchTimeout
    /Users/mschoch/go/src/github.com/blevesearch/bleve/index_alias_impl.go:495 +0xa3

goroutine 33 [chan send]:
github.com/blevesearch/bleve.wrapSearchTimeout.func1(0xc8200e44e0, 0xf00030, 0xc8200e43c0, 0xa78a58, 0xc8200e0240, 0xc8200fe500)
    /Users/mschoch/go/src/github.com/blevesearch/bleve/index_alias_impl.go:495 +0x77
created by github.com/blevesearch/bleve.wrapSearchTimeout
    /Users/mschoch/go/src/github.com/blevesearch/bleve/index_alias_impl.go:495 +0xa3

goroutine 86 [chan send]:
github.com/blevesearch/bleve.wrapSearchTimeout.func1(0xc8200e46c0, 0xf00030, 0xc8200e45a0, 0xa78a58, 0xc8200e0240, 0xc8200fe5f0)
    /Users/mschoch/go/src/github.com/blevesearch/bleve/index_alias_impl.go:495 +0x77
created by github.com/blevesearch/bleve.wrapSearchTimeout
    /Users/mschoch/go/src/github.com/blevesearch/bleve/index_alias_impl.go:495 +0xa3

goroutine 85 [chan send]:
github.com/blevesearch/bleve.wrapSearchTimeout.func1(0xc8200e4660, 0xf00030, 0xc8200e45a0, 0xa78a58, 0xc8200e0200, 0xc8200fe5a0)
    /Users/mschoch/go/src/github.com/blevesearch/bleve/index_alias_impl.go:495 +0x77
created by github.com/blevesearch/bleve.wrapSearchTimeout
    /Users/mschoch/go/src/github.com/blevesearch/bleve/index_alias_impl.go:495 +0xa3
FAIL    github.com/blevesearch/bleve    0.137s
@mschoch
Copy link
Contributor Author

mschoch commented Mar 20, 2016

Ah, this appears to now be a duplicate of #260.

We need to clean this up, even if there is some performance hit.

mschoch added a commit to mschoch/bleve that referenced this issue Mar 20, 2016
Currently bleve batch is build by user goroutine
Then read by bleve gourinte
This is still safe when used correctly
However, Reset() will modify the map, which is now a data race

This fix is to simply make batch.Reset() alloc new maps.
This provides a data-access pattern that can be used safely.
Also, this thread argues that creating a new map may be faster
than trying to reuse an existing one:

https://groups.google.com/d/msg/golang-nuts/UvUm3LA1u8g/jGv_FobNpN0J

Separate but related, I have opted to remove the "unsafe batch"
checking that we did.  This was always limited anyway, and now
users of Go 1.6 are just as likely to get a panic from the
runtime for concurrent map access anyway.  So, the price paid
by us (additional mutex) is not worth it.

fixes blevesearch#360 and blevesearch#260
@mschoch mschoch closed this as completed in b8a2fbb Apr 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant