fix: Make default local storage path effective (#44514)

Make default local storage path effective instead of empty when yaml
config file is missing.

issue: https://github.com/milvus-io/milvus/issues/44513

---------

Signed-off-by: bigsheeper <yihao.dai@zilliz.com>
This commit is contained in:
yihao.dai 2025-09-24 21:00:06 +08:00 committed by GitHub
parent 19e5e9f910
commit 2807d1d1b2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 4 deletions

View File

@ -3724,7 +3724,8 @@ This defaults to true, indicating that Milvus creates temporary index for growin
Doc: "Deprecated: The folder that storing data files for mmap, setting to a path will enable Milvus to load data with mmap",
Formatter: func(v string) string {
if len(v) == 0 {
return path.Join(base.Get("localStorage.path"), "mmap")
localStoragePath := getLocalStoragePath(base)
return path.Join(localStoragePath, "mmap")
}
return v
},
@ -3997,7 +3998,7 @@ Max read concurrency must greater than or equal to 1, and less than or equal to
Formatter: func(v string) string {
if len(v) == 0 {
// use local storage path to check correct device
localStoragePath := base.Get("localStorage.path")
localStoragePath := getLocalStoragePath(base)
if _, err := os.Stat(localStoragePath); os.IsNotExist(err) {
if err := os.MkdirAll(localStoragePath, os.ModePerm); err != nil {
log.Fatal("failed to mkdir", zap.String("localStoragePath", localStoragePath), zap.Error(err))
@ -6576,3 +6577,12 @@ func (params *ComponentParam) Reset(key string) error {
func (params *ComponentParam) GetWithDefault(key string, dft string) string {
return params.baseTable.GetWithDefault(key, dft)
}
func getLocalStoragePath(base *BaseTable) string {
localStoragePath := base.Get("localStorage.path")
if len(localStoragePath) == 0 {
localStoragePath = defaultLocalStoragePath
log.Warn("localStorage.path is not set, using default value", zap.String("localStorage.path", localStoragePath))
}
return localStoragePath
}

View File

@ -37,6 +37,8 @@ const (
defaultEtcdLogPath = "stdout"
KafkaProducerConfigPrefix = "kafka.producer."
KafkaConsumerConfigPrefix = "kafka.consumer."
defaultLocalStoragePath = "/var/lib/milvus/data"
)
// ServiceParam is used to quickly and easily access all basic service configurations.
@ -462,7 +464,7 @@ func (p *LocalStorageConfig) Init(base *BaseTable) {
p.Path = ParamItem{
Key: "localStorage.path",
Version: "2.0.0",
DefaultValue: "/var/lib/milvus/data",
DefaultValue: defaultLocalStoragePath,
Doc: `Local path to where vector data are stored during a search or a query to avoid repetitve access to MinIO or S3 service.
Caution: Changing this parameter after using Milvus for a period of time will affect your access to old data.
It is recommended to change this parameter before starting Milvus for the first time.`,
@ -1549,7 +1551,8 @@ func (p *ProfileConfig) Init(base *BaseTable) {
Doc: "The folder that storing pprof files, by default will use localStoragePath/pprof",
Formatter: func(v string) string {
if len(v) == 0 {
return path.Join(base.Get("localStorage.path"), "pprof")
localStoragePath := getLocalStoragePath(base)
return path.Join(localStoragePath, "pprof")
}
return v
},