From d33559a5431265432826756fd47e876ab1cb8b9a Mon Sep 17 00:00:00 2001 From: wxing1292 Date: Mon, 10 Oct 2022 22:45:37 -0500 Subject: [PATCH] Properly handle min task ID > max task ID case during shard re-balancing (#3470) * Properly handle min task ID > max task ID case by return unavailable error during shard re-balancing --- service/history/replication/ack_manager.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/service/history/replication/ack_manager.go b/service/history/replication/ack_manager.go index 9c40ec4a0e0..9d16a617a20 100644 --- a/service/history/replication/ack_manager.go +++ b/service/history/replication/ack_manager.go @@ -267,7 +267,9 @@ func (p *ackMgrImpl) getTasks( batchSize int, ) ([]*replicationspb.ReplicationTask, int64, error) { - if minTaskID == maxTaskID { + if minTaskID > maxTaskID { + return nil, 0, serviceerror.NewUnavailable("min task ID < max task ID, probably due to shard re-balancing") + } else if minTaskID == maxTaskID { return []*replicationspb.ReplicationTask{}, maxTaskID, nil }