From 3bbbf3cd959cea4aef1f1607f900e9f3387b503c Mon Sep 17 00:00:00 2001 From: SimFG Date: Tue, 19 Nov 2024 15:50:32 +0800 Subject: [PATCH] enhance: improve the lock key of the create/drop collection task (#37759) /kind improvement Signed-off-by: SimFG --- internal/http/static/index.html | 2 +- internal/rootcoord/create_collection_task.go | 3 ++- internal/rootcoord/drop_collection_task.go | 6 +++++- internal/rootcoord/task_test.go | 4 ++-- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/internal/http/static/index.html b/internal/http/static/index.html index 0a12f181e6..246f8970db 100644 --- a/internal/http/static/index.html +++ b/internal/http/static/index.html @@ -157,7 +157,7 @@ Currently, the objects injected by expr include: param, proxy if (xhr.status === 200) { document.getElementById('resultText').textContent = JSON.stringify(JSON.parse(xhr.responseText), null, 2); } else { - document.getElementById('resultText').textContent = 'Error: ' + xhr.status; + document.getElementById('resultText').textContent = `Error: ${xhr.status}, detail: ${xhr.responseText}`; } }; xhr.send(); diff --git a/internal/rootcoord/create_collection_task.go b/internal/rootcoord/create_collection_task.go index 511adbbc66..a8546b7f07 100644 --- a/internal/rootcoord/create_collection_task.go +++ b/internal/rootcoord/create_collection_task.go @@ -664,6 +664,7 @@ func (t *createCollectionTask) Execute(ctx context.Context) error { func (t *createCollectionTask) GetLockerKey() LockerKey { return NewLockerKeyChain( NewClusterLockerKey(false), - NewDatabaseLockerKey(t.Req.GetDbName(), true), + NewDatabaseLockerKey(t.Req.GetDbName(), false), + NewCollectionLockerKey(t.Req.GetCollectionName(), true), ) } diff --git a/internal/rootcoord/drop_collection_task.go b/internal/rootcoord/drop_collection_task.go index 4d443a1ad3..85ef30126c 100644 --- a/internal/rootcoord/drop_collection_task.go +++ b/internal/rootcoord/drop_collection_task.go @@ -121,5 +121,9 @@ func (t *dropCollectionTask) Execute(ctx context.Context) error { } func (t *dropCollectionTask) GetLockerKey() LockerKey { - return NewLockerKeyChain(NewClusterLockerKey(false), NewDatabaseLockerKey(t.Req.GetDbName(), true)) + return NewLockerKeyChain( + NewClusterLockerKey(false), + NewDatabaseLockerKey(t.Req.GetDbName(), false), + NewCollectionLockerKey(t.Req.GetCollectionName(), true), + ) } diff --git a/internal/rootcoord/task_test.go b/internal/rootcoord/task_test.go index cf03907d3d..a11262588e 100644 --- a/internal/rootcoord/task_test.go +++ b/internal/rootcoord/task_test.go @@ -147,7 +147,7 @@ func TestGetLockerKey(t *testing.T) { }, } key := tt.GetLockerKey() - assert.Equal(t, GetLockerKeyString(key), "$-0-false|foo-1-true") + assert.Equal(t, GetLockerKeyString(key), "$-0-false|foo-1-false|bar-2-true") }) t.Run("create database task locker key", func(t *testing.T) { tt := &createDatabaseTask{ @@ -233,7 +233,7 @@ func TestGetLockerKey(t *testing.T) { }, } key := tt.GetLockerKey() - assert.Equal(t, GetLockerKeyString(key), "$-0-false|foo-1-true") + assert.Equal(t, GetLockerKeyString(key), "$-0-false|foo-1-false|bar-2-true") }) t.Run("drop database task locker key", func(t *testing.T) { tt := &dropDatabaseTask{