-
Notifications
You must be signed in to change notification settings - Fork 239
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
Fundamental flaw in bulk indexer? #186
Comments
this is quite possible. This code needs some love. If you have some proposals, I'm open to helping. |
My personal opinion is that it's trying to be a little too "asynchronous". We've moved to a simpler system that has a synchronous interface for any single "batch" of entities, (which is what we were trying to use the BulkIndexer for), whereas the BulkIndexer feels like it's designed to be more of a long running process. We communicate via a Obviously this was domain specific to our code, since we knew how to parse our entities into bulk indexer compatible documents, but I wouldn't imagine this would be too hard to replicate as |
The bulkIndexer has a lot of issues, a simpler bulkIndexer would be appreciated. The current one does not allow the client to deal with errors. It's also very likely to drop data on shutdown of an app since you don't know if something was indexed or not. |
Yes, I've been trying to track down errors in the bulk indexer and it's really difficult. Also, there seems to be a memory leak in NewBulkIndexerErrors. If an update or index operation fails and it retries then it seems to leak memory. |
the background go routine stuff really doesn't belong in the library in my opinion. The library should give you a simple bulk api that the caller can wrap in a goroutine if they want to make it async. |
@vrecan @kristen1980 how about setting a custom Sender function attribute on the BulkIndexer, is that not a good way to deal with errors? what kind of errors are you talking about that can't be caught this way? |
Hrm, it's possible. This was over a year ago so I've really got no memory of the whole situation. Sorry! |
We've been trying to track down some issues where there are holes in our imported data, yet no errors coming through. I think I've identified a race condition where the last documents may never be flushed to Elasticsearch.
In startHttpSender, we wait on both the
b.sendBuf
andb.httpDoneChan
inside a select loop. If we receive onhttpDoneChan
we return, and the goroutine finishes. During theStop
process, we first push the last docs, if there are any, ontosendBuf
and then send true onhttpDoneChan
.Go promises to process a single channel in a fifo manner, however from our tests this does not hold true for a
select
on multiple channels. I believe that in some cases, thehttpDoneChan
will beat thesendBuf
call, and the goroutine will close,Stop
will return, andsendBuf
will be left with data in it, never to be received on. This is more likely to happen, I imagine, if thesendBuf
part of theselect
statement is still processing at the moment that theStop
method is called, since neither channel will be ready to receive on immediately, and then the race occurs.Here's some sample code that shows how the ordering of input to the channels does not matter when selecting on them, and also showing that this can't be solved by closing the channels either :(. The playground link doesn't show the close issue, but testing on a live machine will show the
count
output varies.http://play.golang.org/p/a0RbfN8uQ8
The text was updated successfully, but these errors were encountered: