mirror of https://github.com/milvus-io/milvus.git
Generate unique id with ts for sync task (#20928)
Signed-off-by: Congqi Xia <congqi.xia@zilliz.com> Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>pull/20914/head
parent
f745d7f489
commit
40abb13413
|
@ -124,7 +124,7 @@ func (q *orderFlushQueue) init() {
|
|||
}
|
||||
|
||||
func (q *orderFlushQueue) getFlushTaskRunner(pos *internalpb.MsgPosition) *flushTaskRunner {
|
||||
actual, loaded := q.working.LoadOrStore(string(pos.GetMsgID()), newFlushTaskRunner(q.segmentID, q.injectCh))
|
||||
actual, loaded := q.working.LoadOrStore(getSyncTaskID(pos), newFlushTaskRunner(q.segmentID, q.injectCh))
|
||||
t := actual.(*flushTaskRunner)
|
||||
// not loaded means the task runner is new, do initializtion
|
||||
if !loaded {
|
||||
|
@ -316,7 +316,7 @@ func (m *rendezvousFlushManager) handleDeleteTask(segmentID UniqueID, task flush
|
|||
if m.dropping.Load() {
|
||||
// preventing separate delete, check position exists in queue first
|
||||
q := m.getFlushQueue(segmentID)
|
||||
_, ok := q.working.Load(string(pos.MsgID))
|
||||
_, ok := q.working.Load(getSyncTaskID(pos))
|
||||
// if ok, means position insert data already in queue, just handle task in normal mode
|
||||
// if not ok, means the insert buf should be handle in drop mode
|
||||
if !ok {
|
||||
|
@ -550,6 +550,11 @@ func (m *rendezvousFlushManager) notifyAllFlushed() {
|
|||
close(m.dropHandler.allFlushed)
|
||||
}
|
||||
|
||||
func getSyncTaskID(pos *internalpb.MsgPosition) string {
|
||||
// use msgID & timestamp to generate unique taskID, see also #20926
|
||||
return fmt.Sprintf("%s%d", string(pos.GetMsgID()), pos.GetTimestamp())
|
||||
}
|
||||
|
||||
// close cleans up all the left members
|
||||
func (m *rendezvousFlushManager) close() {
|
||||
m.dispatcher.Range(func(k, v interface{}) bool {
|
||||
|
|
|
@ -424,11 +424,12 @@ func TestRendezvousFlushManager_dropMode(t *testing.T) {
|
|||
for i := 1; i < 11; i++ {
|
||||
target[int64(i)] = struct{}{}
|
||||
m.flushBufferData(nil, int64(i), true, false, &internalpb.MsgPosition{
|
||||
MsgID: []byte{1},
|
||||
MsgID: []byte{byte(i)},
|
||||
})
|
||||
m.flushDelData(nil, int64(i), &internalpb.MsgPosition{
|
||||
MsgID: []byte{1},
|
||||
MsgID: []byte{byte(i)},
|
||||
})
|
||||
t.Log(i)
|
||||
}
|
||||
|
||||
m.notifyAllFlushed()
|
||||
|
@ -485,10 +486,10 @@ func TestRendezvousFlushManager_dropMode(t *testing.T) {
|
|||
|
||||
for i := 1; i < 11; i++ {
|
||||
m.flushBufferData(nil, int64(i), true, false, &internalpb.MsgPosition{
|
||||
MsgID: []byte{1},
|
||||
MsgID: []byte{byte(i)},
|
||||
})
|
||||
m.flushDelData(nil, int64(i), &internalpb.MsgPosition{
|
||||
MsgID: []byte{1},
|
||||
MsgID: []byte{byte(i)},
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue