fix: [2.4]DeleteData merge wrong data casuing data loss (#33821)

See also: #33819
pr: #33820

Signed-off-by: yangxuan <xuan.yang@zilliz.com>
This commit is contained in:
XuanYang-cn 2024-06-13 16:07:56 +08:00 committed by GitHub
parent c9fa167a38
commit a446e754b4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 3 deletions

View File

@ -945,8 +945,8 @@ func (data *DeleteData) AppendBatch(pks []PrimaryKey, tss []Timestamp) {
}
func (data *DeleteData) Merge(other *DeleteData) {
data.Pks = append(other.Pks, other.Pks...)
data.Tss = append(other.Tss, other.Tss...)
data.Pks = append(data.Pks, other.Pks...)
data.Tss = append(data.Tss, other.Tss...)
data.RowCount += other.RowCount
data.memSize += other.Size()

View File

@ -878,9 +878,12 @@ func TestDeleteData(t *testing.T) {
pks, err := GenInt64PrimaryKeys(1, 2, 3)
require.NoError(t, err)
pks2, err := GenInt64PrimaryKeys(4, 5, 6)
require.NoError(t, err)
t.Run("merge", func(t *testing.T) {
first := NewDeleteData(pks, []Timestamp{100, 101, 102})
second := NewDeleteData(pks, []Timestamp{100, 101, 102})
second := NewDeleteData(pks2, []Timestamp{103, 104, 105})
require.EqualValues(t, first.RowCount, second.RowCount)
require.EqualValues(t, first.Size(), second.Size())
require.EqualValues(t, 3, first.RowCount)
@ -891,6 +894,8 @@ func TestDeleteData(t *testing.T) {
assert.Equal(t, len(first.Tss), 6)
assert.EqualValues(t, first.RowCount, 6)
assert.EqualValues(t, first.Size(), 144)
assert.ElementsMatch(t, first.Pks, append(pks, pks2...))
assert.ElementsMatch(t, first.Tss, []Timestamp{100, 101, 102, 103, 104, 105})
assert.NotNil(t, second)
assert.EqualValues(t, 0, second.RowCount)