Merge pull request #53043 from thaJeztah/bolt_bolder

use FreelistMapType for boltdb
This commit is contained in:
Paweł Gronowski
2026-07-24 18:15:00 +02:00
committed by GitHub
6 changed files with 21 additions and 7 deletions

View File

@@ -31,7 +31,9 @@ func NewBoltDBBackend(root string) (Backend, error) {
if err := os.MkdirAll(cacheDir, 0o700); err != nil {
return nil, err
}
db, err := safeOpen(filepath.Join(cacheDir, "identity-cache.db"), 0o600, nil)
db, err := safeOpen(filepath.Join(cacheDir, "identity-cache.db"), 0o600, &bolt.Options{
FreelistType: bolt.FreelistMapType,
})
if err != nil {
return nil, err
}

View File

@@ -20,7 +20,9 @@ func (daemon *Daemon) configureLocalContentStore(ns string) (*namespacedContent,
if err := os.MkdirAll(filepath.Join(daemon.root, "content"), 0o700); err != nil {
return nil, nil, errors.Wrap(err, "error creating dir for content store")
}
db, err := bolt.Open(filepath.Join(daemon.root, "content", "metadata.db"), 0o600, nil)
db, err := bolt.Open(filepath.Join(daemon.root, "content", "metadata.db"), 0o600, &bolt.Options{
FreelistType: bolt.FreelistMapType,
})
if err != nil {
return nil, nil, errors.Wrap(err, "error opening bolt db for content metadata store")
}

View File

@@ -62,7 +62,9 @@ type snapshotter struct {
// NewSnapshotter creates a new snapshotter
func NewSnapshotter(opt Opt, prevLM leases.Manager, ns string) (_ snapshot.Snapshotter, _ *leaseutil.Manager, retErr error) {
dbPath := filepath.Join(opt.Root, "snapshots.db")
db, err := bolt.Open(dbPath, 0o600, nil)
db, err := bolt.Open(dbPath, 0o600, &bolt.Options{
FreelistType: bolt.FreelistMapType,
})
if err != nil {
return nil, nil, errors.Wrapf(err, "failed to open database file %s", dbPath)
}

View File

@@ -235,7 +235,9 @@ func newSnapshotterController(ctx context.Context, rt http.RoundTripper, opt Opt
}
func openHistoryDB(root string, fn string, cfg *config.BuilderHistoryConfig) (*bolt.DB, *bkconfig.HistoryConfig, error) {
db, err := bolt.Open(filepath.Join(root, fn), 0o600, nil)
db, err := bolt.Open(filepath.Join(root, fn), 0o600, &bolt.Options{
FreelistType: bolt.FreelistMapType,
})
if err != nil {
return nil, nil, err
}
@@ -285,7 +287,9 @@ func newGraphDriverController(ctx context.Context, rt http.RoundTripper, opt Opt
return nil, err
}
db, err := bolt.Open(filepath.Join(root, "containerdmeta.db"), 0o644, nil)
db, err := bolt.Open(filepath.Join(root, "containerdmeta.db"), 0o644, &bolt.Options{
FreelistType: bolt.FreelistMapType,
})
if err != nil {
return nil, errors.WithStack(err)
}

View File

@@ -45,7 +45,8 @@ func New(path, bucket string) (store.Store, error) {
// bbolt package returns an ErrTimeout straight away. That way, the
// daemon, and unit tests, will fail fast and loudly instead of
// silently introducing delays.
Timeout: time.Nanosecond,
Timeout: time.Nanosecond,
FreelistType: bolt.FreelistMapType,
})
if err != nil {
if errors.Is(err, berrors.ErrTimeout) {

View File

@@ -104,7 +104,10 @@ func NewStore(rootPath string, drivers *drivers.Store, opts ...StoreOpt) (*Volum
var err error
dbPath := filepath.Join(volPath, "metadata.db")
vs.db, err = bolt.Open(dbPath, 0o600, &bolt.Options{Timeout: 1 * time.Second})
vs.db, err = bolt.Open(dbPath, 0o600, &bolt.Options{
Timeout: 1 * time.Second,
FreelistType: bolt.FreelistMapType,
})
if err != nil {
return nil, errors.Wrapf(err, "error while opening volume store metadata database (%s)", dbPath)
}