Skip to content

Commit 65c856a

Browse files
craig[bot]RaduBerindemiraradeva
committed
151474: storage: bump Pebble format version r=RaduBerinde a=RaduBerinde #### go.mod: bump Pebble to 258531bdf87e Changes: * [`258531bd`](cockroachdb/pebble@258531bd) blob: add FileFormatV2 which has a properties block * [`4be89e71`](cockroachdb/pebble@4be89e71) go.mod: require go1.24 * [`d3bef264`](cockroachdb/pebble@d3bef264) sstable: remove CompressionOptions * [`2d7040f1`](cockroachdb/pebble@2d7040f1) manifest: improve API around TableStats * [`7d7cc282`](cockroachdb/pebble@7d7cc282) db: fix bug in scaling compression stats for virtual tables * [`c9692798`](cockroachdb/pebble@c9692798) db: add some tests for compression stats Release note: none. Epic: none. #### storage: bump Pebble format version Start using the latest Pebble format version. Epic: none Release note: None 151537: workload: add a contention option to KV r=miraradeva a=miraradeva This commit adds a new set of flags to the KV workload to simulate long-running writing transactions. - `--long-running-txn`, when true, enables this option. - `--long-running-txn-num-writes` specifies the number of writes the long-running transaction performs. Even though each long-running write transaction performs multiple writes, for simplicity, it counts for a single write from the perspective of `--read-percent`. This new option also works with the other write options: `--sfu-writes` and `--sel1-writes`. In those cases, in addition to performing multiple writes, each of the writes is preceded by a `SELECT` and a sleep, configured as before. Fixes: #151038 Release note: None Co-authored-by: Radu Berinde <[email protected]> Co-authored-by: Mira Radeva <[email protected]>
3 parents bb8c1eb + 61fda6b + 7cede69 commit 65c856a

File tree

6 files changed

+87
-60
lines changed

6 files changed

+87
-60
lines changed

docs/generated/settings/settings-for-tenants.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,4 +420,4 @@ trace.zipkin.collector string the address of a Zipkin instance to receive trace
420420
ui.database_locality_metadata.enabled boolean true if enabled shows extended locality data about databases and tables in DB Console which can be expensive to compute application
421421
ui.default_timezone string the default timezone used to format timestamps in the ui application
422422
ui.display_timezone enumeration etc/utc the timezone used to format timestamps in the ui. This setting is deprecatedand will be removed in a future version. Use the 'ui.default_timezone' setting instead. 'ui.default_timezone' takes precedence over this setting. [etc/utc = 0, america/new_york = 1] application
423-
version version 1000025.3-upgrading-to-1000025.4-step-004 set the active cluster version in the format '<major>.<minor>' application
423+
version version 1000025.3-upgrading-to-1000025.4-step-006 set the active cluster version in the format '<major>.<minor>' application

docs/generated/settings/settings.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,6 @@
378378
<tr><td><div id="setting-ui-database-locality-metadata-enabled" class="anchored"><code>ui.database_locality_metadata.enabled</code></div></td><td>boolean</td><td><code>true</code></td><td>if enabled shows extended locality data about databases and tables in DB Console which can be expensive to compute</td><td>Serverless/Dedicated/Self-Hosted</td></tr>
379379
<tr><td><div id="setting-ui-default-timezone" class="anchored"><code>ui.default_timezone</code></div></td><td>string</td><td><code></code></td><td>the default timezone used to format timestamps in the ui</td><td>Serverless/Dedicated/Self-Hosted</td></tr>
380380
<tr><td><div id="setting-ui-display-timezone" class="anchored"><code>ui.display_timezone</code></div></td><td>enumeration</td><td><code>etc/utc</code></td><td>the timezone used to format timestamps in the ui. This setting is deprecatedand will be removed in a future version. Use the &#39;ui.default_timezone&#39; setting instead. &#39;ui.default_timezone&#39; takes precedence over this setting. [etc/utc = 0, america/new_york = 1]</td><td>Serverless/Dedicated/Self-Hosted</td></tr>
381-
<tr><td><div id="setting-version" class="anchored"><code>version</code></div></td><td>version</td><td><code>1000025.3-upgrading-to-1000025.4-step-004</code></td><td>set the active cluster version in the format &#39;&lt;major&gt;.&lt;minor&gt;&#39;</td><td>Serverless/Dedicated/Self-Hosted</td></tr>
381+
<tr><td><div id="setting-version" class="anchored"><code>version</code></div></td><td>version</td><td><code>1000025.3-upgrading-to-1000025.4-step-006</code></td><td>set the active cluster version in the format &#39;&lt;major&gt;.&lt;minor&gt;&#39;</td><td>Serverless/Dedicated/Self-Hosted</td></tr>
382382
</tbody>
383383
</table>

