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

Tests | Fix SqlBatch Test Deadlocks #3025

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MichelZ
Copy link
Contributor

@MichelZ MichelZ commented Nov 20, 2024

AI Blurp

This pull request includes changes to the BatchTests.cs file to add retry logic for SQL commands and to enhance the SqlBatchCommand functionality. The most important changes are as follows:

Enhancements to SQL retry logic:

  • Added retry logic configuration using SqlRetryLogicOption and SqlRetryLogicBaseProvider to handle transient errors like deadlocks by retrying the operation up to three times with a delay of 100 milliseconds.

Improvements to SqlBatchCommand:

  • Modified StoredProcedureBatchSupported and MixedBatchSupported methods to include parameters in SqlBatchCommand for executing stored procedures, specifically adding a parameter for the sp_help stored procedure.

Additional imports:

  • Added System.Collections.Generic import to support the use of List<SqlParameter> in the updated methods.

Description

I regularly see deadlocks for the tests that use sp_help.
I'll try to mitigate this in 2 different ways:

  • Add a retry for ErrorNumber 1205 (Deadlock)
  • Add a parameter @objname that does less work so it's less likely to get a deadlock

It can probably also be solved by just using another stored procedure that's not prone to deadlocks, but I chose this way as the easiest path

Example test failure:
https://sqlclientdrivers.visualstudio.com/public/_build/results?buildId=101959&view=logs&j=700ebecb-e440-5400-66bb-488206e790af&t=d8ae6a68-b967-5b1e-ef3d-1b53d82075ee&l=826

Add parameter to sp_help
Copy link

codecov bot commented Nov 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 72.68%. Comparing base (b1f7eaf) to head (4ab317f).
Report is 9 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3025      +/-   ##
==========================================
- Coverage   72.68%   72.68%   -0.01%     
==========================================
  Files         285      285              
  Lines       59155    59160       +5     
==========================================
+ Hits        42998    43000       +2     
- Misses      16157    16160       +3     
Flag Coverage Δ
addons 92.58% <ø> (ø)
netcore 75.44% <ø> (+0.05%) ⬆️
netfx 71.07% <ø> (-0.06%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@MichelZ MichelZ changed the title Fix SqlBatch Test Deadlocks Tests | Fix SqlBatch Test Deadlocks Nov 25, 2024
@mdaigle mdaigle added ➕ Code Health Issues/PRs that are targeted to source code quality improvements. Area\Tests Issues that are targeted to tests or test projects and removed ➕ Code Health Issues/PRs that are targeted to source code quality improvements. labels Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area\Tests Issues that are targeted to tests or test projects
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants