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

"panic: send on closed channel" during indexing #195

Closed
otoolep opened this issue Apr 27, 2015 · 25 comments
Closed

"panic: send on closed channel" during indexing #195

otoolep opened this issue Apr 27, 2015 · 25 comments
Labels

Comments

@otoolep
Copy link

otoolep commented Apr 27, 2015

While running tests described at http://www.philipotoole.com/increasing-bleve-performance-sharding/ I hit the panic below 3 times.

panic: send on closed channel

goroutine 7 [running]:
github.com/blevesearch/bleve/index/upside_down.AnalysisWorker(0xc208052000, 0xc208052060)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/index/upside_down/analysis_pool.go:116 +0x17cd
created by github.com/blevesearch/bleve/index/upside_down.NewAnalysisQueue
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/index/upside_down/analysis_pool.go:46 +0xd5

goroutine 1 [semacquire]:
sync.(*WaitGroup).Wait(0xc20a6b4020)
        /usr/local/go/src/sync/waitgroup.go:132 +0x169
github.com/otoolep/bleve-bench.(*Indexer).Index(0xc20802cf40, 0xc2080f0000, 0x186a0, 0x186a0, 0x0, 0x0)
        /home/philip/repos/bleve-bench/src/github.com/otoolep/bleve-bench/bleve_indexer.go:104 +0x287
main.main()
        /home/philip/repos/bleve-bench/src/github.com/otoolep/bleve-bench/cmd/bench/main.go:61 +0xbf5

goroutine 5 [chan send]:
github.com/blevesearch/bleve/index/upside_down.AnalysisWorker(0xc208052000, 0xc208052060)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/index/upside_down/analysis_pool.go:116 +0x17cd
created by github.com/blevesearch/bleve/index/upside_down.NewAnalysisQueue
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/index/upside_down/analysis_pool.go:46 +0xd5

goroutine 6 [chan send]:
github.com/blevesearch/bleve/index/upside_down.AnalysisWorker(0xc208052000, 0xc208052060)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/index/upside_down/analysis_pool.go:116 +0x17cd
created by github.com/blevesearch/bleve/index/upside_down.NewAnalysisQueue
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/index/upside_down/analysis_pool.go:46 +0xd5

goroutine 8 [chan send]:
github.com/blevesearch/bleve/index/upside_down.AnalysisWorker(0xc208052000, 0xc208052060)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/index/upside_down/analysis_pool.go:116 +0x17cd
created by github.com/blevesearch/bleve/index/upside_down.NewAnalysisQueue
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/index/upside_down/analysis_pool.go:46 +0xd5

goroutine 9 [runnable]:
github.com/blevesearch/bleve.(*DocumentMapping).walkDocument(0xc20802cf80, 0x7c3e20, 0xc20801f920, 0xc20b1d8770, 0x1, 0x1, 0xc2f5d0, 0x0, 0x0, 0xc20d651ad0)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/mapping_document.go:290 +0x282
github.com/blevesearch/bleve.(*DocumentMapping).processProperty(0xc20802cf80, 0x7c3e20, 0xc20801f920, 0xc20b1d8770, 0x1, 0x1, 0xc2f5d0, 0x0, 0x0, 0xc20d651ad0)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/mapping_document.go:372 +0xbd5
github.com/blevesearch/bleve.(*DocumentMapping).walkDocument(0xc20802cf80, 0x7e6920, 0xc20801f920, 0xc20e83fc68, 0x0, 0x0, 0xc2f5d0, 0x0, 0x0, 0xc20d651ad0)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/mapping_document.go:283 +0xc86
github.com/blevesearch/bleve.(*IndexMapping).mapDocument(0xc20a45b500, 0xc20e317c40, 0x7e6920, 0xc20801f920, 0x0, 0x0)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/mapping_index.go:351 +0x4ab
github.com/blevesearch/bleve.(*Batch).Index(0xc20e8be000, 0xc20b1d8750, 0x4, 0x7e6920, 0xc20801f920, 0x0, 0x0)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/index.go:31 +0x218
github.com/otoolep/bleve-bench.func·001(0x7fda41852698, 0xc20a459ce0, 0xc2080f0000, 0x1388, 0x186a0)
        /home/philip/repos/bleve-bench/src/github.com/otoolep/bleve-bench/bleve_indexer.go:73 +0x1b0
created by github.com/otoolep/bleve-bench.(*Indexer).Index
        /home/philip/repos/bleve-bench/src/github.com/otoolep/bleve-bench/bleve_indexer.go:100 +0x246

goroutine 10 [chan receive]:
github.com/blevesearch/bleve/index/upside_down.(*UpsideDownCouch).Batch(0xc208031220, 0xc20d7062a0, 0x0, 0x0)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/index/upside_down/upside_down.go:602 +0x308
github.com/blevesearch/bleve.(*indexImpl).Batch(0xc20a4be1c0, 0xc20a83aa00, 0x0, 0x0)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/index_impl.go:304 +0x112
github.com/otoolep/bleve-bench.func·001(0x7fda41852698, 0xc20a4be1c0, 0xc20810d4c0, 0x1388, 0x17318)
        /home/philip/repos/bleve-bench/src/github.com/otoolep/bleve-bench/bleve_indexer.go:78 +0x39e
created by github.com/otoolep/bleve-bench.(*Indexer).Index
        /home/philip/repos/bleve-bench/src/github.com/otoolep/bleve-bench/bleve_indexer.go:100 +0x246

goroutine 11 [runnable]:
github.com/blevesearch/bleve/index/upside_down.(*UpsideDownCouch).Batch(0xc208031810, 0xc20d23bf00, 0x0, 0x0)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/index/upside_down/upside_down.go:602 +0x308
github.com/blevesearch/bleve.(*indexImpl).Batch(0xc20a4be460, 0xc20ca92a80, 0x0, 0x0)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/index_impl.go:304 +0x112
github.com/otoolep/bleve-bench.func·001(0x7fda41852698, 0xc20a4be460, 0xc20812a980, 0x1388, 0x15f90)
        /home/philip/repos/bleve-bench/src/github.com/otoolep/bleve-bench/bleve_indexer.go:78 +0x39e
created by github.com/otoolep/bleve-bench.(*Indexer).Index
        /home/philip/repos/bleve-bench/src/github.com/otoolep/bleve-bench/bleve_indexer.go:100 +0x246

goroutine 12 [runnable]:
strings.genSplit(0x952520, 0x1, 0x950820, 0x1, 0x0, 0x1, 0x0, 0x0, 0x0)
        /usr/local/go/src/strings/strings.go:287 +0x14d
strings.Split(0x952520, 0x1, 0x950820, 0x1, 0x0, 0x0, 0x0)
        /usr/local/go/src/strings/strings.go:325 +0x76
