Skip to content

Commit

Permalink
storage,server: enable separated intents
Browse files Browse the repository at this point in the history
Separated intents are enabled by default, and the setting
is randomized on the testing path for testserver.go.

The intent resolution performance, which caused these
to be disabled, has been improved due to
cockroachdb#60622 and
cockroachdb#60698

TestLogic/aggregate is tweaked to reduce the number of
intents created, as explained in the TODO added where
the change was made. The fk and upsert tests also
use higher kv.transaction.max_intents_bytes.

Informs cockroachdb#41720

Release note (ops change): The default value of the
storage.transaction.separated_intents.enabled cluster
setting is changed to true.
  • Loading branch information
sumeerbhola committed Feb 23, 2021
1 parent bdcdf88 commit b3f4d2b
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 14 deletions.
11 changes: 8 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ SUBTESTS :=
LINTTIMEOUT := 30m

## Test timeout to use for regular tests.
TESTTIMEOUT := 30m
TESTTIMEOUT := 2h

## Test timeout to use for race tests.
RACETIMEOUT := 30m
Expand Down Expand Up @@ -1058,11 +1058,16 @@ bench benchshort: TESTTIMEOUT := $(BENCHTIMEOUT)
# that longer running benchmarks can skip themselves.
benchshort: override TESTFLAGS += -benchtime=1ns -short

.PHONY: check test testshort testrace testlogic testbaselogic testccllogic testoptlogic bench benchshort
.PHONY: test
test: ## Run tests.
check test testshort testrace bench benchshort:
test:
$(xgo) test $(GOTESTFLAGS) $(GOFLAGS) $(GOMODVENDORFLAGS) -tags '$(TAGS)' -ldflags '$(LINKFLAGS)' -run "TestLogic" $(if $(BENCHES),-bench "$(BENCHES)") -cpuprofile ./artifacts/$@_logic_cpu.prof -memprofile ./artifacts/$@_logic_mem.prof -timeout $(TESTTIMEOUT) ./pkg/sql/logictest $(TESTFLAGS)

.PHONY: check testshort testrace testlogic testbaselogic testccllogic testoptlogic bench benchshort
check testshort testrace bench benchshort:
$(xgo) test $(GOTESTFLAGS) $(GOFLAGS) $(GOMODVENDORFLAGS) -tags '$(TAGS)' -ldflags '$(LINKFLAGS)' -run "$(TESTS)" $(if $(BENCHES),-bench "$(BENCHES)") -timeout $(TESTTIMEOUT) $(PKG) $(TESTFLAGS)


