Skip to content

Commit 2e0325c

Browse files
committed
sql: add session seting for leaf txn admission control behavior
This commit adds a `propagate_admission_header_to_leaf_transactions` session setting to control whether leaf txns inherit the admission header from root txns. The setting is on by default. Informs #144421 Release note: None
1 parent c7159d5 commit 2e0325c

File tree

8 files changed

+50
-1
lines changed

8 files changed

+50
-1
lines changed

pkg/sql/distsql_running.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ func (dsp *DistSQLPlanner) setupFlows(
470470
setupReq.JobTag = jobTag.ValueStr()
471471
}
472472
}
473-
if localState.Txn != nil {
473+
if evalCtx.SessionData().PropagateAdmissionHeaderToLeafTransactions && localState.Txn != nil {
474474
// Propagate the admission control header so that leaf transactions
475475
// correctly inherit it.
476476
setupReq.LeafTxnAdmissionHeader = localState.Txn.AdmissionHeader()

pkg/sql/exec_util.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4178,6 +4178,10 @@ func (m *sessionDataMutator) SetVectorSearchBeamSize(val int32) {
41784178
m.data.VectorSearchBeamSize = val
41794179
}
41804180

4181+
func (m *sessionDataMutator) SetPropagateAdmissionHeaderToLeafTransactions(val bool) {
4182+
m.data.PropagateAdmissionHeaderToLeafTransactions = val
4183+
}
4184+
41814185
// Utility functions related to scrubbing sensitive information on SQL Stats.
41824186

41834187
// quantizeCounts ensures that the Count field in the

pkg/sql/logictest/testdata/logic_test/information_schema

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4055,6 +4055,7 @@ plan_cache_mode auto
40554055
plpgsql_use_strict_into off
40564056
prefer_lookup_joins_for_fks off
40574057
prepared_statements_cache_size 0 B
4058+
propagate_admission_header_to_leaf_transactions on
40584059
propagate_input_ordering off
40594060
recursion_depth_limit 1000
40604061
register_latch_wait_contention_events off

pkg/sql/logictest/testdata/logic_test/pg_catalog

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3064,6 +3064,7 @@ plan_cache_mode auto N
30643064
plpgsql_use_strict_into off NULL NULL NULL string
30653065
prefer_lookup_joins_for_fks off NULL NULL NULL string
30663066
prepared_statements_cache_size 0 B NULL NULL NULL string
3067+
propagate_admission_header_to_leaf_transactions on NULL NULL NULL string
30673068
propagate_input_ordering off NULL NULL NULL string
30683069
recursion_depth_limit 1000 NULL NULL NULL string
30693070
register_latch_wait_contention_events off NULL NULL NULL string
@@ -3284,6 +3285,7 @@ plan_cache_mode auto N
32843285
plpgsql_use_strict_into off NULL user NULL off off
32853286
prefer_lookup_joins_for_fks off NULL user NULL off off
32863287
prepared_statements_cache_size 0 B NULL user NULL 0 B 0 B
3288+
propagate_admission_header_to_leaf_transactions on NULL user NULL on on
32873289
propagate_input_ordering off NULL user NULL off off
32883290
recursion_depth_limit 1000 NULL user NULL 1000 1000
32893291
register_latch_wait_contention_events off NULL user NULL off off
@@ -3503,6 +3505,7 @@ plan_cache_mode NULL NULL NULL
35033505
plpgsql_use_strict_into NULL NULL NULL NULL NULL
35043506
prefer_lookup_joins_for_fks NULL NULL NULL NULL NULL
35053507
prepared_statements_cache_size NULL NULL NULL NULL NULL
3508+
propagate_admission_header_to_leaf_transactions NULL NULL NULL NULL NULL
35063509
propagate_input_ordering NULL NULL NULL NULL NULL
35073510
recursion_depth_limit NULL NULL NULL NULL NULL
35083511
register_latch_wait_contention_events NULL NULL NULL NULL NULL

pkg/sql/logictest/testdata/logic_test/show_source

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ plan_cache_mode auto
180180
plpgsql_use_strict_into off
181181
prefer_lookup_joins_for_fks off
182182
prepared_statements_cache_size 0 B
183+
propagate_admission_header_to_leaf_transactions on
183184
propagate_input_ordering off
184185
recursion_depth_limit 1000
185186
register_latch_wait_contention_events off

pkg/sql/opt/exec/execbuilder/testdata/lookup_join

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2627,6 +2627,26 @@ SELECT message FROM [SHOW TRACE FOR SESSION] WHERE MESSAGE LIKE 'initializing le
26272627
initializing leaf txn admission control header with priority: user-low-pri
26282628
initializing leaf txn admission control header with priority: user-low-pri
26292629

2630+
# Turning off admission header propagation should result in the old behavior.
2631+
statement ok
2632+
SET propagate_admission_header_to_leaf_transactions = false;
2633+
2634+
statement ok
2635+
SET TRACING = "on", cluster;
2636+
2637+
statement ok
2638+
SELECT small.a, large.c FROM small INNER LOOKUP JOIN large ON small.a = large.b
2639+
2640+
statement ok
2641+
SET TRACING = "off";
2642+
2643+
query T
2644+
SELECT message FROM [SHOW TRACE FOR SESSION] WHERE MESSAGE LIKE 'initializing leaf txn%';
2645+
----
2646+
2647+
statement ok
2648+
RESET propagate_admission_header_to_leaf_transactions;
2649+
26302650
statement ok
26312651
RESET default_transaction_quality_of_service
26322652

pkg/sql/sessiondatapb/local_only_session_data.proto

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,9 @@ message LocalOnlySessionData {
664664
// are considered at each level of the search tree. Higher values increase
665665
// search accuracy but require more processing resources.
666666
int32 vector_search_beam_size = 168;
667+
// PropagateAdmissionHeaderToLeafTransactions, when true, causes leaf
668+
// transactions to inherit the admission header from the root transaction.
669+
bool propagate_admission_header_to_leaf_transactions = 169;
667670
///////////////////////////////////////////////////////////////////////////
668671
// WARNING: consider whether a session parameter you're adding needs to //
669672
// be propagated to the remote nodes. If so, that parameter should live //

pkg/sql/vars.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4001,6 +4001,23 @@ var varGen = map[string]sessionVar{
40014001
return strconv.FormatInt(vecindex.SearchBeamSizeSetting.Get(sv), 10)
40024002
},
40034003
},
4004+
4005+
// CockroachDB extension.
4006+
`propagate_admission_header_to_leaf_transactions`: {
4007+
GetStringVal: makePostgresBoolGetStringValFn(`propagate_admission_header_to_leaf_transactions`),
4008+
Set: func(_ context.Context, m sessionDataMutator, s string) error {
4009+
b, err := paramparse.ParseBoolVar("propagate_admission_header_to_leaf_transactions", s)
4010+
if err != nil {
4011+
return err
4012+
}
4013+
m.SetPropagateAdmissionHeaderToLeafTransactions(b)
4014+
return nil
4015+
},
4016+
Get: func(evalCtx *extendedEvalContext, _ *kv.Txn) (string, error) {
4017+
return formatBoolAsPostgresSetting(evalCtx.SessionData().PropagateAdmissionHeaderToLeafTransactions), nil
4018+
},
4019+
GlobalDefault: globalTrue,
4020+
},
40044021
}
40054022

40064023
func ReplicationModeFromString(s string) (sessiondatapb.ReplicationMode, error) {

0 commit comments

Comments
 (0)