github.com/blevesearch/bleve.decodePath(0x952520, 0x1, 0x0, 0x0, 0x0)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/reflect.go:56 +0x60
github.com/blevesearch/bleve.(*DocumentMapping).documentMappingForPath(0xc20a4cec00, 0x952520, 0x1, 0x952520)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/mapping_document.go:110 +0x43
github.com/blevesearch/bleve.(*DocumentMapping).processProperty(0xc20a4cec00, 0x7d4880, 0xc20af97c38, 0xc20af97c40, 0x1, 0x1, 0xc20af97c60, 0x1, 0x1, 0xc20b45ec30)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/mapping_document.go:304 +0x85
github.com/blevesearch/bleve.(*DocumentMapping).walkDocument(0xc20a4cec00, 0x7c3e20, 0xc20baa9160, 0xc20af97c40, 0x1, 0x1, 0xc2f5d0, 0x0, 0x0, 0xc20b45ec30)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/mapping_document.go:290 +0x344
github.com/blevesearch/bleve.(*DocumentMapping).processProperty(0xc20a4cec00, 0x7c3e20, 0xc20baa9160, 0xc20af97c40, 0x1, 0x1, 0xc2f5d0, 0x0, 0x0, 0xc20b45ec30)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/mapping_document.go:372 +0xbd5
github.com/blevesearch/bleve.(*DocumentMapping).walkDocument(0xc20a4cec00, 0x7e6920, 0xc20baa9160, 0xc20c45bc68, 0x0, 0x0, 0xc2f5d0, 0x0, 0x0, 0xc20b45ec30)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/mapping_document.go:283 +0xc86
github.com/blevesearch/bleve.(*IndexMapping).mapDocument(0xc20a45b800, 0xc20b2a3bc0, 0x7e6920, 0xc20baa9160, 0x0, 0x0)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/mapping_index.go:351 +0x4ab
github.com/blevesearch/bleve.(*Batch).Index(0xc20ca74020, 0xc20af97bf8, 0x4, 0x7e6920, 0xc20baa9160, 0x0, 0x0)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/index.go:31 +0x218
github.com/otoolep/bleve-bench.func·001(0x7fda41852698, 0xc20a4be700, 0xc208147e40, 0x1388, 0x14c08)
        /home/philip/repos/bleve-bench/src/github.com/otoolep/bleve-bench/bleve_indexer.go:73 +0x1b0
created by github.com/otoolep/bleve-bench.(*Indexer).Index
        /home/philip/repos/bleve-bench/src/github.com/otoolep/bleve-bench/bleve_indexer.go:100 +0x246

goroutine 13 [runnable]:
github.com/blevesearch/bleve.(*DocumentMapping).documentMappingForPath(0xc20a4cf540, 0x952520, 0x1, 0x952520)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/mapping_document.go:114 +0x2d5
github.com/blevesearch/bleve.(*DocumentMapping).processProperty(0xc20a4cf540, 0x7d4880, 0xc20af842c8, 0xc20af98a00, 0x1, 0x1, 0xc20af842e0, 0x1, 0x1, 0xc20b203d10)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/mapping_document.go:304 +0x85
github.com/blevesearch/bleve.(*DocumentMapping).walkDocument(0xc20a4cf540, 0x7c3e20, 0xc20aa92fc0, 0xc20af98a00, 0x1, 0x1, 0xc2f5d0, 0x0, 0x0, 0xc20b203d10)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/mapping_document.go:290 +0x344
github.com/blevesearch/bleve.(*DocumentMapping).processProperty(0xc20a4cf540, 0x7c3e20, 0xc20aa92fc0, 0xc20af98a00, 0x1, 0x1, 0xc2f5d0, 0x0, 0x0, 0xc20b203d10)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/mapping_document.go:372 +0xbd5
github.com/blevesearch/bleve.(*DocumentMapping).walkDocument(0xc20a4cf540, 0x7e6920, 0xc20aa92fc0, 0xc20c459c68, 0x0, 0x0, 0xc2f5d0, 0x0, 0x0, 0xc20b203d10)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/mapping_document.go:283 +0xc86
github.com/blevesearch/bleve.(*IndexMapping).mapDocument(0xc20a45b900, 0xc20de7ea40, 0x7e6920, 0xc20aa92fc0, 0x0, 0x0)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/mapping_index.go:351 +0x4ab
github.com/blevesearch/bleve.(*Batch).Index(0xc20e87e840, 0xc20af989b8, 0x4, 0x7e6920, 0xc20aa92fc0, 0x0, 0x0)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/index.go:31 +0x218
github.com/otoolep/bleve-bench.func·001(0x7fda41852698, 0xc20a4be9a0, 0xc208165300, 0x1388, 0x13880)
        /home/philip/repos/bleve-bench/src/github.com/otoolep/bleve-bench/bleve_indexer.go:73 +0x1b0
created by github.com/otoolep/bleve-bench.(*Indexer).Index
        /home/philip/repos/bleve-bench/src/github.com/otoolep/bleve-bench/bleve_indexer.go:100 +0x246

goroutine 14 [chan receive]:
github.com/blevesearch/bleve/index/upside_down.(*UpsideDownCouch).Batch(0xc20a50aa00, 0xc20c0d0ef0, 0x0, 0x0)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/index/upside_down/upside_down.go:602 +0x308
github.com/blevesearch/bleve.(*indexImpl).Batch(0xc20a4bec40, 0xc20e8803e0, 0x0, 0x0)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/index_impl.go:304 +0x112
github.com/otoolep/bleve-bench.func·001(0x7fda41852698, 0xc20a4bec40, 0xc2081827c0, 0x1388, 0x124f8)
        /home/philip/repos/bleve-bench/src/github.com/otoolep/bleve-bench/bleve_indexer.go:96 +0x7fe
created by github.com/otoolep/bleve-bench.(*Indexer).Index
        /home/philip/repos/bleve-bench/src/github.com/otoolep/bleve-bench/bleve_indexer.go:100 +0x246

goroutine 15 [runnable]:
reflect.ValueOf(0x7d4880, 0xc20af8ca40, 0x1, 0x0, 0x1)
        /usr/local/go/src/reflect/value.go:2044
github.com/blevesearch/bleve.(*DocumentMapping).processProperty(0xc20a5287c0, 0x7d4880, 0xc20af8ca40, 0xc20af8c550, 0x1, 0x1, 0xc20af8ca48, 0x1, 0x1, 0xc20b3f4510)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/mapping_document.go:311 +0xc7
github.com/blevesearch/bleve.(*DocumentMapping).walkDocument(0xc20a5287c0, 0x7c3e20, 0xc20801fbc0, 0xc20af8c550, 0x1, 0x1, 0xc2f5d0, 0x0, 0x0, 0xc20b3f4510)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/mapping_document.go:290 +0x344
github.com/blevesearch/bleve.(*DocumentMapping).processProperty(0xc20a5287c0, 0x7c3e20, 0xc20801fbc0, 0xc20af8c550, 0x1, 0x1, 0xc2f5d0, 0x0, 0x0, 0xc20b3f4510)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/mapping_document.go:372 +0xbd5
github.com/blevesearch/bleve.(*DocumentMapping).walkDocument(0xc20a5287c0, 0x7e6920, 0xc20801fbc0, 0xc20e841c68, 0x0, 0x0, 0xc2f5d0, 0x0, 0x0, 0xc20b3f4510)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/mapping_document.go:283 +0xc86
github.com/blevesearch/bleve.(*IndexMapping).mapDocument(0xc20a45bb80, 0xc20ac84040, 0x7e6920, 0xc20801fbc0, 0x0, 0x0)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/mapping_index.go:351 +0x4ab
github.com/blevesearch/bleve.(*Batch).Index(0xc20acbefe0, 0xc20af8c530, 0x4, 0x7e6920, 0xc20801fbc0, 0x0, 0x0)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/index.go:31 +0x218
github.com/otoolep/bleve-bench.func·001(0x7fda41852698, 0xc20a4beee0, 0xc20819fc80, 0x1388, 0x11170)
        /home/philip/repos/bleve-bench/src/github.com/otoolep/bleve-bench/bleve_indexer.go:73 +0x1b0
created by github.com/otoolep/bleve-bench.(*Indexer).Index
        /home/philip/repos/bleve-bench/src/github.com/otoolep/bleve-bench/bleve_indexer.go:100 +0x246

goroutine 16 [chan receive]:
github.com/blevesearch/bleve/index/upside_down.(*UpsideDownCouch).Batch(0xc20a50b5e0, 0xc20c7aa740, 0x0, 0x0)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/index/upside_down/upside_down.go:602 +0x308
github.com/blevesearch/bleve.(*indexImpl).Batch(0xc20a4bf180, 0xc20b5ae9e0, 0x0, 0x0)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/index_impl.go:304 +0x112
github.com/otoolep/bleve-bench.func·001(0x7fda41852698, 0xc20a4bf180, 0xc2081bd140, 0x1388, 0xfde8)
        /home/philip/repos/bleve-bench/src/github.com/otoolep/bleve-bench/bleve_indexer.go:78 +0x39e
created by github.com/otoolep/bleve-bench.(*Indexer).Index
        /home/philip/repos/bleve-bench/src/github.com/otoolep/bleve-bench/bleve_indexer.go:100 +0x246

goroutine 17 [runnable]:
github.com/blevesearch/bleve/index/upside_down.(*UpsideDownCouch).Batch(0xc20a50bbd0, 0xc20c67cde0, 0x0, 0x0)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/index/upside_down/upside_down.go:602 +0x308
github.com/blevesearch/bleve.(*indexImpl).Batch(0xc20a4bf420, 0xc20b5afc20, 0x0, 0x0)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/index_impl.go:304 +0x112
github.com/otoolep/bleve-bench.func·001(0x7fda41852698, 0xc20a4bf420, 0xc2081da600, 0x1388, 0xea60)
        /home/philip/repos/bleve-bench/src/github.com/otoolep/bleve-bench/bleve_indexer.go:78 +0x39e
created by github.com/otoolep/bleve-bench.(*Indexer).Index
        /home/philip/repos/bleve-bench/src/github.com/otoolep/bleve-bench/bleve_indexer.go:100 +0x246

goroutine 18 [chan receive]:
github.com/blevesearch/bleve/index/upside_down.(*UpsideDownCouch).Batch(0xc20a5961e0, 0xc20b00ffa0, 0x0, 0x0)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/index/upside_down/upside_down.go:602 +0x308
github.com/blevesearch/bleve.(*indexImpl).Batch(0xc20a4bf6c0, 0xc20d21a8a0, 0x0, 0x0)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/index_impl.go:304 +0x112
github.com/otoolep/bleve-bench.func·001(0x7fda41852698, 0xc20a4bf6c0, 0xc2081f7ac0, 0x1388, 0xd6d8)
        /home/philip/repos/bleve-bench/src/github.com/otoolep/bleve-bench/bleve_indexer.go:78 +0x39e
created by github.com/otoolep/bleve-bench.(*Indexer).Index
        /home/philip/repos/bleve-bench/src/github.com/otoolep/bleve-bench/bleve_indexer.go:100 +0x246

goroutine 19 [runnable]:
github.com/blevesearch/bleve/index/upside_down.(*UpsideDownCouch).Batch(0xc20a5967d0, 0xc20c4d9630, 0x0, 0x0)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/index/upside_down/upside_down.go:602 +0x308
github.com/blevesearch/bleve.(*indexImpl).Batch(0xc20a4bf960, 0xc20c6d7240, 0x0, 0x0)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/index_impl.go:304 +0x112
github.com/otoolep/bleve-bench.func·001(0x7fda41852698, 0xc20a4bf960, 0xc208214f80, 0x1388, 0xc350)
        /home/philip/repos/bleve-bench/src/github.com/otoolep/bleve-bench/bleve_indexer.go:78 +0x39e
created by github.com/otoolep/bleve-bench.(*Indexer).Index
        /home/philip/repos/bleve-bench/src/github.com/otoolep/bleve-bench/bleve_indexer.go:100 +0x246

goroutine 20 [runnable]:
reflect.ValueOf(0x7d4880, 0xc20e918ed0, 0x1, 0x0, 0x1)
        /usr/local/go/src/reflect/value.go:2044
github.com/blevesearch/bleve.(*DocumentMapping).processProperty(0xc20a581600, 0x7d4880, 0xc20e918ed0, 0xc20e918cd0, 0x1, 0x1, 0xc20e918ed8, 0x1, 0x1, 0xc20b4c5080)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/mapping_document.go:311 +0xc7
github.com/blevesearch/bleve.(*DocumentMapping).walkDocument(0xc20a581600, 0x7c3e20, 0xc20c31aec0, 0xc20e918cd0, 0x1, 0x1, 0xc2f5d0, 0x0, 0x0, 0xc20b4c5080)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/mapping_document.go:290 +0x344
github.com/blevesearch/bleve.(*DocumentMapping).processProperty(0xc20a581600, 0x7c3e20, 0xc20c31aec0, 0xc20e918cd0, 0x1, 0x1, 0xc2f5d0, 0x0, 0x0, 0xc20b4c5080)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/mapping_document.go:372 +0xbd5
github.com/blevesearch/bleve.(*DocumentMapping).walkDocument(0xc20a581600, 0x7e6920, 0xc20c31aec0, 0xc20e54bc68, 0x0, 0x0, 0xc2f5d0, 0x0, 0x0, 0xc20b4c5080)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/mapping_document.go:283 +0xc86
github.com/blevesearch/bleve.(*IndexMapping).mapDocument(0xc20a5c2080, 0xc20d2dd9c0, 0x7e6920, 0xc20c31aec0, 0x0, 0x0)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/mapping_index.go:351 +0x4ab
github.com/blevesearch/bleve.(*Batch).Index(0xc20ca6eba0, 0xc20e918cb0, 0x4, 0x7e6920, 0xc20c31aec0, 0x0, 0x0)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/index.go:31 +0x218
github.com/otoolep/bleve-bench.func·001(0x7fda41852698, 0xc20a4bfc00, 0xc208232440, 0x1388, 0xafc8)
        /home/philip/repos/bleve-bench/src/github.com/otoolep/bleve-bench/bleve_indexer.go:73 +0x1b0
created by github.com/otoolep/bleve-bench.(*Indexer).Index
        /home/philip/repos/bleve-bench/src/github.com/otoolep/bleve-bench/bleve_indexer.go:100 +0x246

goroutine 21 [runnable]:
strings.genSplit(0x952520, 0x1, 0x950820, 0x1, 0x0, 0x1, 0x0, 0x0, 0x0)
        /usr/local/go/src/strings/strings.go:287 +0x14d
strings.Split(0x952520, 0x1, 0x950820, 0x1, 0x0, 0x0, 0x0)
        /usr/local/go/src/strings/strings.go:325 +0x76