pkg/cli/testdata/ear-list

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ list
88
000004.log:
99
env type: Data, AES128_CTR
1010
keyID: bbb65a9d114c2a18740f27b6933b74f61018bd5adf545c153b48ffe6473336ef
11-
nonce: 31 d3 cd 5a 69 e2 13 64 21 53 57 64
12-
counter: 3952287331
11+
nonce: 86 a7 78 ad 4b da 62 56 d5 e2 d1 70
12+
counter: 798955289
1313
000005.sst:
1414
env type: Data, AES128_CTR
1515
keyID: bbb65a9d114c2a18740f27b6933b74f61018bd5adf545c153b48ffe6473336ef
16-
nonce: 23 d9 b2 e1 39 b0 87 ed f9 6d 49 20
17-
counter: 3481614039
16+
nonce: d1 05 79 53 68 35 a0 f1 44 01 22 79
17+
counter: 1497766936
1818
COCKROACHDB_DATA_KEYS_000001_monolith:
1919
env type: Store, AES128_CTR
2020
keyID: f594229216d81add7811c4360212eb7629b578ef4eab6e5d05679b3c5de48867
@@ -35,11 +35,11 @@ marker.datakeys.000001.COCKROACHDB_DATA_KEYS_000001_monolith:
3535
keyID: f594229216d81add7811c4360212eb7629b578ef4eab6e5d05679b3c5de48867
3636
nonce: 55 d7 d4 27 6c 97 9b dd f1 5d 40 c8
3737
counter: 467030050
38-
marker.format-version.000011.024:
38+
marker.format-version.000013.026:
3939
env type: Data, AES128_CTR
4040
keyID: bbb65a9d114c2a18740f27b6933b74f61018bd5adf545c153b48ffe6473336ef
41-
nonce: c3 6d b2 7b 3f 3e 67 b9 28 b9 81 b1
42-
counter: 3050109376
41+
nonce: 23 d9 b2 e1 39 b0 87 ed f9 6d 49 20
42+
counter: 3481614039
4343
marker.manifest.000001.MANIFEST-000001:
4444
env type: Data, AES128_CTR
4545
keyID: bbb65a9d114c2a18740f27b6933b74f61018bd5adf545c153b48ffe6473336ef

