Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhancement] Support insert timeout #50644

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

wyb
Copy link
Contributor

@wyb wyb commented Sep 3, 2024

Why I'm doing:

insert and query use the same query_timeout session variable to control timeout.
but they need different default values, default query_timeout 300s is very small for insert.

What I'm doing:

add a new insert_timeout session variable for insert/update/delete and the default value is 14400s.

you can also set timeout in insert properties for the current insert sql, for example

insert into tbl properties("timeout" = "3600") select ...

if timeout property is not set, insert_timeout session variable will be used.

Fixes #issue

What type of PR is this:

  • BugFix
  • Feature
  • Enhancement
  • Refactor
  • UT
  • Doc
  • Tool

Does this PR entail a change in behavior?

  • Yes, this PR will result in a change in behavior.
  • No, this PR will not result in a change in behavior.

If yes, please specify the type of change:

  • Interface/UI changes: syntax, type conversion, expression evaluation, display information
  • Parameter changes: default values, similar parameters but with different default values
  • Policy changes: use new policy to replace old one, functionality automatically enabled
  • Feature removed
  • Miscellaneous: upgrade & downgrade compatibility, etc.

Checklist:

  • I have added test cases for my bug fix or my new feature
  • This pr needs user documentation (for new or modified features or behaviors)
    • I have added documentation for my new feature or new function
  • This is a backport pr

Bugfix cherry-pick branch check:

  • I have checked the version labels which the pr will be auto-backported to the target branch
    • 3.3
    • 3.2
    • 3.1
    • 3.0
    • 2.5

@wyb wyb requested review from a team as code owners September 3, 2024 15:05
@wyb wyb marked this pull request as draft September 3, 2024 15:05
@mergify mergify bot assigned wyb Sep 3, 2024
@wyb wyb marked this pull request as ready for review September 3, 2024 15:17
@@ -1303,6 +1304,7 @@ private void handleAnalyzeStmt() throws IOException {
// will print warning log if timeout, so we update timeout temporarily to avoid
// warning log
context.getSessionVariable().setQueryTimeoutS((int) Config.statistic_collect_query_timeout);
context.getSessionVariable().setInsertTimeoutS((int) Config.statistic_collect_query_timeout);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the usage here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

analyze job has both query and insert sql, so set query_timeout and insert_timeout

String.format("Query exceeded time limit of %d seconds",
ConnectContext.get().getSessionVariable().getQueryTimeoutS())));
status.setStatus(new Status(TStatusCode.TIMEOUT, ErrorCode.ERR_TIMEOUT.formatErrorMsg(
"Query", timeoutMs / 1000, "please increase the 'query_timeout' session variable")));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

query_timeout only?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, only query uses this.

}

public String getExecType() {
if (parsedStmt instanceof InsertStmt || parsedStmt instanceof CreateTableAsSelectStmt) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not implement it as a method in StatementBase?
And provide a StmtExecType class with DML_INSERT, DML_UPDATE, DML_DELETE, DCL_QUERY

@@ -2689,4 +2693,28 @@ public void addFinishedQueryDetail() {
QueryDetailQueue.addQueryDetail(queryDetail);
}

public int getExecTimeout() {
if (parsedStmt instanceof DmlStmt) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it better to provide a abstract getTimeout method in StatementBase, with some sub-classes implementing it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@wyb wyb force-pushed the ins_timeout branch 2 times, most recently from 10874fd to a76bca3 Compare September 17, 2024 02:48
Signed-off-by: wyb <[email protected]>
Copy link

sonarcloud bot commented Sep 20, 2024

Copy link

[Java-Extensions Incremental Coverage Report]

pass : 0 / 0 (0%)

Copy link

[FE Incremental Coverage Report]

fail : 59 / 79 (74.68%)

file detail

path covered_line new_line coverage not_covered_line_detail
🔵 com/starrocks/datacache/DataCacheSelectExecutor.java 0 1 00.00% [79]
🔵 com/starrocks/scheduler/mv/MVMaintenanceJob.java 0 1 00.00% [270]
🔵 com/starrocks/server/GlobalStateMgr.java 0 1 00.00% [2378]
🔵 com/starrocks/qe/LeaderOpExecutor.java 1 3 33.33% [100, 108]
🔵 com/starrocks/sql/StatementPlanner.java 1 2 50.00% [537]
🔵 com/starrocks/qe/ConnectContext.java 8 15 53.33% [920, 924, 952, 953, 958, 959, 960]
🔵 com/starrocks/sql/ast/DmlStmt.java 3 4 75.00% [71]
🔵 com/starrocks/qe/ResultReceiver.java 6 8 75.00% [152, 153]
🔵 com/starrocks/qe/StmtExecutor.java 18 22 81.82% [2281, 2283, 2289, 2290]
🔵 com/starrocks/scheduler/PartitionBasedMvRefreshProcessor.java 1 1 100.00% []
🔵 com/starrocks/qe/SessionVariable.java 4 4 100.00% []
🔵 com/starrocks/qe/ShortCircuitHybridExecutor.java 1 1 100.00% []
🔵 com/starrocks/sql/analyzer/InsertAnalyzer.java 4 4 100.00% []
🔵 com/starrocks/sql/DeletePlanner.java 1 1 100.00% []
🔵 com/starrocks/common/ErrorCode.java 1 1 100.00% []
🔵 com/starrocks/statistic/StatisticUtils.java 1 1 100.00% []
🔵 com/starrocks/server/NodeMgr.java 1 1 100.00% []
🔵 com/starrocks/sql/UpdatePlanner.java 1 1 100.00% []
🔵 com/starrocks/qe/scheduler/dag/JobSpec.java 1 1 100.00% []
🔵 com/starrocks/sql/analyzer/DeleteAnalyzer.java 1 1 100.00% []
🔵 com/starrocks/sql/analyzer/UpdateAnalyzer.java 1 1 100.00% []
🔵 com/starrocks/catalog/DictionaryMgr.java 1 1 100.00% []
🔵 com/starrocks/sql/ast/StatementBase.java 1 1 100.00% []
🔵 com/starrocks/sql/InsertPlanner.java 1 1 100.00% []
🔵 com/starrocks/sql/ast/CreateTableAsSelectStmt.java 1 1 100.00% []

Copy link

[BE Incremental Coverage Report]

pass : 0 / 0 (0%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants