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

fix(sink): set query timeout for jdbc sink to avoid stuck #18430

Merged
merged 3 commits into from
Sep 6, 2024

Conversation

StrikeW
Copy link
Contributor

@StrikeW StrikeW commented Sep 6, 2024

I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.

What's changed and what's your intention?

  • add jdbc.query.timeout to allow user set the timeout for query, default to 10mins if not provided.

related: #18372

Checklist

  • I have written necessary rustdoc comments
  • I have added necessary unit tests and integration tests
  • I have added test labels as necessary. See details.
  • I have added fuzzing tests or opened an issue to track them. (Optional, recommended for new SQL features Sqlsmith: Sql feature generation #7934).
  • My PR contains breaking changes. (If it deprecates some features, please create a tracking issue to remove them in the future).
  • All checks passed in ./risedev check (or alias, ./risedev c)
  • My PR changes performance-critical code. (Please run macro/micro-benchmarks and show the results.)
  • My PR contains critical fixes that are necessary to be merged into the latest release. (Please check out the details)

Documentation

  • My PR needs documentation updates. (Please use the Release note section below to summarize the impact on users)

Release note

If this PR includes changes that directly affect users or other significant modifications relevant to the community, kindly draft a release note to provide a concise summary of these changes. Please prioritize highlighting the impact these changes will have on users.

@fuyufjh
Copy link
Member

fuyufjh commented Sep 6, 2024

Better to make it a configurable WITH arguments of create sink...

@StrikeW StrikeW added the user-facing-changes Contains changes that are visible to users label Sep 6, 2024
@hzxa21
Copy link
Collaborator

hzxa21 commented Sep 6, 2024

The PR description mentions that this PR can fix #18372. Do we confirm that this can actually resolve the issue? If it is caused by a deadlock mentioned in pgJDBC, I suspect that setting the timeout may not work.

It is okay to merge this PR though because the statement timeout may help in other cases.

@StrikeW
Copy link
Contributor Author

StrikeW commented Sep 6, 2024

The PR description mentions that this PR can fix #18372. Do we confirm that this can actually resolve the issue? If it is caused by a deadlock mentioned in pgJDBC, I suspect that setting the timeout may not work.

It is okay to merge this PR though because the statement timeout may help in other cases.

Since the stuck problem is not always reproducible, I didn't find a way to confirm it.
This pr is a best effort try to fix the stuck issue indeed.

Copy link
Collaborator

@hzxa21 hzxa21 left a comment

Choose a reason for hiding this comment

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

LGTM.

If we cannot confirm whether this PR can fix the issue, I suggest we keep the original issue opened until we rollout the fix and confirm it works.

How about cherry-picking it to 2.0 as well?

@StrikeW
Copy link
Contributor Author

StrikeW commented Sep 6, 2024

If we cannot confirm whether this PR can fix the issue, I suggest we keep the original issue opened until we rollout the fix and confirm it works.

Sounds ok to me.

How about cherry-picking it to 2.0 as well?

Yeah, I have labeled it.

@StrikeW StrikeW changed the title fix: set query timeout for jdbc sink to avoid stuck fix(sink): set query timeout for jdbc sink to avoid stuck Sep 6, 2024
@StrikeW StrikeW added this pull request to the merge queue Sep 6, 2024
@wenym1
Copy link
Contributor

wenym1 commented Sep 6, 2024

Just take a look at the code of pgjdbc. It seems that when this timeout is set, in every executeBatch, it will set a timer task with this timeout value. When timeout is reached, it will send separate cancel query from a separate PgStream. So even if the query is stuck in lower level connection, we are still able to cancel the query. So this setting can probably work.

Btw, can users specify the statement timeout in the jdbc connection string, so that for previous version, they can also set the timeout in the jdbc connection string?

@StrikeW
Copy link
Contributor Author

StrikeW commented Sep 6, 2024

Just take a look at the code of pgjdbc. It seems that when this timeout is set, in every executeBatch, it will set a timer task with this timeout value. When timeout is reached, it will send separate cancel query from a separate PgStream. So even if the query is stuck in lower level connection, we are still able to cancel the query. So this setting can probably work.

Btw, can users specify the statement timeout in the jdbc connection string, so that for previous version, they can also set the timeout in the jdbc connection string?

From the doc, I think users of previous versions could add the ?options=-c%20statement_timeout=5min to the jdbc url to set the timeout for a statement.

Merged via the queue into main with commit 5311069 Sep 6, 2024
40 of 41 checks passed
@StrikeW StrikeW deleted the siyuan/fix-jdbc-sink-stuck branch September 6, 2024 07:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need-cherry-pick-release-2.0 type/fix Bug fix user-facing-changes Contains changes that are visible to users
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants