-
Notifications
You must be signed in to change notification settings - Fork 92
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
Add support for sys.sp_reset_connection stored procedure #2758
Add support for sys.sp_reset_connection stored procedure #2758
Conversation
dffe0b3
to
d1df741
Compare
Pull Request Test Coverage Report for Build 10990507023Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
d1df741
to
e048c94
Compare
@@ -276,6 +277,7 @@ GetTDSRequest(bool *resetProtocol) | |||
ResetTDSConnection(); | |||
TdsErrorContext->err_text = "Fetching TDS Request"; | |||
*resetProtocol = true; | |||
reset_tds_connection_flag = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to also put this in the catch block?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On error connection is not reset so we should not set the flag to false. right ?
otherwise TDS request after error will reuse the old connection resources ?
7d70d95
to
933cbae
Compare
@@ -71,6 +71,8 @@ typedef ResetConnectionData *ResetConnection; | |||
* Local structures | |||
*/ | |||
TdsRequestCtrlData *TdsRequestCtrl = NULL; | |||
bool resetTdsConnectionFlag; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we initialise resetTdsConnectionFlag as false, that is on backend startup ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets initialize both vars
6eea9b8
to
60589ef
Compare
SELECT * from #babel_temp_table | ||
storedproc#!#prep#!#sys.sp_reset_connection#!# | ||
SELECT * from #babel_temp_table |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not actually testing the RPC in this connection, can we also have an RPC after storedproc?
@@ -71,6 +71,8 @@ typedef ResetConnectionData *ResetConnection; | |||
* Local structures | |||
*/ | |||
TdsRequestCtrlData *TdsRequestCtrl = NULL; | |||
bool resetTdsConnectionFlag; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets initialize both vars
ec430c1
to
344acb5
Compare
344acb5
to
a66de39
Compare
8107191
to
fa5c6dc
Compare
fa5c6dc
to
4ea70d8
Compare
# Test (24): End | ||
|
||
# Test (25): Test sys.sp_reset_connection stored procedure |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create a new test file for sp_reset_connection
INSERT INTO #babel_temp_table (Data) VALUES (100), (200), (300) | ||
SELECT * from #babel_temp_table | ||
storedproc#!#prep#!#sys.sp_reset_connection#!# |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We must add tests for sp_prepexec, sp_execute as well. This test only uses sp_customtype
/* | ||
* SetResetTDSConnectionFlag - Sets reset tds connection flag | ||
*/ | ||
void SetResetTDSConnectionFlag() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On diving deep, Found 2 behaviour differences:
- sys.sp_reset_connection should not send Env change token and TDSResetConnection should send
- Isolation levels are reset for sp_reset_connection but retained for TDSResetConnection
We have not fixed this for sp_reset_connection and this is paramount for feature complete. Lets focus on testing and aligning TSQL Behaviour and using wireshark
|
||
EXEC sys.sp_reset_connection | ||
-- TODO: GUC is not resetting | ||
SELECT @@lock_timeout; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm assuming the default value was 0. How are we really testing the reset in this case?
~~END~~ | ||
|
||
DECLARE @handle int; | ||
EXEC SP_PREPARE @handle output, NULL, N'exec sys.sp_reset_connection' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From my previous comments, we have still not added RPC tests
~~END~~ | ||
|
||
DECLARE @handle int; | ||
EXEC SP_PREPARE @handle output, NULL, N'exec sys.sp_reset_connection' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From my previous comments, we have still not added RPC tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay I see the these are added in .net
3997e2e
into
babelfish-for-postgresql:BABEL_4_X_DEV
…or-postgresql#2758) Support sys.sp_reset_connection store procedure to reset tds connection 1. At the moment babelfish doesn't support sys.sp_reset_connection to reset the connection state. With this change it supports reset connection stored procedure. 2. This change is required for supporting RDS Proxy for Babelfish. RDS Proxy calls sys.sp_reset_connection before connection is reused by other clients. Tasks: BABEL-429 Signed off by: Sharath BP <[email protected]> (cherry picked from commit 3997e2e)
…or-postgresql#2758) Support sys.sp_reset_connection store procedure to reset tds connection 1. At the moment babelfish doesn't support sys.sp_reset_connection to reset the connection state. With this change it supports reset connection stored procedure. 2. This change is required for supporting RDS Proxy for Babelfish. RDS Proxy calls sys.sp_reset_connection before connection is reused by other clients. Tasks: BABEL-429 Signed off by: Sharath BP <[email protected]> (cherry picked from commit 3997e2e)
Description
Support sys.sp_reset_connection store procedure to reset tds connection
Issues Resolved
BABEL-429
Test Scenarios Covered
Use case based - Yes
Boundary conditions - Yes
Arbitrary inputs - Yes
Negative test cases - Yes
Minor version upgrade tests - N/A
Major version upgrade tests - N/A
Performance tests - N/A
Tooling impact - N/A
Client tests - N/A
Check List
By submitting this pull request, I confirm that my contribution is under the terms of the Apache 2.0 and PostgreSQL licenses, and grant any person obtaining a copy of the contribution permission to relicense all or a portion of my contribution to the PostgreSQL License solely to contribute all or a portion of my contribution to the PostgreSQL open source project.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.