github.com/blevesearch/bleve.decodePath(0x952520, 0x1, 0x0, 0x0, 0x0)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/reflect.go:56 +0x60
github.com/blevesearch/bleve.(*DocumentMapping).documentMappingForPath(0xc20a581f40, 0x952520, 0x1, 0x952520)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/mapping_document.go:110 +0x43
github.com/blevesearch/bleve.(*DocumentMapping).processProperty(0xc20a581f40, 0x7d4880, 0xc20af93198, 0xc20afa1680, 0x1, 0x1, 0xc20af931b0, 0x1, 0x1, 0xc20ec99f50)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/mapping_document.go:304 +0x85
github.com/blevesearch/bleve.(*DocumentMapping).walkDocument(0xc20a581f40, 0x7c3e20, 0xc20ac11140, 0xc20afa1680, 0x1, 0x1, 0xc2f5d0, 0x0, 0x0, 0xc20ec99f50)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/mapping_document.go:290 +0x344
github.com/blevesearch/bleve.(*DocumentMapping).processProperty(0xc20a581f40, 0x7c3e20, 0xc20ac11140, 0xc20afa1680, 0x1, 0x1, 0xc2f5d0, 0x0, 0x0, 0xc20ec99f50)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/mapping_document.go:372 +0xbd5
github.com/blevesearch/bleve.(*DocumentMapping).walkDocument(0xc20a581f40, 0x7e6920, 0xc20ac11140, 0xc20c457c68, 0x0, 0x0, 0xc2f5d0, 0x0, 0x0, 0xc20ec99f50)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/mapping_document.go:283 +0xc86
github.com/blevesearch/bleve.(*IndexMapping).mapDocument(0xc20a5c2180, 0xc20dc98b40, 0x7e6920, 0xc20ac11140, 0x0, 0x0)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/mapping_index.go:351 +0x4ab
github.com/blevesearch/bleve.(*Batch).Index(0xc20ca74960, 0xc20afa1638, 0x4, 0x7e6920, 0xc20ac11140, 0x0, 0x0)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/index.go:31 +0x218
github.com/otoolep/bleve-bench.func·001(0x7fda41852698, 0xc20a4bfea0, 0xc20824f900, 0x1388, 0x9c40)
        /home/philip/repos/bleve-bench/src/github.com/otoolep/bleve-bench/bleve_indexer.go:73 +0x1b0
created by github.com/otoolep/bleve-bench.(*Indexer).Index
        /home/philip/repos/bleve-bench/src/github.com/otoolep/bleve-bench/bleve_indexer.go:100 +0x246

goroutine 22 [runnable]:
github.com/blevesearch/bleve.(*DocumentMapping).documentMappingForPath(0xc20a5e4880, 0x952520, 0x1, 0x952520)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/mapping_document.go:114 +0x2d5
github.com/blevesearch/bleve.(*DocumentMapping).processProperty(0xc20a5e4880, 0x7d4880, 0xc20f120618, 0xc20e232d50, 0x1, 0x1, 0xc20f120630, 0x1, 0x1, 0xc20b690ea0)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/mapping_document.go:304 +0x85
github.com/blevesearch/bleve.(*DocumentMapping).walkDocument(0xc20a5e4880, 0x7c3e20, 0xc20a4ec920, 0xc20e232d50, 0x1, 0x1, 0xc2f5d0, 0x0, 0x0, 0xc20b690ea0)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/mapping_document.go:290 +0x344
github.com/blevesearch/bleve.(*DocumentMapping).processProperty(0xc20a5e4880, 0x7c3e20, 0xc20a4ec920, 0xc20e232d50, 0x1, 0x1, 0xc2f5d0, 0x0, 0x0, 0xc20b690ea0)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/mapping_document.go:372 +0xbd5
github.com/blevesearch/bleve.(*DocumentMapping).walkDocument(0xc20a5e4880, 0x7e6920, 0xc20a4ec920, 0xc20c0e3c68, 0x0, 0x0, 0xc2f5d0, 0x0, 0x0, 0xc20b690ea0)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/mapping_document.go:283 +0xc86
github.com/blevesearch/bleve.(*IndexMapping).mapDocument(0xc20a5c2280, 0xc20dabf540, 0x7e6920, 0xc20a4ec920, 0x0, 0x0)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/mapping_index.go:351 +0x4ab
github.com/blevesearch/bleve.(*Batch).Index(0xc20ca6fc60, 0xc20e232d08, 0x4, 0x7e6920, 0xc20a4ec920, 0x0, 0x0)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/index.go:31 +0x218
github.com/otoolep/bleve-bench.func·001(0x7fda41852698, 0xc20a5f4150, 0xc20826cdc0, 0x1388, 0x88b8)
        /home/philip/repos/bleve-bench/src/github.com/otoolep/bleve-bench/bleve_indexer.go:73 +0x1b0
created by github.com/otoolep/bleve-bench.(*Indexer).Index
        /home/philip/repos/bleve-bench/src/github.com/otoolep/bleve-bench/bleve_indexer.go:100 +0x246

goroutine 23 [runnable]:
reflect.Value.Type(0x7d4880, 0xc20b196e78, 0x48, 0xc20b196e78, 0x48)
        /usr/local/go/src/reflect/value.go:1630
github.com/blevesearch/bleve.(*DocumentMapping).processProperty(0xc20a5e51c0, 0x7d4880, 0xc20b196e78, 0xc20b1e2430, 0x1, 0x1, 0xc20b196e90, 0x1, 0x1, 0xc20b4c4780)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/mapping_document.go:316 +0x131
github.com/blevesearch/bleve.(*DocumentMapping).walkDocument(0xc20a5e51c0, 0x7c3e20, 0xc20c31acc0, 0xc20b1e2430, 0x1, 0x1, 0xc2f5d0, 0x0, 0x0, 0xc20b4c4780)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/mapping_document.go:290 +0x344
github.com/blevesearch/bleve.(*DocumentMapping).processProperty(0xc20a5e51c0, 0x7c3e20, 0xc20c31acc0, 0xc20b1e2430, 0x1, 0x1, 0xc2f5d0, 0x0, 0x0, 0xc20b4c4780)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/mapping_document.go:372 +0xbd5
github.com/blevesearch/bleve.(*DocumentMapping).walkDocument(0xc20a5e51c0, 0x7e6920, 0xc20c31acc0, 0xc20e747c68, 0x0, 0x0, 0xc2f5d0, 0x0, 0x0, 0xc20b4c4780)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/mapping_document.go:283 +0xc86
github.com/blevesearch/bleve.(*IndexMapping).mapDocument(0xc20a5c2380, 0xc20d2dd5c0, 0x7e6920, 0xc20c31acc0, 0x0, 0x0)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/mapping_index.go:351 +0x4ab
github.com/blevesearch/bleve.(*Batch).Index(0xc20c7ed560, 0xc20b1e23e8, 0x4, 0x7e6920, 0xc20c31acc0, 0x0, 0x0)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/index.go:31 +0x218
github.com/otoolep/bleve-bench.func·001(0x7fda41852698, 0xc20a5f43f0, 0xc20828a280, 0x1388, 0x7530)
        /home/philip/repos/bleve-bench/src/github.com/otoolep/bleve-bench/bleve_indexer.go:73 +0x1b0
