mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-07 01:28:27 +08:00
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:
parent
4d6b130af4
commit
471b3e4e09
@ -494,8 +494,8 @@ func (t *createCollectionTask) Prepare(ctx context.Context) error {
|
||||
t.Req.Properties = append(properties, timezoneKV)
|
||||
}
|
||||
|
||||
if hookutil.GetEzPropByDBProperties(db.Properties) != nil {
|
||||
t.Req.Properties = append(t.Req.Properties, hookutil.GetEzPropByDBProperties(db.Properties))
|
||||
if ezProps := hookutil.GetEzPropByDBProperties(db.Properties); ezProps != nil {
|
||||
t.Req.Properties = append(t.Req.Properties, ezProps)
|
||||
}
|
||||
|
||||
t.header.DbId = db.ID
|
||||
|
||||
@ -58,10 +58,16 @@ func (c *Core) broadcastCreateDatabase(ctx context.Context, req *milvuspb.Create
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to tidy database cipher properties")
|
||||
}
|
||||
|
||||
tz, exist := funcutil.TryGetAttrByKeyFromRepeatedKV(common.TimezoneKey, properties)
|
||||
if exist && !timestamptz.IsTimezoneValid(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().
|
||||
WithHeader(&message.CreateDatabaseMessageHeader{
|
||||
DbName: req.GetDbName(),
|
||||
|
||||
@ -25,6 +25,7 @@ import (
|
||||
"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/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/ce"
|
||||
"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")
|
||||
}
|
||||
|
||||
// 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().
|
||||
WithHeader(&message.DropDatabaseMessageHeader{
|
||||
DbName: req.GetDbName(),
|
||||
|
||||
@ -341,6 +341,10 @@ func (mt *MetaTable) createDefaultDb() error {
|
||||
|
||||
cipherProps := hookutil.GetDBCipherProperties(ezID, defaultRootKey)
|
||||
defaultProperties = append(defaultProperties, cipherProps...)
|
||||
|
||||
if err := hookutil.CreateEZByDBProperties(defaultProperties); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
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 {
|
||||
dbName := db.Name
|
||||
if err := hookutil.CreateEZByDBProperties(db.Properties); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := mt.catalog.CreateDatabase(ctx, db, ts); err != nil {
|
||||
hookutil.RemoveEZByDBProperties(db.Properties) // ignore the error since create database failed
|
||||
return err
|
||||
}
|
||||
|
||||
@ -444,11 +443,6 @@ func (mt *MetaTable) DropDatabase(ctx context.Context, dbName string, ts typeuti
|
||||
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.aliases.dropDb(dbName)
|
||||
delete(mt.dbName2Meta, dbName)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user