Skip to content

Commit ed1466e

Browse files
committed
db: disable writing to value blocks if DisableSeparationBySuffix is true
Make sure this field, which has been moved from SpanPolicy to ValueStoragePolicy, is read for the DisableValueBlocks option in the sst writer.
1 parent 6d69292 commit ed1466e

File tree

4 files changed

+167
-20
lines changed

4 files changed

+167
-20
lines changed

compaction_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1530,18 +1530,17 @@ func runCompactionTest(
15301530
if len(parts) != 1 {
15311531
td.Fatalf(t, "expected disable-separation-by-suffix with no value, got: %s", arg)
15321532
}
1533-
if policy.ValueStoragePolicy.PolicyAdjustment == NoValueSeparation {
1534-
td.Fatalf(t, "conflicting value storage policies for span: %s", line)
1533+
if policy.ValueStoragePolicy.PolicyAdjustment == UseDefaultValueStorage {
1534+
policy.ValueStoragePolicy.PolicyAdjustment = OverrideValueStorage
15351535
}
1536-
policy.ValueStoragePolicy.PolicyAdjustment = OverrideValueStorage
15371536
policy.ValueStoragePolicy.DisableSeparationBySuffix = true
15381537
case "val-sep-minimum-size":
15391538
if len(parts) != 2 {
15401539
td.Fatalf(t, "expected val-sep-minimum-size=<size>, got: %s", arg)
15411540
}
15421541
size, err := strconv.ParseUint(parts[1], 10, 64)
15431542
if err != nil {
1544-
td.Fatalf(t, "parsing value-minimum-size: %s", err)
1543+
td.Fatalf(t, "parsing val-sep-minimum-size: %s", err)
15451544
}
15461545
policy.ValueStoragePolicy.MinimumSize = int(size)
15471546
if size == 0 {

options.go

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,22 +1299,17 @@ func (p SpanPolicy) String() string {
12991299
}
13001300
switch p.ValueStoragePolicy.PolicyAdjustment {
13011301
case NoValueSeparation:
1302-
sb.WriteString("no-value-separation,")
1302+
sb.WriteString("no-blob-value-separation,")
13031303
case OverrideValueStorage:
1304-
sb.WriteString("override,")
1304+
sb.WriteString("override-value-separation,")
13051305
}
13061306
return strings.TrimSuffix(sb.String(), ",")
13071307
}
13081308

13091309
// ValueStoragePolicyAdjustment is used to determine where to store the values for
1310-
// KVs. If the PolicyAdjustment specified is OverrideValueStorage, the remaining fields
1311-
// are used to override the global configuration for value separation.
1310+
// KVs, overriding global policies. Values can be configured to be stored in-place,
1311+
// in value blocks, or in blob files.
13121312
type ValueStoragePolicyAdjustment struct {
1313-
// PolicyAdjustment specifies the policy adjustment to apply.
1314-
PolicyAdjustment ValueStoragePolicyAdjustmentType
1315-
1316-
// Remaining fields are ignored, unless the PolicyAdjustment is OverrideValueStorage.
1317-
13181313
// DisableSeparationBySuffix disables discriminating KVs depending on
13191314
// suffix.
13201315
//
@@ -1323,6 +1318,13 @@ type ValueStoragePolicyAdjustment struct {
13231318
// keys (where the smallest suffix is the latest version), but should be
13241319
// disabled for keys where the suffix does not correspond to a version.
13251320
DisableSeparationBySuffix bool
1321+
1322+
// PolicyAdjustment specifies the policy adjustment to apply for value separation
1323+
// into blob files.
1324+
PolicyAdjustment ValueStoragePolicyAdjustmentType
1325+
1326+
// Remaining fields are ignored, unless the PolicyAdjustment is OverrideValueStorage.
1327+
13261328
// MinimumSize is the minimum size of the value.
13271329
MinimumSize int
13281330
}
@@ -1333,11 +1335,11 @@ type ValueStoragePolicyAdjustmentType uint8
13331335

13341336
const (
13351337
// UseDefaultValueStorage is the default value; Pebble will respect global
1336-
// configuration for value separation.
1338+
// configuration for value separation into blob files.
13371339
UseDefaultValueStorage ValueStoragePolicyAdjustmentType = iota
13381340

1339-
// NoValueSeparation indicates Pebble should prefer storing values
1340-
// in-place.
1341+
// NoValueSeparation indicates Pebble should prefer storing values in
1342+
// the same sstable (either in-place or in a value block).
13411343
NoValueSeparation
13421344

13431345
// OverrideValueStorage indicates that value separation thresholds (see
@@ -1360,7 +1362,8 @@ var ValueStorageLatencyTolerant = ValueStoragePolicyAdjustment{
13601362
// ValueStorageLowReadLatency is the suggested ValueStoragePolicyAdjustment
13611363
// to use for key ranges that require low value retrieval latency.
13621364
var ValueStorageLowReadLatency = ValueStoragePolicyAdjustment{
1363-
PolicyAdjustment: NoValueSeparation,
1365+
PolicyAdjustment: NoValueSeparation,
1366+
DisableSeparationBySuffix: true,
13641367
}
13651368

13661369
// SpanPolicyFunc is used to determine the SpanPolicy for a key region.

sstable/properties.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,9 @@ type Properties struct {
125125
// The minimum size a value must be to be separated into a blob file during writing.
126126
ValueSeparationMinSize uint64 `prop:"pebble.value-separation.min-size"`
127127
// ValueSeparationBySuffixDisabled indicates if special value separation rules were
128-
// applied based on the KV suffix when writing. Pebble attempts to optimize writing of
129-
// MVCC garbage values into blob files, which are recognized by the key suffix.
128+
// applied based on the KV suffix when writing blob files. Pebble attempts to optimize
129+
// separating MVCC garbage, which are recognized by the key suffix. Note that this
130+
// value corresponds only for blob file writing and not value blocks.
130131
ValueSeparationBySuffixDisabled bool `prop:"pebble.value-separation.by-suffix.disabled"`
131132
// User collected properties. Currently, we only use them to store block
132133
// properties aggregated at the table level.

testdata/compaction/mvcc_garbage_blob

Lines changed: 145 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ flush-log
6767

6868
# Another test with the same value separation config, but this time we set a span
6969
# policy for the span y-zz that disables value separation by suffix. This should
70-
# prevent MVCC garbage from being written to blob files.
70+
# prevent MVCC garbage from being separeted (both into blob files and value blocks).
7171

7272
define value-separation=(enabled, min-size=5, max-ref-depth=3, garbage-ratios=1.0:1.0)
7373
----
@@ -127,3 +127,147 @@ pebble.compression_stats: None:234
127127
pebble.value-separation.min-size: 5
128128
pebble.value-separation.by-suffix.disabled: true
129129
obsolete-key: hex:00
130+
131+
define value-separation=(enabled, min-size=5, max-ref-depth=3, garbage-ratios=1.0:1.0)
132+
----
133+
134+
135+
set-span-policies
136+
a,c val-sep-minimum-size=0 disable-separation-by-suffix
137+
----
138+
139+
140+
batch
141+
set a@2 a2
142+
set b@5 b5
143+
del b@4
144+
set b@3 bat3
145+
set b@2 bat2
146+
del b@1
147+
set b@1 bat1
148+
set b@0 bat0
149+
----
150+
151+
flush
152+
----
153+
L0.0:
154+
000005:[a@2#10,SET-b@0#17,SET] seqnums:[10-17] points:[a@2#10,SET-b@0#17,SET] size:770
155+
156+
sstable-properties file=000005
157+
----
158+
rocksdb.num.entries: 7
159+
rocksdb.raw.key.size: 77
160+
rocksdb.raw.value.size: 20
161+
pebble.raw.point-tombstone.key.size: 3
162+
rocksdb.deleted.keys: 1
163+
rocksdb.num.range-deletions: 0
164+
rocksdb.num.data.blocks: 1
165+
rocksdb.comparator: pebble.internal.testkeys
166+
rocksdb.data.size: 157
167+
rocksdb.filter.size: 0
168+
rocksdb.index.size: 36
169+
rocksdb.block.based.table.index.type: 0
170+
pebble.colblk.schema: DefaultKeySchema(pebble.internal.testkeys,16)
171+
rocksdb.merge.operator: pebble.concatenate
172+
rocksdb.merge.operands: 0
173+
rocksdb.property.collectors: [obsolete-key]
174+
rocksdb.compression: Snappy
175+
pebble.compression_stats: None:188
176+
obsolete-key: hex:00
177+
178+
179+
define value-separation=(enabled, min-size=5, max-ref-depth=3, garbage-ratios=1.0:1.0)
180+
----
181+
182+
set-span-policies
183+
a,c val-sep-minimum-size=0
184+
----
185+
186+
187+
batch
188+
set a@2 a2
189+
set b@5 b5
190+
del b@4
191+
set b@3 bat3
192+
set b@2 bat2
193+
del b@1
194+
set b@1 bat1
195+
set b@0 bat0
196+
----
197+
198+
# Although we've disabled value separation into blob files, writing to
199+
# value blocks should still be enabled.
200+
flush
201+
----
202+
L0.0:
203+
000005:[a@2#10,SET-b@0#17,SET] seqnums:[10-17] points:[a@2#10,SET-b@0#17,SET] size:880
204+
205+
sstable-properties file=000005
206+
----
207+
rocksdb.num.entries: 7
208+
rocksdb.raw.key.size: 77
209+
rocksdb.raw.value.size: 20
210+
pebble.raw.point-tombstone.key.size: 3
211+
rocksdb.deleted.keys: 1
212+
rocksdb.num.range-deletions: 0
213+
pebble.value-blocks.size: 25
214+
rocksdb.num.data.blocks: 1
215+
rocksdb.comparator: pebble.internal.testkeys
216+
rocksdb.data.size: 175
217+
rocksdb.filter.size: 0
218+
rocksdb.index.size: 36
219+
rocksdb.block.based.table.index.type: 0
220+
pebble.colblk.schema: DefaultKeySchema(pebble.internal.testkeys,16)
221+
rocksdb.merge.operator: pebble.concatenate
222+
rocksdb.merge.operands: 0
223+
pebble.num.value-blocks: 1
224+
pebble.num.values.in.value-blocks: 3
225+
rocksdb.property.collectors: [obsolete-key]
226+
rocksdb.compression: Snappy
227+
pebble.compression_stats: None:221
228+
obsolete-key: hex:00
229+
230+
batch
231+
set a@2 a2
232+
set b@5 b5
233+
del b@4
234+
set b@3 bat3
235+
set b@2 bat2
236+
del b@1
237+
set b@1 bat1
238+
set b@0 bat0
239+
----
240+
241+
# Disabling value separation by suffix should also disable writing to value blocks.
242+
set-span-policies
243+
a,c val-sep-minimum-size=0 disable-separation-by-suffix
244+
----
245+
246+
flush
247+
----
248+
L0.1:
249+
000007:[a@2#18,SET-b@0#25,SET] seqnums:[18-25] points:[a@2#18,SET-b@0#25,SET] size:770
250+
L0.0:
251+
000005:[a@2#10,SET-b@0#17,SET] seqnums:[10-17] points:[a@2#10,SET-b@0#17,SET] size:880
252+
253+
sstable-properties file=000007
254+
----
255+
rocksdb.num.entries: 7
256+
rocksdb.raw.key.size: 77
257+
rocksdb.raw.value.size: 20
258+
pebble.raw.point-tombstone.key.size: 3
259+
rocksdb.deleted.keys: 1
260+
rocksdb.num.range-deletions: 0
261+
rocksdb.num.data.blocks: 1
262+
rocksdb.comparator: pebble.internal.testkeys
263+
rocksdb.data.size: 157
264+
rocksdb.filter.size: 0
265+
rocksdb.index.size: 36
266+
rocksdb.block.based.table.index.type: 0
267+
pebble.colblk.schema: DefaultKeySchema(pebble.internal.testkeys,16)
268+
rocksdb.merge.operator: pebble.concatenate
269+
rocksdb.merge.operands: 0
270+
rocksdb.property.collectors: [obsolete-key]
271+
rocksdb.compression: Snappy
272+
pebble.compression_stats: None:188
273+
obsolete-key: hex:00

0 commit comments

Comments
 (0)