pkg/clusterversion/cockroach_versions.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,9 @@ const (
210210
// constructing the split write batch.
211211
V25_4_WriteInitialTruncStateBeforeSplitApplication
212212

213+
// V25_4_PebbleFormatV2BlobFiles bumps the pebble format to FormatV2BlobFiles.
214+
V25_4_PebbleFormatV2BlobFiles
215+
213216
// *************************************************
214217
// Step (1) Add new versions above this comment.
215218
// Do not add new versions to a patch release.
@@ -263,6 +266,7 @@ var versionTable = [numKeys]roachpb.Version{
263266
V25_4_Start: {Major: 25, Minor: 3, Internal: 2},
264267

265268
V25_4_WriteInitialTruncStateBeforeSplitApplication: {Major: 25, Minor: 3, Internal: 4},
269+
V25_4_PebbleFormatV2BlobFiles: {Major: 25, Minor: 3, Internal: 6},
266270

267271
// *************************************************
268272
// Step (2): Add new versions above this comment.

pkg/storage/pebble.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2326,8 +2326,9 @@ func (p *Pebble) CreateCheckpoint(dir string, spans []roachpb.Span) error {
23262326
// named version, it can be assumed all *nodes* have ratcheted to the pebble
23272327
// version associated with it, since they did so during the fence version.
23282328
var pebbleFormatVersionMap = map[clusterversion.Key]pebble.FormatMajorVersion{
2329-
clusterversion.V25_3: pebble.FormatValueSeparation,
2330-
clusterversion.V25_2: pebble.FormatTableFormatV6,
2329+
clusterversion.V25_4_PebbleFormatV2BlobFiles: pebble.FormatV2BlobFiles,
2330+
clusterversion.V25_3: pebble.FormatValueSeparation,
2331+
clusterversion.V25_2: pebble.FormatTableFormatV6,
23312332
}
23322333

23332334
// MinimumSupportedFormatVersion is the version that provides features that the

pkg/workload/kv/kv.go

Lines changed: 71 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ type kv struct {
8383
sequential bool
8484
zipfian bool
8585
sfuDelay time.Duration
86+
longRunningTxn bool
87+
longRunningTxnNumWrites int
8688
splits int
8789
scatter bool
8890
secondaryIndex bool
@@ -119,18 +121,20 @@ var kvMeta = workload.Meta{
119121
g := &kv{}
120122
g.flags.FlagSet = pflag.NewFlagSet(`kv`, pflag.ContinueOnError)
121123
g.flags.Meta = map[string]workload.FlagMeta{
122-
`batch`: {RuntimeOnly: true},
123-
`sfu-wait-delay`: {RuntimeOnly: true},
124-
`sfu-writes`: {RuntimeOnly: true},
125-
`read-percent`: {RuntimeOnly: true},
126-
`span-percent`: {RuntimeOnly: true},
127-
`span-limit`: {RuntimeOnly: true},
128-
`del-percent`: {RuntimeOnly: true},
129-
`splits`: {RuntimeOnly: true},
130-
`scatter`: {RuntimeOnly: true},
131-
`timeout`: {RuntimeOnly: true},
132-
`prepare-read-only`: {RuntimeOnly: true},
133-
`sel1-writes`: {RuntimeOnly: true},
124+
`batch`: {RuntimeOnly: true},
125+
`sfu-wait-delay`: {RuntimeOnly: true},
126+
`sfu-writes`: {RuntimeOnly: true},
127+
`long-running-txn`: {RuntimeOnly: true},
128+
`long-running-txn-num-writes`: {RuntimeOnly: true},
129+
`read-percent`: {RuntimeOnly: true},
130+
`span-percent`: {RuntimeOnly: true},
131+
`span-limit`: {RuntimeOnly: true},
132+
`del-percent`: {RuntimeOnly: true},
133+
`splits`: {RuntimeOnly: true},
134+
`scatter`: {RuntimeOnly: true},
135+
`timeout`: {RuntimeOnly: true},
136+
`prepare-read-only`: {RuntimeOnly: true},
137+
`sel1-writes`: {RuntimeOnly: true},
134138
}
135139
g.flags.IntVar(&g.batchSize, `batch`, 1,
136140
`Number of blocks to read/insert in a single SQL statement.`)
@@ -187,6 +191,13 @@ var kvMeta = workload.Meta{
187191
g.flags.BoolVar(&g.prepareReadOnly, `prepare-read-only`, false, `Prepare and perform only read statements.`)
188192
g.flags.BoolVar(&g.writesUseSelect1, `sel1-writes`, false,
189193
`Use SELECT 1 as the first statement of transactional writes with a sleep after SELECT 1.`)
194+
g.flags.BoolVar(&g.longRunningTxn, `long-running-txn`, false,
195+
`Use a long-running transaction for running lock contention scenarios. If run with `+
196+
`--sfu-writes or --sel1-writes, it will use those writes in the long-running transaction; `+
197+
`otherwise, it will use regular writes. Each long-running write transaction counts for a`+
198+
`single write, as measured by --read-percent.`)
199+
g.flags.IntVar(&g.longRunningTxnNumWrites, `long-running-txn-num-writes`, 10,
200+
`Number of writes in the long-running transaction when using --long-running-txn.`)
190201
g.connFlags = workload.NewConnFlags(&g.flags)
191202
return g
192203
},
@@ -670,23 +681,26 @@ func (o *kvOp) run(ctx context.Context) (retErr error) {
670681
o.hists.Get(`span`).Record(elapsed)
671682
return err
672683
}
673-
const argCount = 2
674-
writeArgs := make([]interface{}, argCount*o.config.batchSize)
675-
var sfuArgs []interface{}
676-
if o.config.writesUseSelectForUpdate {
677-
sfuArgs = make([]interface{}, o.config.batchSize)
678-
}
679-
for i := 0; i < o.config.batchSize; i++ {
680-
j := i * argCount
681-
writeArgs[j+0] = o.t.getKey(o.g.writeKey())
682-
if sfuArgs != nil {
683-
sfuArgs[i] = writeArgs[j]
684+
makeWriteBatchArgs := func() ([]interface{}, []interface{}) {
685+
const argCount = 2
686+
writeArgs := make([]interface{}, argCount*o.config.batchSize)
687+
var sfuArgs []interface{}
688+
if o.config.writesUseSelectForUpdate {
689+
sfuArgs = make([]interface{}, o.config.batchSize)
690+
}
691+
for i := 0; i < o.config.batchSize; i++ {
692+
j := i * argCount
693+
writeArgs[j+0] = o.t.getKey(o.g.writeKey())
694+
if sfuArgs != nil {
695+
sfuArgs[i] = writeArgs[j]
696+
}
697+
writeArgs[j+1] = o.config.randBlock(o.g.rand())
684698
}
685-
writeArgs[j+1] = o.config.randBlock(o.g.rand())
699+
return writeArgs, sfuArgs
686700
}
687701
start := timeutil.Now()
688702
var err error
689-
if o.config.writesUseSelect1 || o.config.writesUseSelectForUpdate {
703+
if o.config.writesUseSelect1 || o.config.writesUseSelectForUpdate || o.config.longRunningTxn {
690704
// We could use crdb.ExecuteTx, but we avoid retries in this workload so
691705
// that each run call makes 1 attempt, so that rate limiting in workerRun
692706
// behaves as expected.
@@ -695,44 +709,52 @@ func (o *kvOp) run(ctx context.Context) (retErr error) {
695709
if err != nil {
696710
return err
697711
}
698-
699712
defer func() {
700713
rollbackErr := tx.Rollback(ctx)
701714
if !errors.Is(rollbackErr, pgx.ErrTxClosed) {
702715
retErr = errors.CombineErrors(retErr, rollbackErr)
703716
}
704717
}()
705-
if o.config.writesUseSelect1 {
706-
rows, err := o.sel1Stmt.QueryTx(ctx, tx)
707-
if err != nil {
708-
return err
709-
}
710-
rows.Close()
711-
if err = rows.Err(); err != nil {
712-
return err
713-
}
718+
iterations := 1
719+
if o.config.longRunningTxn {
720+
iterations = o.config.longRunningTxnNumWrites
714721
}
715-
if o.config.writesUseSelectForUpdate {
716-
rows, err := o.sfuStmt.QueryTx(ctx, tx, sfuArgs...)
717-
if err != nil {
718-
return err
722+
for i := 0; i < iterations; i++ {
723+
writeArgs, sfuArgs := makeWriteBatchArgs()
724+
if o.config.writesUseSelect1 {
725+
rows, err := o.sel1Stmt.QueryTx(ctx, tx)
726+
if err != nil {
727+
return err
728+
}
729+
rows.Close()
730+
if err = rows.Err(); err != nil {
731+
return err
732+
}
733+
}
734+
if o.config.writesUseSelectForUpdate {
735+
rows, err := o.sfuStmt.QueryTx(ctx, tx, sfuArgs...)
736+
if err != nil {
737+
return err
738+
}
739+
rows.Close()
740+
if err = rows.Err(); err != nil {
741+
// The transaction may have experienced an error in the meantime.
742+
return o.tryHandleWriteErr("write-write-err", start, err)
743+
}
719744
}
720-
rows.Close()
721-
if err = rows.Err(); err != nil {
722-
return err
745+
// Simulate a transaction that does other work between the sel1 / SFU and write.
746+
time.Sleep(o.config.sfuDelay)
747+
if _, err = o.writeStmt.ExecTx(ctx, tx, writeArgs...); err != nil {
748+
// Multiple write transactions can contend and encounter
749+
// a serialization failure. We swallow such an error.
750+
return o.tryHandleWriteErr("write-write-err", start, err)
723751
}
724752
}
725-
// Simulate a transaction that does other work between the sel1 / SFU and write.
726-
time.Sleep(o.config.sfuDelay)
727-
if _, err = o.writeStmt.ExecTx(ctx, tx, writeArgs...); err != nil {
728-
// Multiple write transactions can contend and encounter
729-
// a serialization failure. We swallow such an error.
730-
return o.tryHandleWriteErr("write-write-err", start, err)
731-
}
732753
if err = tx.Commit(ctx); err != nil {
733754
return o.tryHandleWriteErr("write-commit-err", start, err)
734755
}
735756
} else {
757+
writeArgs, _ := makeWriteBatchArgs()
736758
_, err = o.writeStmt.Exec(ctx, writeArgs...)
737759
}
738760
if err != nil {

0 commit comments

Comments
 (0)