fix: fail early when --enable-feature=use-uncached-io is unsupported

Signed-off-by: machine424 <ayoubmrini424@gmail.com>
This commit is contained in:
machine424 2026-03-03 11:43:40 +01:00
parent 1751685dd4
commit 6b4d8fa91e
No known key found for this signature in database
GPG Key ID: A4B001A4FDEE017D
4 changed files with 16 additions and 0 deletions

View File

@ -77,6 +77,7 @@ import (
"github.com/prometheus/prometheus/tracing"
"github.com/prometheus/prometheus/tsdb"
"github.com/prometheus/prometheus/tsdb/agent"
"github.com/prometheus/prometheus/tsdb/fileutil"
"github.com/prometheus/prometheus/util/compression"
"github.com/prometheus/prometheus/util/documentcli"
"github.com/prometheus/prometheus/util/features"
@ -319,6 +320,9 @@ func (c *flagConfig) setFeatureListOptions(logger *slog.Logger) error {
c.web.EnableTypeAndUnitLabels = true
logger.Info("Experimental type and unit labels enabled")
case "use-uncached-io":
if !fileutil.UncachedIOSupported() {
return errors.New("experimental Uncached IO is not supported")
}
c.tsdb.UseUncachedIO = true
logger.Info("Experimental Uncached IO is enabled.")
default:

View File

@ -26,3 +26,7 @@ func NewDirectIOWriter(f *os.File, size int) (BufWriter, error) {
func NewBufioWriterWithSize(f *os.File, size int) (BufWriter, error) {
return NewDirectIOWriter(f, size)
}
func UncachedIOSupported() bool {
return true
}

View File

@ -27,3 +27,7 @@ func NewBufioWriterWithSize(f *os.File, size int) (BufWriter, error) {
func NewDirectIOWriter(f *os.File, size int) (BufWriter, error) {
return newDirectIOWriter(f, size)
}
func UncachedIOSupported() bool {
return true
}

View File

@ -27,3 +27,7 @@ func NewBufioWriterWithSize(f *os.File, size int) (BufWriter, error) {
func NewDirectIOWriter(*os.File, int) (BufWriter, error) {
return nil, errDirectIOUnsupported
}
func UncachedIOSupported() bool {
return false
}