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 }