enhance: Revert "feat: encode cluster id in auto id (#44324)" (#44426)

This reverts commit 7af159410395f0e7079d4875d96544c01f1d477b
This commit is contained in:
Bingyi Sun 2025-09-17 17:56:01 +08:00 committed by GitHub
parent 7af1594103
commit 5cd2d99799
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 3 additions and 62 deletions

View File

@ -1039,7 +1039,6 @@ common:
enableConfigParamTypeCheck: true # Indicates whether to enable config param type check
enablePosixMode: false # Specifies whether to run in POSIX mode for enhanced file system compatibility
UsingJSONStatsForQuery: true # Indicates whether to use json stats when query
clusterID: 0 # cluster id
# QuotaConfig, configurations of Milvus quota and limits.
# By default, we enable:

View File

@ -35,7 +35,6 @@ import (
"github.com/milvus-io/milvus/internal/datacoord/session"
"github.com/milvus-io/milvus/internal/storage"
"github.com/milvus-io/milvus/internal/util/importutilv2"
"github.com/milvus-io/milvus/pkg/v2/common"
"github.com/milvus-io/milvus/pkg/v2/log"
"github.com/milvus-io/milvus/pkg/v2/proto/datapb"
"github.com/milvus-io/milvus/pkg/v2/proto/internalpb"
@ -339,10 +338,7 @@ func AssembleImportRequest(task ImportTask, job ImportJob, meta *meta, alloc all
expansionFactor := paramtable.Get().DataCoordCfg.ImportPreAllocIDExpansionFactor.GetAsInt64()
preAllocIDNum := (totalRows + 1) * int64(binlogNum) * expansionFactor
idBegin, idEnd, err := common.AllocAutoID(func(n uint32) (int64, int64, error) {
ids, ide, e := alloc.AllocN(int64(n))
return int64(ids), int64(ide), e
}, uint32(preAllocIDNum), Params.CommonCfg.ClusterID.GetAsUint64())
idBegin, idEnd, err := alloc.AllocN(preAllocIDNum)
if err != nil {
return nil, err
}

View File

@ -12,7 +12,6 @@ import (
"github.com/milvus-io/milvus-proto/go-api/v2/schemapb"
"github.com/milvus-io/milvus/internal/allocator"
"github.com/milvus-io/milvus/internal/util/function/embedding"
"github.com/milvus-io/milvus/pkg/v2/common"
"github.com/milvus-io/milvus/pkg/v2/log"
"github.com/milvus-io/milvus/pkg/v2/metrics"
"github.com/milvus-io/milvus/pkg/v2/util/commonpbutil"
@ -184,8 +183,7 @@ func (it *insertTask) PreExecute(ctx context.Context) error {
var rowIDBegin UniqueID
var rowIDEnd UniqueID
tr := timerecord.NewTimeRecorder("applyPK")
clusterID := Params.CommonCfg.ClusterID.GetAsUint64()
rowIDBegin, rowIDEnd, _ = common.AllocAutoID(it.idAllocator.Alloc, rowNums, clusterID)
rowIDBegin, rowIDEnd, _ = it.idAllocator.Alloc(rowNums)
metrics.ProxyApplyPrimaryKeyLatency.WithLabelValues(strconv.FormatInt(paramtable.GetNodeID(), 10)).Observe(float64(tr.ElapseSpan().Milliseconds()))
it.insertMsg.RowIDs = make([]UniqueID, rowNums)

View File

@ -767,8 +767,7 @@ func (it *upsertTask) insertPreExecute(ctx context.Context) error {
rowNums := uint32(it.upsertMsg.InsertMsg.NRows())
// set upsertTask.insertRequest.rowIDs
tr := timerecord.NewTimeRecorder("applyPK")
clusterID := Params.CommonCfg.ClusterID.GetAsUint64()
rowIDBegin, rowIDEnd, _ := common.AllocAutoID(it.idAllocator.Alloc, rowNums, clusterID)
rowIDBegin, rowIDEnd, _ := it.idAllocator.Alloc(rowNums)
metrics.ProxyApplyPrimaryKeyLatency.WithLabelValues(strconv.FormatInt(paramtable.GetNodeID(), 10)).Observe(float64(tr.ElapseSpan().Milliseconds()))
it.upsertMsg.InsertMsg.RowIDs = make([]UniqueID, rowNums)

View File

@ -19,7 +19,6 @@ package common
import (
"encoding/binary"
"fmt"
"math/bits"
"strconv"
"strings"
@ -516,15 +515,3 @@ func ParseNamespaceProp(props ...*commonpb.KeyValuePair) (value bool, has bool,
}
return false, false, nil
}
func AllocAutoID(allocFunc func(uint32) (int64, int64, error), rowNum uint32, clusterID uint64) (int64, int64, error) {
idStart, idEnd, err := allocFunc(rowNum)
if err != nil {
return 0, 0, err
}
reversed := bits.Reverse64(clusterID)
// right shift by 1 to preserve sign bit
reversed = reversed >> 1
return idStart | int64(reversed), idEnd | int64(reversed), nil
}

View File

@ -288,12 +288,3 @@ func TestIsEnableDynamicSchema(t *testing.T) {
})
}
}
func TestAllocAutoID(t *testing.T) {
start, end, err := AllocAutoID(func(n uint32) (int64, int64, error) {
return 100, 110, nil
}, 10, 1)
assert.NoError(t, err)
assert.EqualValues(t, 0b0100, start>>60)
assert.EqualValues(t, 0b0100, end>>60)
}

View File

@ -57,7 +57,6 @@ const (
DefaultSearchCacheBudgetGBRatio = 0.10
DefaultLoadNumThreadRatio = 8.0
DefaultBeamWidthRatio = 4.0
MaxClusterIDBits = 3
)
// ComponentParam is used to quickly and easily access all components' configurations.
@ -329,7 +328,6 @@ type commonConfig struct {
EnablePosixMode ParamItem `refreshable:"false"`
UsingJSONStatsForQuery ParamItem `refreshable:"true"`
ClusterID ParamItem `refreshable:"false"`
}
func (p *commonConfig) init(base *BaseTable) {
@ -1250,26 +1248,6 @@ This helps Milvus-CDC synchronize incremental data`,
Export: true,
}
p.EnablePosixMode.Init(base.mgr)
p.ClusterID = ParamItem{
Key: "common.clusterID",
Version: "2.6.3",
DefaultValue: "0",
Doc: "cluster id",
Export: true,
PanicIfEmpty: true,
Formatter: func(v string) string {
if getAsInt(v) < 0 {
return ""
}
maxClusterID := (int64(1) << MaxClusterIDBits) - 1
if getAsInt64(v) > maxClusterID {
return ""
}
return v
},
}
p.ClusterID.Init(base.mgr)
}
type gpuConfig struct {

View File

@ -146,13 +146,6 @@ func TestComponentParam(t *testing.T) {
assert.Equal(t, 1, params.CommonCfg.StorageZstdConcurrency.GetAsInt())
params.Save("common.storage.zstd.concurrency", "2")
assert.Equal(t, 2, params.CommonCfg.StorageZstdConcurrency.GetAsInt())
assert.Equal(t, 0, params.CommonCfg.ClusterID.GetAsInt())
params.Save("common.clusterID", "32")
assert.Panics(t, func() {
params.CommonCfg.ClusterID.GetAsInt()
})
params.Save("common.clusterID", "0")
})
t.Run("test rootCoordConfig", func(t *testing.T) {