.PHONY: stress stressrace
stress: ## Run tests under stress.
stressrace: ## Run tests under stress with the race detector enabled.
Expand Down
1 change: 1 addition & 0 deletions pkg/server/settingswatcher/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ go_test(
"//pkg/settings",
"//pkg/settings/cluster",
"//pkg/sql",
"//pkg/storage",
"//pkg/testutils",
"//pkg/testutils/serverutils",
"//pkg/testutils/sqlutils",
Expand Down
5 changes: 5 additions & 0 deletions pkg/server/settingswatcher/settings_watcher_external_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/settings"
"github.com/cockroachdb/cockroach/pkg/settings/cluster"
"github.com/cockroachdb/cockroach/pkg/sql"
"github.com/cockroachdb/cockroach/pkg/storage"
"github.com/cockroachdb/cockroach/pkg/testutils"
"github.com/cockroachdb/cockroach/pkg/testutils/sqlutils"
"github.com/cockroachdb/cockroach/pkg/testutils/testcluster"
Expand Down Expand Up @@ -92,6 +93,10 @@ func TestSettingWatcher(t *testing.T) {
s0.ExecutorConfig().(sql.ExecutorConfig).RangeFeedFactory,
tc.Stopper())
require.NoError(t, sw.Start(ctx))
// TestCluster randomizes the value of SeparatedIntentsEnabled, so set it to
// the same as in fakeSettings for the subsequent equality check.
storage.SeparatedIntentsEnabled.Override(
&s0.ClusterSettings().SV, storage.SeparatedIntentsEnabled.Get(&fakeSettings.SV))
require.NoError(t, checkSettingsValuesMatch(s0.ClusterSettings(), fakeSettings))
for k, v := range toSet {
tdb.Exec(t, "SET CLUSTER SETTING "+k+" = $1", v[1])
Expand Down
9 changes: 4 additions & 5 deletions pkg/server/testserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,11 @@ func makeTestConfigFromParams(params base.TestServerArgs) Config {
st := params.Settings
if params.Settings == nil {
st = cluster.MakeClusterSettings()
// TODO(sumeer): re-introduce this randomization.
// enabledSeparated := rand.Intn(2) == 0
// log.Infof(context.Background(),
// "test Config is randomly setting enabledSeparated: %t",
// enabledSeparated)
// storage.SeparatedIntentsEnabled.Override(&st.SV, enabledSeparated)
enabledSeparated := true
log.Infof(context.Background(),
"test Config is randomly setting enabledSeparated: %t", enabledSeparated)
storage.SeparatedIntentsEnabled.Override(&st.SV, enabledSeparated)
}
st.ExternalIODir = params.ExternalIODir
cfg := makeTestConfig(st)
Expand Down
22 changes: 17 additions & 5 deletions pkg/sql/logictest/testdata/logic_test/aggregate
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
subtest other

# Reduce the need for ranged intent resolution, since the test environment
# tends to accumulate lots of un-compacted intent tombstones that can slow it
# down.
statement ok
SET CLUSTER SETTING kv.transaction.max_intents_bytes = '1048576'

statement ok
CREATE TABLE kv (
k INT PRIMARY KEY,
Expand Down Expand Up @@ -892,32 +898,38 @@ CREATE TABLE mnop (
p BIGINT
)

# TODO(sumeer): increase this series back to 2e4 once we have more performance
# improvements to ranged intent resolution. This test is somewhat artificial
# in that it accumulates a large number of deletion markers for intents for
# each key, in the LSM memtable, without them being flushed to ssts. This
# slows down ranged intent resolution. With 1e4 keys, the txn tracks each
# intent individually, and intent resolution is fast.
statement ok
INSERT INTO mnop (m, n) SELECT i, (1e9 + i/2e4)::float FROM
generate_series(1, 2e4) AS i(i)
generate_series(1, 5e3) AS i(i)

statement ok
UPDATE mnop SET o = n::decimal, p = (n * 10)::bigint

query RRR
SELECT round(variance(n), 2), round(variance(n), 2), round(variance(p)) FROM mnop
----
0.08 0.08 8
0.01 0.01 1

query RRR
SELECT round(var_pop(n), 2), round(var_pop(n), 2), round(var_pop(p)) FROM mnop
----
0.08 0.08 8
0.01 0.01 1

query RRR
SELECT round(stddev_samp(n), 2), round(stddev(n), 2), round(stddev_samp(p)) FROM mnop
----
0.29 0.29 3
0.07 0.07 1

query RRR
SELECT round(stddev_pop(n), 2), round(stddev_pop(n), 2), round(stddev_pop(p)) FROM mnop
----
0.29 0.29 3
0.07 0.07 1

query RRR
SELECT avg(1::int)::float, avg(2::float)::float, avg(3::decimal)::float
Expand Down
6 changes: 6 additions & 0 deletions pkg/sql/logictest/testdata/logic_test/fk
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# LogicTest: !3node-tenant(49854)

# Reduce the need for ranged intent resolution, since the test environment
# tends to accumulate lots of un-compacted intent tombstones that can slow it
# down.
statement ok
SET CLUSTER SETTING kv.transaction.max_intents_bytes = "1048576"

statement ok
SET CLUSTER SETTING sql.cross_db_fks.enabled = TRUE

Expand Down
6 changes: 6 additions & 0 deletions pkg/sql/logictest/testdata/logic_test/upsert
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
subtest strict

# Reduce the need for ranged intent resolution, since the test environment
# tends to accumulate lots of un-compacted intent tombstones that can slow it
# down.
statement ok
SET CLUSTER SETTING kv.transaction.max_intents_bytes = "1048576"

statement ok
CREATE TABLE ex(
foo INT PRIMARY KEY,
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/intent_reader_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ var SeparatedIntentsEnabled = settings.RegisterBoolSetting(
"storage.transaction.separated_intents.enabled",
"if enabled, intents will be written to a separate lock table, instead of being "+
"interleaved with MVCC values",
false,
true,
)

// This file defines wrappers for Reader and Writer, and functions to do the
Expand Down

0 comments on commit b3f4d2b

Please sign in to comment.