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

Comprehensive cursor state cleanup to avoid stale data after TDSResetConnection #3040

Conversation

KushaalShroff
Copy link
Contributor

@KushaalShroff KushaalShroff commented Oct 22, 2024

Description

Earlier we were not cleaning up cursor states and hast tables like CursorHashTable and CursorPreparedHandleHashTable at the time of resetting the TDS connection. This lead to cursor leaks and potentially will let users to continue using the cursors from previous connection. To fix this we introduce a reset_cached_cursor function which cleans up all the stale cursor states and resets the cursor handles.

Issues Resolved

BABEL-5287

Test Scenarios Covered

  • Use case based -
    Added tests for prepared and unprepared cursor with thorough checks pre and post reset.

Check List

  • Commits are signed per the DCO using --signoff

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.

@coveralls
Copy link
Collaborator

coveralls commented Oct 22, 2024

Pull Request Test Coverage Report for Build 11550988613

Details

  • 29 of 31 (93.55%) changed or added relevant lines in 2 files are covered.
  • 2 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.1%) to 74.641%

Changes Missing Coverage Covered Lines Changed/Added Lines %
contrib/babelfishpg_tsql/src/cursor.c 28 30 93.33%
Files with Coverage Reduction New Missed Lines %
contrib/babelfishpg_tds/src/backend/tds/tdscomm.c 2 76.03%
Totals Coverage Status
Change from base Build 11550836663: 0.1%
Covered Lines: 45339
Relevant Lines: 60743

💛 - Coveralls

@KushaalShroff KushaalShroff merged commit e4bde8f into babelfish-for-postgresql:BABEL_4_X_DEV Oct 28, 2024
46 checks passed
@KushaalShroff KushaalShroff deleted the cursor_reset_4X branch October 28, 2024 11:44
KushaalShroff added a commit to amazon-aurora/babelfish_extensions that referenced this pull request Nov 22, 2024
…Connection (babelfish-for-postgresql#3040)

Earlier we were not cleaning up cursor states and hast tables like CursorHashTable and CursorPreparedHandleHashTable at the time of resetting the TDS connection. This lead to cursor leaks and potentially will let users to continue using the cursors from previous connection. To fix this we introduce a reset_cached_cursor function which cleans up all the stale cursor states and resets the cursor handles.

Issues Resolved
BABEL-5287

Signed-off-by: Kushaal Shroff [email protected]
KushaalShroff added a commit to amazon-aurora/babelfish_extensions that referenced this pull request Nov 22, 2024
…Connection (babelfish-for-postgresql#3040)

Earlier we were not cleaning up cursor states and hast tables like CursorHashTable and CursorPreparedHandleHashTable at the time of resetting the TDS connection. This lead to cursor leaks and potentially will let users to continue using the cursors from previous connection. To fix this we introduce a reset_cached_cursor function which cleans up all the stale cursor states and resets the cursor handles.

Issues Resolved
BABEL-5287

Signed-off-by: Kushaal Shroff [email protected]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants