Skip to content

Commit d276833

Browse files
craig[bot]rafiss
andcommitted
Merge #140400
140400: spanconfigreconciler: use fixed timestamp when reading descriptors r=rafiss a=rafiss Recently when we changed the default value of autocommit_before_ddl to true, we found that the chance of hitting a retry error while running schema changes dramatically increased. The reason was because the backgound span reconciler would need locks for the same keys that were being modified by the schema change job itself -- most notably, the descriptor table and descriptor ID sequence. This patch addresses the issue by making the spanconfig reconciler use the checkpoint timestamp from the rangefeed as the fixed timestamp for the transaction that reads the descriptors whose spans are being reconciled. This defensive measure helps us avoid any possibility of contention caused by this background job's transaction. This allows us to re-enable the autocommit setting for logictests that run in multitenancy. fixes #140172 Release note: None Co-authored-by: Rafi Shamim <[email protected]>
2 parents bd25b0e + 5c5ffc5 commit d276833

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

pkg/spanconfig/spanconfigreconciler/reconciler.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,16 @@ func (r *incrementalReconciler) reconcile(
522522
) error {
523523
var err error
524524

525+
// Using a fixed timestamp prevents this background job from contending
526+
// with foreground schema change traffic. Schema changes modify system
527+
// objects like system.descriptor, system.descriptor_id_seq, and
528+
// system.span_count. The spanconfig reconciler needs to read these
529+
// objects also. A fixed timestamp is a defensive measure to help
530+
// avoid contention caused by this background job.
531+
err = txn.KV().SetFixedTimestamp(ctx, checkpoint)
532+
if err != nil {
533+
return err
534+
}
525535
// TODO(irfansharif): Instead of these filter methods for missing
526536
// tables and system targets that live on the Reconciler, we could
527537
// move this to the SQLTranslator instead, now that the SQLTranslator

pkg/sql/logictest/logic.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1683,16 +1683,6 @@ func (t *logicTest) newCluster(
16831683
tenantID := serverutils.TestTenantID()
16841684
conn := t.cluster.SystemLayer(0).SQLConn(t.rootT)
16851685

1686-
// TODO(rafi): Remove this setting. We're adding it since the 3node-tenant
1687-
// config seem to be flaky with autcommit_before_ddl = true. Disable that
1688-
// setting for multitenant configs while the issue is being investigated.
1689-
if _, err := conn.Exec(
1690-
"ALTER TENANT [$1] SET CLUSTER SETTING sql.defaults.autocommit_before_ddl.enabled = false",
1691-
tenantID.ToUint64(),
1692-
); err != nil {
1693-
t.Fatal(err)
1694-
}
1695-
16961686
clusterSettings := toa.clusterSettings
16971687
if len(clusterSettings) > 0 {
16981688
// We reduce the closed timestamp duration on the host tenant so that the

0 commit comments

Comments
 (0)