Ensure that jdbc temp tables can be dropped if the insertions fail#19368
Merged
wendigo merged 1 commit intotrinodb:masterfrom Oct 18, 2023
Merged
Ensure that jdbc temp tables can be dropped if the insertions fail#19368wendigo merged 1 commit intotrinodb:masterfrom
wendigo merged 1 commit intotrinodb:masterfrom
Conversation
96fb94a to
a9ab48a
Compare
Member
Author
kokosing
reviewed
Oct 12, 2023
Member
kokosing
left a comment
There was a problem hiding this comment.
Is it possible to have a test?
hashhar
reviewed
Oct 12, 2023
plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/BaseJdbcClient.java
Show resolved
Hide resolved
Member
Author
@kokosing Sorry i didn't figure out a good way to mock the jdbc insertion failure, it seems that we need to implement |
kokosing
approved these changes
Oct 12, 2023
Member
Author
wendigo
approved these changes
Oct 18, 2023
Contributor
|
Thanks @hackeryang |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
We use Trino to query and insert mysql tables, and one day we found that our MySQL appeared many temp tables which were created long time ago as shown below:
After reading relevant source codes, we found that this place may cause a bug:


If the execution of the statement
pageSinkInsertSqlfails inconstructPageSinkIdsTable(), thecloser.register(() -> dropTable(session, pageSinkTable, true))infinishInsertTable()won't be executed, and will directly jump to thefinallycode block to executecloser.close(), which only hascloser.register(() -> dropTable(session, temporaryTable, true))withoutpageSinkTable.So we need to register the drop table closer before the execution of insertion statements.
Additional context and related issues
Release notes
(x) This is not user-visible or is docs only, and no release notes are required.
( ) Release notes are required. Please propose a release note for me.
( ) Release notes are required, with the following suggested text: