Skip to content

Commit

Permalink
txnidcache: disable cache by default
Browse files Browse the repository at this point in the history
See cockroachdb#76738.

Release note: None
  • Loading branch information
tbg authored and RajivTS committed Mar 6, 2022
1 parent 1069743 commit 9d66119
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion docs/generated/settings/settings-for-tenants.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ server.web_session.purge.max_deletions_per_cycle integer 10 the maximum number o
server.web_session.purge.period duration 1h0m0s the time until old sessions are deleted
server.web_session.purge.ttl duration 1h0m0s if nonzero, entries in system.web_sessions older than this duration are periodically purged
server.web_session_timeout duration 168h0m0s the duration that a newly created web session will be valid
sql.contention.txn_id_cache.max_size byte size 64 MiB the maximum byte size TxnID cache will use (set to 0 to disable)
sql.contention.txn_id_cache.max_size byte size 0 B the maximum byte size TxnID cache will use (set to 0 to disable)
sql.cross_db_fks.enabled boolean false if true, creating foreign key references across databases is allowed
sql.cross_db_sequence_owners.enabled boolean false if true, creating sequences owned by tables from other databases is allowed
sql.cross_db_sequence_references.enabled boolean false if true, sequences referenced by tables from other databases are allowed
Expand Down
2 changes: 1 addition & 1 deletion docs/generated/settings/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
<tr><td><code>server.web_session.purge.period</code></td><td>duration</td><td><code>1h0m0s</code></td><td>the time until old sessions are deleted</td></tr>
<tr><td><code>server.web_session.purge.ttl</code></td><td>duration</td><td><code>1h0m0s</code></td><td>if nonzero, entries in system.web_sessions older than this duration are periodically purged</td></tr>
<tr><td><code>server.web_session_timeout</code></td><td>duration</td><td><code>168h0m0s</code></td><td>the duration that a newly created web session will be valid</td></tr>
<tr><td><code>sql.contention.txn_id_cache.max_size</code></td><td>byte size</td><td><code>64 MiB</code></td><td>the maximum byte size TxnID cache will use (set to 0 to disable)</td></tr>
<tr><td><code>sql.contention.txn_id_cache.max_size</code></td><td>byte size</td><td><code>0 B</code></td><td>the maximum byte size TxnID cache will use (set to 0 to disable)</td></tr>
<tr><td><code>sql.cross_db_fks.enabled</code></td><td>boolean</td><td><code>false</code></td><td>if true, creating foreign key references across databases is allowed</td></tr>
<tr><td><code>sql.cross_db_sequence_owners.enabled</code></td><td>boolean</td><td><code>false</code></td><td>if true, creating sequences owned by tables from other databases is allowed</td></tr>
<tr><td><code>sql.cross_db_sequence_references.enabled</code></td><td>boolean</td><td><code>false</code></td><td>if true, sequences referenced by tables from other databases are allowed</td></tr>
Expand Down
9 changes: 9 additions & 0 deletions pkg/ccl/serverccl/statusccl/tenant_status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ func TestTenantStatusAPI(t *testing.T) {
testHelper := newTestTenantHelper(t, 3 /* tenantClusterSize */, knobs)
defer testHelper.cleanup(ctx, t)

for _, conn := range []*sqlutils.SQLRunner{
sqlutils.MakeSQLRunner(testHelper.hostCluster.ServerConn(0)),
testHelper.testCluster().tenantConn(0),
} {
conn.Exec(
t, "SET CLUSTER SETTING sql.contention.txn_id_cache.max_size = '10MB'",
)
}

t.Run("reset_sql_stats", func(t *testing.T) {
testResetSQLStatsRPCForTenant(ctx, t, testHelper)
})
Expand Down
3 changes: 2 additions & 1 deletion pkg/sql/contention/txnidcache/cluster_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ var MaxSize = settings.RegisterByteSizeSetting(
settings.TenantWritable,
`sql.contention.txn_id_cache.max_size`,
"the maximum byte size TxnID cache will use (set to 0 to disable)",
64*1024*1024, // 64 MB
// See https://github.com/cockroachdb/cockroach/issues/76738.
0,
).WithPublic()
2 changes: 1 addition & 1 deletion pkg/sql/contention/txnidcache/txn_id_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ func TestTransactionIDCache(t *testing.T) {
})

t.Run("provisional_txn_id_cache_record", func(t *testing.T) {
testConn.Exec(t, "RESET CLUSTER SETTING sql.contention.txn_id_cache.max_size")
testConn.Exec(t, "SET CLUSTER SETTING sql.contention.txn_id_cache.max_size = '10MB'")
callCaptured := uint32(0)

injector.setHook(func(
Expand Down
4 changes: 3 additions & 1 deletion pkg/sql/contention/txnidcache/writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ func TestTxnIDCacheCanBeDisabledViaClusterSetting(t *testing.T) {
st := cluster.MakeTestingClusterSettings()
ctx := context.Background()

MaxSize.Override(ctx, &st.SV, 1<<10)

sink := &counterSink{}
w := newWriter(st, sink)
w.Record(contentionpb.ResolvedTxnID{
Expand All @@ -191,7 +193,7 @@ func TestTxnIDCacheCanBeDisabledViaClusterSetting(t *testing.T) {
require.Equal(t, 1, sink.numOfRecord)

// This should re-enable txn id cache.
MaxSize.Override(ctx, &st.SV, MaxSize.Default())
MaxSize.Override(ctx, &st.SV, 1<<10)

w.Record(contentionpb.ResolvedTxnID{
TxnID: uuid.FastMakeV4(),
Expand Down

0 comments on commit 9d66119

Please sign in to comment.