Signed-off-by: yefu.chen <yefu.chen@zilliz.com>
pull/6522/head
neza2017 2021-07-14 17:11:54 +08:00 committed by GitHub
parent 7f99d9d714
commit fac350cc58
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 2 deletions

View File

@ -48,8 +48,8 @@ func (gia *GlobalIDAllocator) Alloc(count uint32) (typeutil.UniqueID, typeutil.U
if err != nil {
return 0, 0, err
}
idStart := typeutil.UniqueID(timestamp)
idEnd := idStart + int64(count)
idEnd := typeutil.UniqueID(timestamp) + 1
idStart := idEnd - int64(count)
return idStart, idEnd, nil
}

View File

@ -49,4 +49,16 @@ func TestGlobalTSOAllocator_All(t *testing.T) {
assert.Nil(t, err)
assert.Equal(t, count, uint32(idEnd-idStart))
})
t.Run("Alloc2", func(t *testing.T) {
count1 := uint32(2 << 18)
id1, err := gTestIDAllocator.allocator.GenerateTSO(count1)
assert.Nil(t, err)
count2 := uint32(2 << 8)
id2, err := gTestIDAllocator.allocator.GenerateTSO(count2)
assert.Nil(t, err)
assert.Equal(t, id2-id1, uint64(count2))
})
}

View File

@ -1750,6 +1750,9 @@ func (c *Core) AllocTimestamp(ctx context.Context, in *rootcoordpb.AllocTimestam
}, nil
}
// log.Printf("AllocTimestamp : %d", ts)
//return first available time stamp
ts = ts - uint64(in.Count) + 1
return &rootcoordpb.AllocTimestampResponse{
Status: &commonpb.Status{
ErrorCode: commonpb.ErrorCode_Success,

View File

@ -60,6 +60,9 @@ func executeTask(t reqTask) error {
case <-t.Ctx().Done():
return fmt.Errorf("context canceled")
case err := <-errChan:
if t.Core().ctx.Err() != nil || t.Ctx().Err() != nil {
return fmt.Errorf("context canceled")
}
return err
}
}