diff --git a/go.mod b/go.mod index 8868f5d491..dd3c234815 100644 --- a/go.mod +++ b/go.mod @@ -26,7 +26,7 @@ require ( github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 github.com/klauspost/compress v1.17.7 github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d - github.com/milvus-io/milvus-proto/go-api/v2 v2.4.5 + github.com/milvus-io/milvus-proto/go-api/v2 v2.4.6 github.com/minio/minio-go/v7 v7.0.61 github.com/pingcap/log v1.1.1-0.20221015072633-39906604fb81 github.com/prometheus/client_golang v1.14.0 @@ -65,12 +65,14 @@ require ( require github.com/milvus-io/milvus-storage/go v0.0.0-20231227072638-ebd0b8e56d70 require ( + github.com/bits-and-blooms/bitset v1.10.0 github.com/greatroar/blobloom v0.8.0 github.com/jolestar/go-commons-pool/v2 v2.1.2 github.com/milvus-io/milvus/pkg v0.0.0-00010101000000-000000000000 github.com/pkg/errors v0.9.1 github.com/valyala/fastjson v1.6.4 github.com/zeebo/xxh3 v1.0.2 + google.golang.org/protobuf v1.33.0 gopkg.in/yaml.v3 v3.0.1 ) @@ -92,7 +94,6 @@ require ( github.com/benbjohnson/clock v1.1.0 // indirect github.com/benesch/cgosymbolizer v0.0.0-20190515212042-bec6fe6e597b // indirect github.com/beorn7/perks v1.0.1 // indirect - github.com/bits-and-blooms/bitset v1.10.0 // indirect github.com/bytedance/sonic v1.9.1 // indirect github.com/campoy/embedmd v1.0.0 // indirect github.com/cenkalti/backoff/v4 v4.2.0 // indirect @@ -235,7 +236,6 @@ require ( google.golang.org/genproto v0.0.0-20230706204954-ccb25ca9f130 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20230629202037-9506855d4529 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda // indirect - google.golang.org/protobuf v1.33.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect @@ -249,7 +249,6 @@ replace ( github.com/bketelsen/crypt => github.com/bketelsen/crypt v0.0.4 // Fix security alert for core-os/etcd github.com/expr-lang/expr => github.com/SimFG/expr v0.0.0-20231218130003-94d085776dc5 github.com/go-kit/kit => github.com/go-kit/kit v0.1.0 - github.com/greatroar/blobloom => github.com/milvus-io/blobloom v0.0.0-20240603110411-471ae49f3b93 // github.com/milvus-io/milvus-storage/go => ../milvus-storage/go github.com/milvus-io/milvus/pkg => ./pkg github.com/streamnative/pulsarctl => github.com/xiaofan-luan/pulsarctl v0.5.1 diff --git a/go.sum b/go.sum index aa61435339..a014845cea 100644 --- a/go.sum +++ b/go.sum @@ -607,8 +607,8 @@ github.com/milvus-io/blobloom v0.0.0-20240603110411-471ae49f3b93 h1:xnIeuG1nuTEH github.com/milvus-io/blobloom v0.0.0-20240603110411-471ae49f3b93/go.mod h1:mjMJ1hh1wjGVfr93QIHJ6FfDNVrA0IELv8OvMHJxHKs= github.com/milvus-io/gorocksdb v0.0.0-20220624081344-8c5f4212846b h1:TfeY0NxYxZzUfIfYe5qYDBzt4ZYRqzUjTR6CvUzjat8= github.com/milvus-io/gorocksdb v0.0.0-20220624081344-8c5f4212846b/go.mod h1:iwW+9cWfIzzDseEBCCeDSN5SD16Tidvy8cwQ7ZY8Qj4= -github.com/milvus-io/milvus-proto/go-api/v2 v2.4.5 h1:83SZKox70jyABAPY7HdbvrwI3cmgwzyuc7dO4dYmoC0= -github.com/milvus-io/milvus-proto/go-api/v2 v2.4.5/go.mod h1:1OIl0v5PQeNxIJhCvY+K55CBUOYDZevw9g9380u1Wek= +github.com/milvus-io/milvus-proto/go-api/v2 v2.4.6 h1:rSkwp5Mg/7KBSUqXcrPBUgTQGZNdvYWEKB+rHo9YJtk= +github.com/milvus-io/milvus-proto/go-api/v2 v2.4.6/go.mod h1:1OIl0v5PQeNxIJhCvY+K55CBUOYDZevw9g9380u1Wek= github.com/milvus-io/milvus-storage/go v0.0.0-20231227072638-ebd0b8e56d70 h1:Z+sp64fmAOxAG7mU0dfVOXvAXlwRB0c8a96rIM5HevI= github.com/milvus-io/milvus-storage/go v0.0.0-20231227072638-ebd0b8e56d70/go.mod h1:GPETMcTZq1gLY1WA6Na5kiNAKnq8SEMMiVKUZrM3sho= github.com/milvus-io/pulsar-client-go v0.6.10 h1:eqpJjU+/QX0iIhEo3nhOqMNXL+TyInAs1IAHZCrCM/A= diff --git a/internal/metastore/kv/rootcoord/kv_catalog_test.go b/internal/metastore/kv/rootcoord/kv_catalog_test.go index feebcee7ab..236ba03ad6 100644 --- a/internal/metastore/kv/rootcoord/kv_catalog_test.go +++ b/internal/metastore/kv/rootcoord/kv_catalog_test.go @@ -2536,7 +2536,7 @@ func TestRBAC_Grant(t *testing.T) { func TestCatalog_AlterDatabase(t *testing.T) { kvmock := mocks.NewSnapShotKV(t) c := &Catalog{Snapshot: kvmock} - db := model.NewDatabase(1, "db", pb.DatabaseState_DatabaseCreated) + db := model.NewDatabase(1, "db", pb.DatabaseState_DatabaseCreated, nil) kvmock.EXPECT().Save(mock.Anything, mock.Anything, mock.Anything).Return(nil) ctx := context.Background() diff --git a/internal/metastore/model/database.go b/internal/metastore/model/database.go index 91e8828222..52fe49fb82 100644 --- a/internal/metastore/model/database.go +++ b/internal/metastore/model/database.go @@ -18,18 +18,21 @@ type Database struct { Properties []*commonpb.KeyValuePair } -func NewDatabase(id int64, name string, state pb.DatabaseState) *Database { +func NewDatabase(id int64, name string, state pb.DatabaseState, properties []*commonpb.KeyValuePair) *Database { + if properties == nil { + properties = make([]*commonpb.KeyValuePair, 0) + } return &Database{ ID: id, Name: name, State: state, CreatedTime: uint64(time.Now().UnixNano()), - Properties: make([]*commonpb.KeyValuePair, 0), + Properties: properties, } } func NewDefaultDatabase() *Database { - return NewDatabase(util.DefaultDBID, util.DefaultDBName, pb.DatabaseState_DatabaseCreated) + return NewDatabase(util.DefaultDBID, util.DefaultDBName, pb.DatabaseState_DatabaseCreated, nil) } func (c *Database) Available() bool { diff --git a/internal/rootcoord/broker_test.go b/internal/rootcoord/broker_test.go index 5accc2b1b1..4d4102d560 100644 --- a/internal/rootcoord/broker_test.go +++ b/internal/rootcoord/broker_test.go @@ -333,7 +333,7 @@ func TestServerBroker_GcConfirm(t *testing.T) { } func mockGetDatabase(meta *mockrootcoord.IMetaTable) { - db := model.NewDatabase(1, "default", pb.DatabaseState_DatabaseCreated) + db := model.NewDatabase(1, "default", pb.DatabaseState_DatabaseCreated, nil) meta.EXPECT().GetDatabaseByName(mock.Anything, mock.Anything, mock.Anything). Return(db, nil).Maybe() meta.EXPECT().GetDatabaseByID(mock.Anything, mock.Anything, mock.Anything). diff --git a/internal/rootcoord/create_db_task.go b/internal/rootcoord/create_db_task.go index 089c25c68f..31de0c5f5a 100644 --- a/internal/rootcoord/create_db_task.go +++ b/internal/rootcoord/create_db_task.go @@ -50,6 +50,6 @@ func (t *createDatabaseTask) Prepare(ctx context.Context) error { } func (t *createDatabaseTask) Execute(ctx context.Context) error { - db := model.NewDatabase(t.dbID, t.Req.GetDbName(), etcdpb.DatabaseState_DatabaseCreated) + db := model.NewDatabase(t.dbID, t.Req.GetDbName(), etcdpb.DatabaseState_DatabaseCreated, t.Req.GetProperties()) return t.core.meta.CreateDatabase(ctx, db, t.GetTs()) } diff --git a/internal/rootcoord/meta_table_test.go b/internal/rootcoord/meta_table_test.go index bcade0aafd..b916facaf1 100644 --- a/internal/rootcoord/meta_table_test.go +++ b/internal/rootcoord/meta_table_test.go @@ -1563,7 +1563,7 @@ func TestMetaTable_RenameCollection(t *testing.T) { meta := &MetaTable{ dbName2Meta: map[string]*model.Database{ util.DefaultDBName: model.NewDefaultDatabase(), - "db1": model.NewDatabase(2, "db1", pb.DatabaseState_DatabaseCreated), + "db1": model.NewDatabase(2, "db1", pb.DatabaseState_DatabaseCreated, nil), }, catalog: catalog, names: newNameDb(), @@ -1696,7 +1696,7 @@ func TestMetaTable_ChangePartitionState(t *testing.T) { } func TestMetaTable_CreateDatabase(t *testing.T) { - db := model.NewDatabase(1, "exist", pb.DatabaseState_DatabaseCreated) + db := model.NewDatabase(1, "exist", pb.DatabaseState_DatabaseCreated, nil) t.Run("database already exist", func(t *testing.T) { meta := &MetaTable{ names: newNameDb(), @@ -1755,7 +1755,7 @@ func TestAlterDatabase(t *testing.T) { mock.Anything, ).Return(nil) - db := model.NewDatabase(1, "db1", pb.DatabaseState_DatabaseCreated) + db := model.NewDatabase(1, "db1", pb.DatabaseState_DatabaseCreated, nil) meta := &MetaTable{ dbName2Meta: map[string]*model.Database{ @@ -1785,7 +1785,7 @@ func TestAlterDatabase(t *testing.T) { mock.Anything, ).Return(mockErr) - db := model.NewDatabase(1, "db1", pb.DatabaseState_DatabaseCreated) + db := model.NewDatabase(1, "db1", pb.DatabaseState_DatabaseCreated, nil) meta := &MetaTable{ dbName2Meta: map[string]*model.Database{ @@ -1808,7 +1808,7 @@ func TestAlterDatabase(t *testing.T) { t.Run("alter database name", func(t *testing.T) { catalog := mocks.NewRootCoordCatalog(t) - db := model.NewDatabase(1, "db1", pb.DatabaseState_DatabaseCreated) + db := model.NewDatabase(1, "db1", pb.DatabaseState_DatabaseCreated, nil) meta := &MetaTable{ dbName2Meta: map[string]*model.Database{ @@ -1863,7 +1863,7 @@ func TestMetaTable_EmtpyDatabaseName(t *testing.T) { names: newNameDb(), dbName2Meta: map[string]*model.Database{ util.DefaultDBName: model.NewDefaultDatabase(), - "db2": model.NewDatabase(2, "db2", pb.DatabaseState_DatabaseCreated), + "db2": model.NewDatabase(2, "db2", pb.DatabaseState_DatabaseCreated, nil), }, collID2Meta: map[typeutil.UniqueID]*model.Collection{ 1: { @@ -1939,7 +1939,7 @@ func TestMetaTable_DropDatabase(t *testing.T) { t.Run("database not empty", func(t *testing.T) { mt := &MetaTable{ dbName2Meta: map[string]*model.Database{ - "not_empty": model.NewDatabase(1, "not_empty", pb.DatabaseState_DatabaseCreated), + "not_empty": model.NewDatabase(1, "not_empty", pb.DatabaseState_DatabaseCreated, nil), }, names: newNameDb(), aliases: newNameDb(), @@ -1965,7 +1965,7 @@ func TestMetaTable_DropDatabase(t *testing.T) { ).Return(errors.New("error mock DropDatabase")) mt := &MetaTable{ dbName2Meta: map[string]*model.Database{ - "not_commit": model.NewDatabase(1, "not_commit", pb.DatabaseState_DatabaseCreated), + "not_commit": model.NewDatabase(1, "not_commit", pb.DatabaseState_DatabaseCreated, nil), }, names: newNameDb(), aliases: newNameDb(), @@ -1986,7 +1986,7 @@ func TestMetaTable_DropDatabase(t *testing.T) { ).Return(nil) mt := &MetaTable{ dbName2Meta: map[string]*model.Database{ - "not_commit": model.NewDatabase(1, "not_commit", pb.DatabaseState_DatabaseCreated), + "not_commit": model.NewDatabase(1, "not_commit", pb.DatabaseState_DatabaseCreated, nil), }, names: newNameDb(), aliases: newNameDb(),