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>
This commit is contained in:
XuanYang-cn 2025-11-25 20:01:06 +08:00 committed by GitHub
parent 4d6b130af4
commit 471b3e4e09
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 18 additions and 12 deletions

View File

@ -494,8 +494,8 @@ func (t *createCollectionTask) Prepare(ctx context.Context) error {
t.Req.Properties = append(properties, timezoneKV) t.Req.Properties = append(properties, timezoneKV)
} }
if hookutil.GetEzPropByDBProperties(db.Properties) != nil { if ezProps := hookutil.GetEzPropByDBProperties(db.Properties); ezProps != nil {
t.Req.Properties = append(t.Req.Properties, hookutil.GetEzPropByDBProperties(db.Properties)) t.Req.Properties = append(t.Req.Properties, ezProps)
} }
t.header.DbId = db.ID t.header.DbId = db.ID

View File

@ -58,10 +58,16 @@ func (c *Core) broadcastCreateDatabase(ctx context.Context, req *milvuspb.Create
if err != nil { if err != nil {
return errors.Wrap(err, "failed to tidy database cipher properties") return errors.Wrap(err, "failed to tidy database cipher properties")
} }
tz, exist := funcutil.TryGetAttrByKeyFromRepeatedKV(common.TimezoneKey, properties) tz, exist := funcutil.TryGetAttrByKeyFromRepeatedKV(common.TimezoneKey, properties)
if exist && !timestamptz.IsTimezoneValid(tz) { if exist && !timestamptz.IsTimezoneValid(tz) {
return merr.WrapErrParameterInvalidMsg("unknown or invalid IANA Time Zone ID: %s", tz) return merr.WrapErrParameterInvalidMsg("unknown or invalid IANA Time Zone ID: %s", tz)
} }
if err := hookutil.CreateEZByDBProperties(properties); err != nil {
return errors.Wrap(err, "failed to create ez by db properties")
}
msg := message.NewCreateDatabaseMessageBuilderV2(). msg := message.NewCreateDatabaseMessageBuilderV2().
WithHeader(&message.CreateDatabaseMessageHeader{ WithHeader(&message.CreateDatabaseMessageHeader{
DbName: req.GetDbName(), DbName: req.GetDbName(),

View File

@ -25,6 +25,7 @@ import (
"github.com/milvus-io/milvus-proto/go-api/v2/commonpb" "github.com/milvus-io/milvus-proto/go-api/v2/commonpb"
"github.com/milvus-io/milvus-proto/go-api/v2/milvuspb" "github.com/milvus-io/milvus-proto/go-api/v2/milvuspb"
"github.com/milvus-io/milvus/internal/distributed/streaming" "github.com/milvus-io/milvus/internal/distributed/streaming"
"github.com/milvus-io/milvus/internal/util/hookutil"
"github.com/milvus-io/milvus/pkg/v2/streaming/util/message" "github.com/milvus-io/milvus/pkg/v2/streaming/util/message"
"github.com/milvus-io/milvus/pkg/v2/streaming/util/message/ce" "github.com/milvus-io/milvus/pkg/v2/streaming/util/message/ce"
"github.com/milvus-io/milvus/pkg/v2/util/typeutil" "github.com/milvus-io/milvus/pkg/v2/util/typeutil"
@ -47,6 +48,11 @@ func (c *Core) broadcastDropDatabase(ctx context.Context, req *milvuspb.DropData
return errors.Wrap(err, "failed to get database name") return errors.Wrap(err, "failed to get database name")
} }
// Call back cipher plugin when dropping database succeeded
if err := hookutil.RemoveEZByDBProperties(db.Properties); err != nil {
return errors.Wrap(err, "failed to remove ez by db properties")
}
msg := message.NewDropDatabaseMessageBuilderV2(). msg := message.NewDropDatabaseMessageBuilderV2().
WithHeader(&message.DropDatabaseMessageHeader{ WithHeader(&message.DropDatabaseMessageHeader{
DbName: req.GetDbName(), DbName: req.GetDbName(),

View File

@ -341,6 +341,10 @@ func (mt *MetaTable) createDefaultDb() error {
cipherProps := hookutil.GetDBCipherProperties(ezID, defaultRootKey) cipherProps := hookutil.GetDBCipherProperties(ezID, defaultRootKey)
defaultProperties = append(defaultProperties, cipherProps...) defaultProperties = append(defaultProperties, cipherProps...)
if err := hookutil.CreateEZByDBProperties(defaultProperties); err != nil {
return err
}
} }
return mt.createDatabasePrivate(mt.ctx, model.NewDefaultDatabase(defaultProperties), ts) return mt.createDatabasePrivate(mt.ctx, model.NewDefaultDatabase(defaultProperties), ts)
@ -377,12 +381,7 @@ func (mt *MetaTable) CreateDatabase(ctx context.Context, db *model.Database, ts
func (mt *MetaTable) createDatabasePrivate(ctx context.Context, db *model.Database, ts typeutil.Timestamp) error { func (mt *MetaTable) createDatabasePrivate(ctx context.Context, db *model.Database, ts typeutil.Timestamp) error {
dbName := db.Name dbName := db.Name
if err := hookutil.CreateEZByDBProperties(db.Properties); err != nil {
return err
}
if err := mt.catalog.CreateDatabase(ctx, db, ts); err != nil { if err := mt.catalog.CreateDatabase(ctx, db, ts); err != nil {
hookutil.RemoveEZByDBProperties(db.Properties) // ignore the error since create database failed
return err return err
} }
@ -444,11 +443,6 @@ func (mt *MetaTable) DropDatabase(ctx context.Context, dbName string, ts typeuti
return err return err
} }
// Call back cipher plugin when dropping database succeeded
if err := hookutil.RemoveEZByDBProperties(db.Properties); err != nil {
return err
}
mt.names.dropDb(dbName) mt.names.dropDb(dbName)
mt.aliases.dropDb(dbName) mt.aliases.dropDb(dbName)
delete(mt.dbName2Meta, dbName) delete(mt.dbName2Meta, dbName)