Skip to content

Make SQLServer deadlock query retries reusable#14947

Merged
hashhar merged 2 commits intotrinodb:masterfrom
hashhar:hashhar/sqlserver-cleanup
Nov 15, 2022
Merged

Make SQLServer deadlock query retries reusable#14947
hashhar merged 2 commits intotrinodb:masterfrom
hashhar:hashhar/sqlserver-cleanup

Conversation

@hashhar
Copy link
Copy Markdown
Member

@hashhar hashhar commented Nov 8, 2022

The 2nd commit isn't very useful IMO. Just the first one should be fine.

@hashhar hashhar added the no-release-notes This pull request does not require release notes entry label Nov 8, 2022
@hashhar hashhar requested a review from kokosing November 8, 2022 10:07
@cla-bot cla-bot bot added the cla-signed label Nov 8, 2022
@hashhar hashhar force-pushed the hashhar/sqlserver-cleanup branch from 31a8ad4 to ca7f5d5 Compare November 12, 2022 19:13
@hashhar hashhar requested review from krvikash and ssheikin November 12, 2022 19:13
Copy link
Copy Markdown
Contributor

@ssheikin ssheikin left a comment

Choose a reason for hiding this comment

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

Thanks!
Please squash commits.

@hashhar hashhar force-pushed the hashhar/sqlserver-cleanup branch from ca7f5d5 to 5de6556 Compare November 15, 2022 07:44
{
// DDL operations can take out locks against system tables causing queries against them to deadlock
int maxAttemptCount = 3;
RetryPolicy<T> retryPolicy = new RetryPolicy<T>()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: retry policies can be extracted as constants

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

that was the initial version but it looks cleaner this way - especially since the policy has no use outside of this very specific case (at-least today).

return retryOnDeadlock(() -> getTableDataCompression(handle, table), "error when getting table compression info for '%s'".formatted(table));
}

public static <T> T retryOnDeadlock(CheckedSupplier<T> supplier, String attemptLogMessage)
Copy link
Copy Markdown
Member

@kokosing kokosing Nov 15, 2022

Choose a reason for hiding this comment

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

Do we need to be so specific to stress the OnDeadlock part? I think there are certain operation that are retry-able where deadlock could be one of them. We may want retry in other places too so maybe having some utility for retries for sql-server could be beneficial.

Just a nit.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, would be useful. I don't any such cases today. Once we have them we can refactor - refactor without existing usage makes it difficult to decide optimal API.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Note that when we introduce such retry I expect it to actually live in BaseJdbcClient (for metadata) and JdbcRecordSetProvider (for data).

@hashhar hashhar merged commit b958563 into trinodb:master Nov 15, 2022
@hashhar hashhar deleted the hashhar/sqlserver-cleanup branch November 15, 2022 12:25
@github-actions github-actions bot added this to the 403 milestone Nov 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed no-release-notes This pull request does not require release notes entry

Development

Successfully merging this pull request may close these issues.

4 participants