created by github.com/otoolep/bleve-bench.(*Indexer).Index
        /home/philip/repos/bleve-bench/src/github.com/otoolep/bleve-bench/bleve_indexer.go:100 +0x246

goroutine 24 [chan receive]:
github.com/blevesearch/bleve/index/upside_down.(*UpsideDownCouch).Batch(0xc20a61e5a0, 0xc20af50400, 0x0, 0x0)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/index/upside_down/upside_down.go:602 +0x308
github.com/blevesearch/bleve.(*indexImpl).Batch(0xc20a5f4690, 0xc20acbef80, 0x0, 0x0)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/index_impl.go:304 +0x112
github.com/otoolep/bleve-bench.func·001(0x7fda41852698, 0xc20a5f4690, 0xc2082a7740, 0x1388, 0x61a8)
        /home/philip/repos/bleve-bench/src/github.com/otoolep/bleve-bench/bleve_indexer.go:78 +0x39e
created by github.com/otoolep/bleve-bench.(*Indexer).Index
        /home/philip/repos/bleve-bench/src/github.com/otoolep/bleve-bench/bleve_indexer.go:100 +0x246

goroutine 25 [runnable]:
strings.genSplit(0x952520, 0x1, 0x950820, 0x1, 0x0, 0x1, 0x0, 0x0, 0x0)
        /usr/local/go/src/strings/strings.go:287 +0x14d
strings.Split(0x952520, 0x1, 0x950820, 0x1, 0x0, 0x0, 0x0)
        /usr/local/go/src/strings/strings.go:325 +0x76
github.com/blevesearch/bleve.decodePath(0x952520, 0x1, 0x0, 0x0, 0x0)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/reflect.go:56 +0x60
github.com/blevesearch/bleve.(*DocumentMapping).documentMappingForPath(0xc20a63c440, 0x952520, 0x1, 0x952520)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/mapping_document.go:110 +0x43
github.com/blevesearch/bleve.(*DocumentMapping).processProperty(0xc20a63c440, 0x7d4880, 0xc20c35f150, 0xc20c35ee40, 0x1, 0x1, 0xc20c35f158, 0x1, 0x1, 0xc20f5519b0)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/mapping_document.go:304 +0x85
github.com/blevesearch/bleve.(*DocumentMapping).walkDocument(0xc20a63c440, 0x7c3e20, 0xc20ca75d20, 0xc20c35ee40, 0x1, 0x1, 0xc2f5d0, 0x0, 0x0, 0xc20f5519b0)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/mapping_document.go:290 +0x344
github.com/blevesearch/bleve.(*DocumentMapping).processProperty(0xc20a63c440, 0x7c3e20, 0xc20ca75d20, 0xc20c35ee40, 0x1, 0x1, 0xc2f5d0, 0x0, 0x0, 0xc20f5519b0)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/mapping_document.go:372 +0xbd5
github.com/blevesearch/bleve.(*DocumentMapping).walkDocument(0xc20a63c440, 0x7e6920, 0xc20ca75d20, 0xc20e83dc68, 0x0, 0x0, 0xc2f5d0, 0x0, 0x0, 0xc20f5519b0)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/mapping_document.go:283 +0xc86
github.com/blevesearch/bleve.(*IndexMapping).mapDocument(0xc20a5c2580, 0xc20e8abac0, 0x7e6920, 0xc20ca75d20, 0x0, 0x0)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/mapping_index.go:351 +0x4ab
github.com/blevesearch/bleve.(*Batch).Index(0xc20ca75020, 0xc20c35ee20, 0x4, 0x7e6920, 0xc20ca75d20, 0x0, 0x0)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/index.go:31 +0x218
github.com/otoolep/bleve-bench.func·001(0x7fda41852698, 0xc20a5f4930, 0xc2082c4c00, 0x1388, 0x4e20)
        /home/philip/repos/bleve-bench/src/github.com/otoolep/bleve-bench/bleve_indexer.go:73 +0x1b0
created by github.com/otoolep/bleve-bench.(*Indexer).Index
        /home/philip/repos/bleve-bench/src/github.com/otoolep/bleve-bench/bleve_indexer.go:100 +0x246

goroutine 26 [runnable]:
github.com/blevesearch/bleve.(*DocumentMapping).walkDocument(0xc20a63cd80, 0x7c3e20, 0xc20bc57620, 0xc20af95200, 0x1, 0x1, 0xc2f5d0, 0x0, 0x0, 0xc20b60dce0)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/mapping_document.go:290 +0x282
github.com/blevesearch/bleve.(*DocumentMapping).processProperty(0xc20a63cd80, 0x7c3e20, 0xc20bc57620, 0xc20af95200, 0x1, 0x1, 0xc2f5d0, 0x0, 0x0, 0xc20b60dce0)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/mapping_document.go:372 +0xbd5
github.com/blevesearch/bleve.(*DocumentMapping).walkDocument(0xc20a63cd80, 0x7e6920, 0xc20bc57620, 0xc20e549c68, 0x0, 0x0, 0xc2f5d0, 0x0, 0x0, 0xc20b60dce0)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/mapping_document.go:283 +0xc86
github.com/blevesearch/bleve.(*IndexMapping).mapDocument(0xc20a5c2680, 0xc20a839e80, 0x7e6920, 0xc20bc57620, 0x0, 0x0)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/mapping_index.go:351 +0x4ab
github.com/blevesearch/bleve.(*Batch).Index(0xc20e88e500, 0xc20af951e0, 0x4, 0x7e6920, 0xc20bc57620, 0x0, 0x0)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/index.go:31 +0x218
github.com/otoolep/bleve-bench.func·001(0x7fda41852698, 0xc20a5f4bd0, 0xc2082e20c0, 0x1388, 0x3a98)
        /home/philip/repos/bleve-bench/src/github.com/otoolep/bleve-bench/bleve_indexer.go:73 +0x1b0
created by github.com/otoolep/bleve-bench.(*Indexer).Index
        /home/philip/repos/bleve-bench/src/github.com/otoolep/bleve-bench/bleve_indexer.go:100 +0x246

goroutine 27 [chan receive]:
github.com/blevesearch/bleve/index/upside_down.(*UpsideDownCouch).Batch(0xc20a61f770, 0xc20b827810, 0x0, 0x0)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/index/upside_down/upside_down.go:602 +0x308
github.com/blevesearch/bleve.(*indexImpl).Batch(0xc20a5f4e70, 0xc20b592d20, 0x0, 0x0)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/index_impl.go:304 +0x112
github.com/otoolep/bleve-bench.func·001(0x7fda41852698, 0xc20a5f4e70, 0xc2082ff580, 0x1388, 0x2710)
        /home/philip/repos/bleve-bench/src/github.com/otoolep/bleve-bench/bleve_indexer.go:78 +0x39e
created by github.com/otoolep/bleve-bench.(*Indexer).Index
        /home/philip/repos/bleve-bench/src/github.com/otoolep/bleve-bench/bleve_indexer.go:100 +0x246

goroutine 28 [chan receive]:
github.com/blevesearch/bleve/index/upside_down.(*UpsideDownCouch).Batch(0xc20a61fd60, 0xc20b505e70, 0x0, 0x0)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/index/upside_down/upside_down.go:602 +0x308
github.com/blevesearch/bleve.(*indexImpl).Batch(0xc20a5f5110, 0xc20ac6baa0, 0x0, 0x0)
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/index_impl.go:304 +0x112
github.com/otoolep/bleve-bench.func·001(0x7fda41852698, 0xc20a5f5110, 0xc20831ca40, 0x1388, 0x1388)
        /home/philip/repos/bleve-bench/src/github.com/otoolep/bleve-bench/bleve_indexer.go:78 +0x39e
created by github.com/otoolep/bleve-bench.(*Indexer).Index
        /home/philip/repos/bleve-bench/src/github.com/otoolep/bleve-bench/bleve_indexer.go:100 +0x246

goroutine 249 [chan send]:
github.com/blevesearch/bleve/index/upside_down.func·019()
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/index/upside_down/upside_down.go:593 +0x13b
created by github.com/blevesearch/bleve/index/upside_down.(*UpsideDownCouch).Batch
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/index/upside_down/upside_down.go:596 +0x28c

goroutine 305 [chan send]:
github.com/blevesearch/bleve/index/upside_down.func·019()
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/index/upside_down/upside_down.go:593 +0x13b
created by github.com/blevesearch/bleve/index/upside_down.(*UpsideDownCouch).Batch
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/index/upside_down/upside_down.go:596 +0x28c

goroutine 277 [runnable]:
github.com/blevesearch/bleve/index/upside_down.func·019()
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/index/upside_down/upside_down.go:593 +0x13b
created by github.com/blevesearch/bleve/index/upside_down.(*UpsideDownCouch).Batch
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/index/upside_down/upside_down.go:596 +0x28c

goroutine 251 [runnable]:
github.com/blevesearch/bleve/index/upside_down.func·019()
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/index/upside_down/upside_down.go:584
created by github.com/blevesearch/bleve/index/upside_down.(*UpsideDownCouch).Batch
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/index/upside_down/upside_down.go:596 +0x28c

goroutine 250 [runnable]:
github.com/blevesearch/bleve/index/upside_down.func·019()
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/index/upside_down/upside_down.go:593 +0x13b
created by github.com/blevesearch/bleve/index/upside_down.(*UpsideDownCouch).Batch
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/index/upside_down/upside_down.go:596 +0x28c

goroutine 276 [chan send]:
github.com/blevesearch/bleve/index/upside_down.func·019()
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/index/upside_down/upside_down.go:593 +0x13b
created by github.com/blevesearch/bleve/index/upside_down.(*UpsideDownCouch).Batch
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/index/upside_down/upside_down.go:596 +0x28c

goroutine 218 [chan send]:
github.com/blevesearch/bleve/index/upside_down.func·019()
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/index/upside_down/upside_down.go:593 +0x13b
created by github.com/blevesearch/bleve/index/upside_down.(*UpsideDownCouch).Batch
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/index/upside_down/upside_down.go:596 +0x28c

goroutine 219 [runnable]:
github.com/blevesearch/bleve/index/upside_down.func·019()
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/index/upside_down/upside_down.go:593 +0x13b
created by github.com/blevesearch/bleve/index/upside_down.(*UpsideDownCouch).Batch
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/index/upside_down/upside_down.go:596 +0x28c

goroutine 206 [runnable]:
github.com/blevesearch/bleve/index/upside_down.func·019()
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/index/upside_down/upside_down.go:593 +0x13b
created by github.com/blevesearch/bleve/index/upside_down.(*UpsideDownCouch).Batch
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/index/upside_down/upside_down.go:596 +0x28c

goroutine 217 [chan send]:
github.com/blevesearch/bleve/index/upside_down.func·019()
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/index/upside_down/upside_down.go:593 +0x13b
created by github.com/blevesearch/bleve/index/upside_down.(*UpsideDownCouch).Batch
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/index/upside_down/upside_down.go:596 +0x28c

goroutine 237 [chan send]:
github.com/blevesearch/bleve/index/upside_down.func·019()
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/index/upside_down/upside_down.go:593 +0x13b
created by github.com/blevesearch/bleve/index/upside_down.(*UpsideDownCouch).Batch
        /home/philip/repos/bleve-bench/src/github.com/blevesearch/bleve/index/upside_down/upside_down.go:596 +0x28c
@mschoch mschoch added the bug label Apr 27, 2015
@mschoch
Copy link
Contributor

mschoch commented Apr 27, 2015

This is definitely a bug, but I'd like to try and reproduce it (the line numbers in the trace don't seem to correspond with the code in your bleve-bench repo)

@mschoch
Copy link
Contributor

mschoch commented Apr 27, 2015

I haven't been able to reproduce it yet, though I may ask @steveyen to help me review the relevant sections of code later today.

Can you let me know which bleve commit you're on, and if possible provide the datasource file you used for testing?

Thanks

@otoolep
Copy link
Author

otoolep commented Apr 27, 2015

Let me see if can reproduce it. I forced-pushed a couple of times last night, that's why the line numbers are off.

@otoolep
Copy link
Author

otoolep commented Apr 30, 2015

