Update pebble db to latest format by default (#10720)
* Update pebble db to latest format by default If the pebble database format is not explicitly set in the config, then set it to the latest format version by default. This will ensure that the database format is sufficiently up-to-date to be compatible with a major version upgrade of pebble.
Andrew Gillis committed
Feb 17, 2025 at 13:32 UTC
e41dc120f762c8cd7571195b3027964a09852773
2 files changed
+19
-1
docs/changelogs/v0.34.md
+6
@@ -9,6 +9,7 @@
9
- [RPC and CLI command changes](#rpc-and-cli-command-changes)
10
- [Bitswap improvements from Boxo](#bitswap-improvements-from-boxo)
11
- [IPFS_LOG_LEVEL deprecated](#ipfs_log_level-deprecated)
12
+ - [Pebble datastore format upgrade](#pebble_datastore_format_update)
13
- [👨👩👧👦 Contributors](#-contributors)
14
15
### Overview
@@ -29,4 +30,9 @@ This release includes performance and reliability improvements and fixes for min
30
31
The variable has been deprecated. Please use [`GOLOG_LOG_LEVEL`](https://github.com/ipfs/kubo/blob/master/docs/environment-variables.md#golog_log_level) instead for configuring logging levels.
32
33
+#### Pebble datastore format update
34
+
35
+If the pebble database format is not explicitly set in the config, then automatically upgrade it to the latest format version supported by the release ob pebble used by kubo. This will ensure that the database format is sufficiently up-to-date to be compatible with a major version upgrade of pebble. This is necessary before upgrading to use pebble v2.
36
+
37
+
38
### 👨👩👧👦 Contributors
plugin/plugins/pebbleds/pebbleds.go
+13
-1
@@ -72,6 +72,11 @@ func (*pebbledsPlugin) DatastoreConfigParser() fsrepo.ConfigFromMap {
72
if err != nil {
73
return nil, err
74
}
75
+ fmv, err := getConfigInt("formatMajorVersion", params)
76
+ if err != nil {
77
+ return nil, err
78
+ }
79
+ formatMajorVersion := pebble.FormatMajorVersion(fmv)
80
l0CompactionThreshold, err := getConfigInt("l0CompactionThreshold", params)
81
if err != nil {
82
return nil, err
@@ -105,10 +110,17 @@ func (*pebbledsPlugin) DatastoreConfigParser() fsrepo.ConfigFromMap {
110
return nil, err
111
}
112
108
- if bytesPerSync != 0 || disableWAL || l0CompactionThreshold != 0 || l0StopWritesThreshold != 0 || lBaseMaxBytes != 0 || maxConcurrentCompactions != 0 || memTableSize != 0 || memTableStopWritesThreshold != 0 || walBytesPerSync != 0 || walMinSyncSec != 0 {
113
+ // Use latest version by default. This will ensure that format is
114
+ // compatible across database upgrades.
115
+ if formatMajorVersion == 0 {
116
+ formatMajorVersion = pebble.FormatNewest
117
+ }
118
+
119
+ if bytesPerSync != 0 || disableWAL || formatMajorVersion != 0 || l0CompactionThreshold != 0 || l0StopWritesThreshold != 0 || lBaseMaxBytes != 0 || maxConcurrentCompactions != 0 || memTableSize != 0 || memTableStopWritesThreshold != 0 || walBytesPerSync != 0 || walMinSyncSec != 0 {
120
c.pebbleOpts = &pebble.Options{
121
BytesPerSync: bytesPerSync,
122
DisableWAL: disableWAL,
123
+ FormatMajorVersion: formatMajorVersion,
124
L0CompactionThreshold: l0CompactionThreshold,
125
L0StopWritesThreshold: l0StopWritesThreshold,
126
LBaseMaxBytes: int64(lBaseMaxBytes),