From 5447216480efefe7eb8dbef4fe335f421acfda56 Mon Sep 17 00:00:00 2001 From: cmasone-attic Date: Thu, 5 Jan 2017 13:33:08 -0800 Subject: [PATCH] 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 --- go/datas/http_batch_store.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/go/datas/http_batch_store.go b/go/datas/http_batch_store.go index b7897c4d5a..99589c6dd9 100644 --- a/go/datas/http_batch_store.go +++ b/go/datas/http_batch_store.go @@ -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