I tried a couple more times, but have not managed to reproduce this. Perhaps it was something about the earlier state of my code, but unfortunately I no longer have the code. :-(

@mschoch
Copy link
Contributor

mschoch commented Apr 30, 2015

@steveyen helped me review the code. We did theorize one way it could happen. If you were to add a document to a batch, after you already started executing the batch, there could be a data race between where we compute how many items we expect to read from a result channel, and how many items we actually push onto the work channel.

Obviously your code would not do this by design, but I can see how it could happen during development.

The next question is what should be done to prevent this. Right now Batches are a use-once model, so calls to Index/Delete/SetInternal/DeleteInternal after executing the batch are not correct. Unfortunately, not all these operations return an error today. One option is to modify the signature to return an error. Another option is to have the methods acquire a lock, in this case any calls to modify the batch during execution would block. At first the second option appears like a hack to provide safety, while not letting the user know there is a problem... But, I'd like to consider a future where we can reuse the batches by calling a Reset() method, this could avoid some unnecessary allocations.

@otoolep
Copy link
Author

otoolep commented Apr 30, 2015

Actually, this might make sense. When I first coded this I forgot to ask for a new batch after I started executing the new batch. So I was re-using batch objects. This has been fixed now in my code.

@mschoch
Copy link
Contributor

mschoch commented May 14, 2015

Confirmed I was able to cause the same crash in a test case. Evaluating our options...

@mschoch
Copy link
Contributor

mschoch commented May 15, 2015

To summarize what I put into the commit message. The Batch object was never intended to be thread-safe and this particular panic was actually a manifestation of inadvertently mutating the batch by multiple go-routines at the same time. To address this we have done 2 things:

  1. Documentation more clearly states that Batch is not thread-safe.
  2. The code can detect SOME cases when this is happening. When it does, it avoids a preventable panic and instead returns an error upside_down.UnsafeBatchUseDetected. Users should not rely on this detecting all cases, rather it is designed to be a more helpful way of detecting inadvertent usage than a panic.

@prologic
Copy link

Is this the same as #41 ?

@mschoch
Copy link
Contributor

mschoch commented May 30, 2018

I just posted to the same effect on blevesearch/blevex#41 – The root cause of the panic is the same, but the reason we get into this state is likely different and unique to the automatic index batcher. The pattern bleve uses is to figure out how many items are going to be analyzed, build a channel, pass it to the analysis queue, and read off EXACTLY the expected number of items. We then close and move on. However in this case, another analyzed document was written to the channel AFTER we already closed it. As we observed in this issue, this can happen if you start to execute a batch, and the keep mutating the batch without waiting for the batch execution to finish. I'm not very familiar with the automatic index batcher, so I'm reviewing it now to see if I spot anything.

@prologic
Copy link

Yeah I'm going to have to modify this IndexBatcher a bit. I'm not too familiar with this pattern it implements however. Do you know why we do this whole song 'n dance of blocking the callers up to the period interval? Why not just fill a buffer and write batches up to buffer_size? Or just fill a buffer and empty and batch the contents of the buffered operations very X interval?

@prologic
Copy link

Or in other words; its not clear to me why you'd want to block your callers at all? Certainly in my case I'd rather not to get a higher write throughput.

@mschoch
Copy link
Contributor

mschoch commented May 30, 2018

At Couchbase we do something closer to what you've described. We just build batches of the sizes we like, execute them and recycle them. It's straightforward and works well for us. The user who contributed this wanted to try and hide the batching entirely and just expose a simpler API that didn't do any explicit batching. It sounds like you should just avoid using this automatic batcher.

@prologic
Copy link

So... I'm able to repro this with this very simple naive batching indxer:

package je

import (
	"sync"
	"time"

	log "github.com/sirupsen/logrus"

	"github.com/blevesearch/bleve"
)

type bleveIndex bleve.Index

type IndexBatcher struct {
	sync.Mutex
	bleveIndex

	interval time.Duration
	close    chan bool
	batch    *bleve.Batch
}

func NewIndexBatcher(index bleve.Index, interval time.Duration) bleve.Index {
	ib := &IndexBatcher{
		bleveIndex: index,

		batch:    index.NewBatch(),
		interval: interval,
		close:    make(chan bool),
	}

	go ib.batchloop()
	return ib
}

func (ib *IndexBatcher) batchloop() {
	t := time.NewTicker(ib.interval)

	for {
		select {
		case <-t.C:
			ib.Lock()
			err := ib.Batch(ib.batch)
			if err != nil {
				log.Errorf("error batching: %s", err)
			}
			ib.batch.Reset()
			ib.Unlock()
		case <-ib.close:
			break
		}
	}
}

func (ib *IndexBatcher) Close() error {
	ib.close <- true
	return ib.bleveIndex.Close()
}

func (ib *IndexBatcher) Index(id string, data interface{}) error {
	ib.Lock()
	err := ib.batch.Index(id, data)
	ib.Unlock()

	return err
}

func (ib *IndexBatcher) Delete(id string) error {
	ib.Lock()
	ib.batch.Delete(id)
	ib.Unlock()
	return nil
}

func (ib *IndexBatcher) SetInternal(key, val []byte) error {
	ib.Lock()
	ib.batch.SetInternal(key, val)
	ib.Unlock()
	return nil
}

func (ib *IndexBatcher) DeleteInternal(key []byte) error {
	ib.Lock()
	ib.batch.DeleteInternal(key)
	ib.Unlock()
	return nil
}

Crash:

panic: send on closed channel

goroutine 19 [running]:
github.com/blevesearch/bleve/index.AnalysisWorker(0xc42014e060, 0xc42014e0c0)
	/Users/prologic/go/src/github.com/blevesearch/bleve/index/analysis.go:107 +0x7b
created by github.com/blevesearch/bleve/index.NewAnalysisQueue
	/Users/prologic/go/src/github.com/blevesearch/bleve/index/analysis.go:94 +0xcd

Which is exactly at the same place.

I don't see how if I have a mutex guard around all Batch{...} operations how this is possible?

@prologic
Copy link

prologic commented Jun 1, 2018

Can we please get some more eyes on this and consider reopening? I've crawled through my simple indexer with a fine tooth comb and can't understand where the problem lies.

@mschoch
Copy link
Contributor

mschoch commented Jun 1, 2018

I've added a main function, here is a complete example, but it does not crash for me. Maybe you're configuring the batcher differently, or using it differently, can you take a look?

package main

import (
	"fmt"
	"os"
	"sync"
	"time"

	"log"

	"github.com/blevesearch/bleve"
)

type bleveIndex bleve.Index

type IndexBatcher struct {
	sync.Mutex
	bleveIndex

	interval time.Duration
	close    chan bool
	batch    *bleve.Batch
}

func NewIndexBatcher(index bleve.Index, interval time.Duration) bleve.Index {
	ib := &IndexBatcher{
		bleveIndex: index,

		batch:    index.NewBatch(),
		interval: interval,
		close:    make(chan bool),
	}

	go ib.batchloop()
	return ib
}

func (ib *IndexBatcher) batchloop() {
	t := time.NewTicker(ib.interval)

	for {
		select {
		case <-t.C:
			ib.Lock()
			err := ib.Batch(ib.batch)
			if err != nil {
				log.Printf("error batching: %s", err)
			}
			ib.batch.Reset()
			ib.Unlock()
		case <-ib.close:
			break
		}
	}
}

func (ib *IndexBatcher) Close() error {
	ib.close <- true
	return ib.bleveIndex.Close()
}

func (ib *IndexBatcher) Index(id string, data interface{}) error {
	ib.Lock()
	err := ib.batch.Index(id, data)
	ib.Unlock()

	return err
}

func (ib *IndexBatcher) Delete(id string) error {
	ib.Lock()
	ib.batch.Delete(id)
	ib.Unlock()
	return nil
}

func (ib *IndexBatcher) SetInternal(key, val []byte) error {
	ib.Lock()
	ib.batch.SetInternal(key, val)
	ib.Unlock()
	return nil
}

func (ib *IndexBatcher) DeleteInternal(key []byte) error {
	ib.Lock()
	ib.batch.DeleteInternal(key)
	ib.Unlock()
	return nil
}

func main() {
	os.RemoveAll("/tmp/btest38")

	m := bleve.NewIndexMapping()
	idx, err := bleve.New("/tmp/btest38", m)
	if err != nil {
		log.Fatal(err)
	}

	ib := NewIndexBatcher(idx, 200*time.Millisecond)

	for i := 0; i < 1000; i++ {
		err = ib.Index(fmt.Sprintf("%d", i), map[string]interface{}{
			"name": fmt.Sprintf("%d", i),
			"body": "something",
		})
		if err != nil {
			log.Fatalf("error indexing through batcher: %v", err)
		}
		time.Sleep(10 * time.Millisecond)
	}
	err = ib.Close()
	if err != nil {
		log.Fatalf("error closing batcher: %v", err)
	}

}

@prologic
Copy link

prologic commented Jun 1, 2018

My code is identical. The test-environment is what is different. My conditions are:

  • Put the system under high concurrent load, say with hey -n 1000 -c 10
  • While under load do an index search

This crashes at the same spot quite consistently.

@prologic
Copy link

prologic commented Jun 3, 2018

New find; re-creating the Batch() object instead of calling batch.Reset() makes the crash go away. Not sure why though. The code looks like this (almost verbatim from blevex):

package je

import (
	"fmt"
	"sync"
	"time"

	"github.com/blevesearch/bleve"
)

// NOTE As this approach uses carefully orchestrated interactions
// between a mutex, channels, and reference swapping, be sure to carefully
// consider the impact of reordering statements or making changes to the
// patterns present in the code. Specifically, individual operations follow the
// pattern of:
// - Construct empty references for result error, signal channel
// - Acquire lock
// - Assign references to current result error and signal channel
// - Add operation to batch
// - Release lock
// - Wait on signal channel to close
// - Return result error
// While the batch loop follows the pattern on timer event:
// - Acquire lock
// - Execute batch
// - Store result in current result error
// - Make new current result error for use by operations in the next batch
// - Close signal channel so that operations waiting on the completion of this
//   batch will return the result pointed to by the previous result error that
//   they are still holding.
// - Make new current signal channel for use by operations in the next batch
// - Release lock
// This design minimizes the need for allocating channels, uses only one go
// routine for the batching, and doesn't require tracking the number of
// operations waiting on a response or looping to notify each waiting operation.

// IndexBatcher can be wrapped around a Index to aggregate operations
// in a concurrent / parallel context for increased throughput.
type IndexBatcher struct {
	bleveIndex

	period time.Duration
	closer chan bool

	// lock is used to protect applying / resetting the batch, updating /
	// replacing the result, and signalling / replacing the signal channel from
	// the batch loop.  Elsewhere it is used for getting a reference to the
	// current result, getting a reference to the current signal channel,
	// and adding operations to the batch.
	lock   sync.Mutex
	batch  *bleve.Batch
	result *error
	signal chan bool
}

// NewIndexBatcher returns an index that will aggregate and fire modifying
// requests as a batch every period time. All other Index methods are
// passed straight through to the underlying index. Period time should be
// tuned to the underlying KVStore, the concurrent load, latency requirements,
// and the documents / document mappings being used. Single digit (7~8)
// milliseconds is a reasonable place to start.
func NewIndexBatcher(index bleve.Index, period time.Duration) bleve.Index {
	ib := &IndexBatcher{
		bleveIndex: index,

		batch:  index.NewBatch(),
		period: period,
		closer: make(chan bool),
		signal: make(chan bool),
		result: new(error),
	}

	go ib.batchloop()
	return ib
}

// batchloop processes batches every period and implements a clean close
// operation
func (ib *IndexBatcher) batchloop() {
	t := time.NewTicker(ib.period)

BatchLoop:
	for {
		select {
		case <-t.C:
			ib.lock.Lock()
			func() {
				defer func() {
					if r := recover(); r != nil {
						(*ib.result) = fmt.Errorf("IndexBatcher caught a panic: %v", r)
					}
				}()
				(*ib.result) = ib.Batch(ib.batch)
			}()
			ib.batch = ib.bleveIndex.NewBatch()
			ib.result = new(error)
			close(ib.signal)
			ib.signal = make(chan bool)
			ib.lock.Unlock()
		case <-ib.closer:
			break BatchLoop
		}
	}

	t.Stop()
	(*ib.result) = fmt.Errorf("IndexBatcher has been closed")
	close(ib.signal)
}

// Close stops the batcher returning an error to currently waiting operations
// and closes the underlying Index
func (ib *IndexBatcher) Close() error {
	ib.closer <- true
	return ib.bleveIndex.Close()
}

// Index the object with the specified identifier. May hold the operation for up
// to ib.period time before executing in a batch.
func (ib *IndexBatcher) Index(id string, data interface{}) error {
	var result *error
	var signal chan bool
	ib.lock.Lock()
	result = ib.result
	signal = ib.signal
	err := ib.batch.Index(id, data)
	ib.lock.Unlock()

	if err != nil {
		return err
	}

	<-signal
	return *result
}

// Delete entries for the specified identifier from the index. May hold the
// operation for up to ib.period time before executing in a batch.
func (ib *IndexBatcher) Delete(id string) error {
	var result *error
	var signal chan bool
	ib.lock.Lock()
	result = ib.result
	signal = ib.signal
	ib.batch.Delete(id)
	ib.lock.Unlock()

	<-signal
	return *result
}

// SetInternal mappings directly in the kvstore. May hold the
// operation for up to ib.period time before executing in a batch.
func (ib *IndexBatcher) SetInternal(key, val []byte) error {
	var result *error
	var signal chan bool
	ib.lock.Lock()
	result = ib.result
	signal = ib.signal
	ib.batch.SetInternal(key, val)
	ib.lock.Unlock()

	<-signal
	return *result
}

// DeleteInternal mappings directly from the kvstore. May hold the
// operation for up to ib.period time before executing in a batch.
func (ib *IndexBatcher) DeleteInternal(key []byte) error {
	var result *error
	var signal chan bool
	ib.lock.Lock()
	result = ib.result
	signal = ib.signal
	ib.batch.DeleteInternal(key)
	ib.lock.Unlock()

	<-signal
	return *result
}

@prologic
Copy link

prologic commented Jun 3, 2018

Note the lines:

	ib.batch = ib.bleveIndex.NewBatch()
	ib.result = new(error)

@mschoch
Copy link
Contributor

mschoch commented Jun 3, 2018

I don't think it's new information from my understanding. Our understanding of this crash is as follows:

  1. the number of updates inside a batch is computed here: https://github.com/blevesearch/bleve/blob/master/index/upsidedown/upsidedown.go#L808

  2. an item is put onto the analysis queue for each update here:
    https://github.com/blevesearch/bleve/blob/master/index/upsidedown/upsidedown.go#L818

  3. we read the number of updates computed above in 1, off the of the analysis results channel: https://github.com/blevesearch/bleve/blob/master/index/upsidedown/upsidedown.go#L861

This crash happens when the count computed in 1 and the number of documents written in 2 are not the same. In this original issue, this happened because the user would continue to modify a batch after it had been executed. This is clearly not supported and thus the issue was closed.

In this case, we still don't understand why these counts are different, but this seems to still be the only way we would end up closing the channel prematurely and get the panic. Not resetting batches avoids this entirely, but presumably is unacceptable for other reasons. The question remains, why do we see this problem, even though the locking looks correct and the batch reuse looks to be as intended.

@prologic
Copy link

prologic commented Jun 3, 2018

@mschoch What I don't understand is how this is even remotely possible while all Batch() operations are under a mutex guard/lock? The only way I can think of is that the call to index.Batch(batch) itself takes the batch object and does "asynchronous" operations on it; meanwhile we've done a batch.Reset() and are now adding more documents to the batch while another batch is in progress. Meaning even through we've "reset" the batch object it's actually under use by the Analysis workers.

@prologic
Copy link

prologic commented Jun 3, 2018

If this is what's happening; then my solution is a "hack" but works and the IndexBatcher in blevex is just plain wrong.

@abhinavdangeti
Copy link
Member

@prologic , so I've tried to reproduce this issue a good number of times with the test snippet you shared .. but haven't been able to so far. Also as we've noted earlier - it's not quite obvious from the code why this panic seems to occur only with the "batch.Reset()", as all operations occur while within the lock.
Could you perhaps give more tips on how you've managed to reproduce the issue with your test? I'm not quite familiar with hey, and how you've used it to reproduce the issue..

@prologic
Copy link

prologic commented Jun 11, 2018 via email

@abhinavdangeti
Copy link
Member

At this point, any test case that we can set up and run to reliably reproduce this issue could prove very useful. Cheers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants