Skip to content

Commit

Permalink
Merge pull request #130525 from cockroachdb/blathers/backport-staging…
Browse files Browse the repository at this point in the history
…-v23.2.11-129517

staging-v23.2.11: sql: override StmtTimeout to 0 for sessionless IE
  • Loading branch information
celiala authored Sep 12, 2024
2 parents 275629c + 5f5a5c3 commit c52ebc8
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 88 deletions.
4 changes: 0 additions & 4 deletions pkg/server/server_sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -1217,10 +1217,6 @@ func newSQLServer(ctx context.Context, cfg sqlServerArgs) (*SQLServer, error) {

// Job internal operations use the node principal.
sd.UserProto = username.NodeUserName().EncodeProto()

// The following should not apply to SQL operations performed by the jobs
// subsystem.
sd.StmtTimeout = 0
})
jobRegistry.SetInternalDB(jobsInternalDB)

Expand Down
1 change: 1 addition & 0 deletions pkg/sql/internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ func NewInternalSessionData(
sd.SearchPath = sessiondata.DefaultSearchPathForUser(username.NodeUserName())
sd.SequenceState = sessiondata.NewSequenceState()
sd.Location = time.UTC
sd.StmtTimeout = 0
return sd
}

Expand Down
34 changes: 34 additions & 0 deletions pkg/sql/opt/exec/execbuilder/testdata/execute_internally_builtin
Original file line number Diff line number Diff line change
Expand Up @@ -215,3 +215,37 @@ root

statement ok
SELECT crdb_internal.execute_internally('EXPLAIN ANALYZE SELECT 1;');

# Ensure that StmtTimeout for a session-independent IE cannot be overriden.
subtest stmt_timeout

statement ok
SET CLUSTER SETTING sql.defaults.statement_timeout = '36000000ms';

statement ok
SET statement_timeout = '39600000ms';

query T
SELECT crdb_internal.execute_internally('SHOW statement_timeout;');
----
0

# Ensure that a session-bound IE still inherits from session vars, if available;
# otherwise, it inherits from the cluster setting.
query T
SELECT crdb_internal.execute_internally('SHOW statement_timeout;', true);
----
39600000

statement ok
RESET statement_timeout;

query T
SELECT crdb_internal.execute_internally('SHOW statement_timeout;', true);
----
36000000

statement ok
RESET CLUSTER SETTING sql.defaults.statement_timeout;

subtest end
1 change: 0 additions & 1 deletion pkg/sql/tests/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ go_test(
"hash_sharded_test.go",
"impure_builtin_test.go",
"inverted_index_test.go",
"job_statement_timeout_test.go",
"kv_test.go",
"main_test.go",
"max_open_txns_test.go",
Expand Down
83 changes: 0 additions & 83 deletions pkg/sql/tests/job_statement_timeout_test.go

This file was deleted.

0 comments on commit c52ebc8

Please sign in to comment.