Skip to content

Commit 471b3e4

Browse files
authored
fix: Move Init and Remove EZ logic out of metatable (#45827)
This will avoid endless retry CreateDatabase/DropDatabase when cipherPlugin fails in the new DDL framework. See also: #45826 --------- Signed-off-by: yangxuan <xuan.yang@zilliz.com>
1 parent 4d6b130 commit 471b3e4

File tree

4 files changed

+18
-12
lines changed

4 files changed

+18
-12
lines changed

internal/rootcoord/create_collection_task.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -494,8 +494,8 @@ func (t *createCollectionTask) Prepare(ctx context.Context) error {
494494
t.Req.Properties = append(properties, timezoneKV)
495495
}
496496

497-
if hookutil.GetEzPropByDBProperties(db.Properties) != nil {
498-
t.Req.Properties = append(t.Req.Properties, hookutil.GetEzPropByDBProperties(db.Properties))
497+
if ezProps := hookutil.GetEzPropByDBProperties(db.Properties); ezProps != nil {
498+
t.Req.Properties = append(t.Req.Properties, ezProps)
499499
}
500500

501501
t.header.DbId = db.ID

internal/rootcoord/ddl_callbacks_create_database.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,16 @@ func (c *Core) broadcastCreateDatabase(ctx context.Context, req *milvuspb.Create
5858
if err != nil {
5959
return errors.Wrap(err, "failed to tidy database cipher properties")
6060
}
61+
6162
tz, exist := funcutil.TryGetAttrByKeyFromRepeatedKV(common.TimezoneKey, properties)
6263
if exist && !timestamptz.IsTimezoneValid(tz) {
6364
return merr.WrapErrParameterInvalidMsg("unknown or invalid IANA Time Zone ID: %s", tz)
6465
}
66+
67+
if err := hookutil.CreateEZByDBProperties(properties); err != nil {
68+
return errors.Wrap(err, "failed to create ez by db properties")
69+
}
70+
6571
msg := message.NewCreateDatabaseMessageBuilderV2().
6672
WithHeader(&message.CreateDatabaseMessageHeader{
6773
DbName: req.GetDbName(),

internal/rootcoord/ddl_callbacks_drop_database.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"github.com/milvus-io/milvus-proto/go-api/v2/commonpb"
2626
"github.com/milvus-io/milvus-proto/go-api/v2/milvuspb"
2727
"github.com/milvus-io/milvus/internal/distributed/streaming"
28+
"github.com/milvus-io/milvus/internal/util/hookutil"
2829
"github.com/milvus-io/milvus/pkg/v2/streaming/util/message"
2930
"github.com/milvus-io/milvus/pkg/v2/streaming/util/message/ce"
3031
"github.com/milvus-io/milvus/pkg/v2/util/typeutil"
@@ -47,6 +48,11 @@ func (c *Core) broadcastDropDatabase(ctx context.Context, req *milvuspb.DropData
4748
return errors.Wrap(err, "failed to get database name")
4849
}
4950

51+
// Call back cipher plugin when dropping database succeeded
52+
if err := hookutil.RemoveEZByDBProperties(db.Properties); err != nil {
53+
return errors.Wrap(err, "failed to remove ez by db properties")
54+
}
55+
5056
msg := message.NewDropDatabaseMessageBuilderV2().
5157
WithHeader(&message.DropDatabaseMessageHeader{
5258
DbName: req.GetDbName(),

internal/rootcoord/meta_table.go

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,10 @@ func (mt *MetaTable) createDefaultDb() error {
341341

342342
cipherProps := hookutil.GetDBCipherProperties(ezID, defaultRootKey)
343343
defaultProperties = append(defaultProperties, cipherProps...)
344+
345+
if err := hookutil.CreateEZByDBProperties(defaultProperties); err != nil {
346+
return err
347+
}
344348
}
345349

346350
return mt.createDatabasePrivate(mt.ctx, model.NewDefaultDatabase(defaultProperties), ts)
@@ -377,12 +381,7 @@ func (mt *MetaTable) CreateDatabase(ctx context.Context, db *model.Database, ts
377381

378382
func (mt *MetaTable) createDatabasePrivate(ctx context.Context, db *model.Database, ts typeutil.Timestamp) error {
379383
dbName := db.Name
380-
if err := hookutil.CreateEZByDBProperties(db.Properties); err != nil {
381-
return err
382-
}
383-
384384
if err := mt.catalog.CreateDatabase(ctx, db, ts); err != nil {
385-
hookutil.RemoveEZByDBProperties(db.Properties) // ignore the error since create database failed
386385
return err
387386
}
388387

@@ -444,11 +443,6 @@ func (mt *MetaTable) DropDatabase(ctx context.Context, dbName string, ts typeuti
444443
return err
445444
}
446445

447-
// Call back cipher plugin when dropping database succeeded
448-
if err := hookutil.RemoveEZByDBProperties(db.Properties); err != nil {
449-
return err
450-
}
451-
452446
mt.names.dropDb(dbName)
453447
mt.aliases.dropDb(dbName)
454448
delete(mt.dbName2Meta, dbName)

0 commit comments

Comments
 (0)