Fix sync bug when all chunks are already present in the sink (#3032)

In the edge case where all source chunks are already present in the
sink AND the sink dataset does not yet exist, the httpBatchStore code
was sending chunks in reverse order.  This patch ensures that,
regardless of how few chunks are sent, any operation that sends chunks
to the server also resets chunk write order.

Fixes #3101
This commit is contained in:
cmasone-attic
2017-01-05 13:33:08 -08:00
committed by GitHub
parent ce5c747a71
commit 5447216480

View File

@@ -356,7 +356,10 @@ func (bhcs *httpBatchStore) sendWriteRequests() {
defer func() { <-bhcs.rateLimit }()
bhcs.cacheMu.Lock()
defer bhcs.cacheMu.Unlock()
defer func() {
bhcs.flushOrder = nbs.InsertOrder // This needs to happen even if no chunks get written.
bhcs.cacheMu.Unlock()
}()
count := bhcs.unwrittenPuts.Count()
if count == 0 {
@@ -366,7 +369,6 @@ func (bhcs *httpBatchStore) sendWriteRequests() {
bhcs.unwrittenPuts.Destroy()
bhcs.unwrittenPuts = nbs.NewCache()
bhcs.hints = types.Hints{}
bhcs.flushOrder = nbs.InsertOrder
}()
var res *http.Response