fix: transaction commit fails when indexes are dropped mid-transaction#3673
Conversation
TransactionIndexContext.commit() and addFilesToLock() threw SchemaException when iterating index entries that referenced indexes dropped during the same transaction (e.g. via dropType). Now pruned before processing. Also fix NPE in MCPConfiguration.isUserAllowed() when username is null. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses critical stability issues related to transaction management and user permission checks. It ensures that database transactions can commit successfully even when indexes are dropped mid-transaction, and it fortifies the user permission system against null input, thereby enhancing the overall robustness and reliability of the system. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
Code ReviewGood, targeted fix for two independent bugs. The changes are minimal, defensive, and well-tested. A few observations: TransactionIndexContext —
|
There was a problem hiding this comment.
Code Review
This pull request effectively addresses two critical issues. The TransactionIndexContext now correctly handles scenarios where indexes are dropped mid-transaction, preventing SchemaException during commit and file locking operations. Additionally, a NullPointerException in MCPConfiguration.isUserAllowed() has been resolved by adding a null check for the username parameter. These changes significantly improve the stability and robustness of the system.
| if (!schema.existsIndex(indexName)) | ||
| // INDEX WAS DROPPED DURING THE TRANSACTION (e.g. TYPE DROP), SKIP IT | ||
| continue; |
There was a problem hiding this comment.
While the logic is correct, it is generally considered best practice in Java to always use curly braces {} with if statements, even for single-line bodies. This improves readability and prevents potential bugs if more statements are added later.
For example:
if (!schema.existsIndex(indexName)) {
// INDEX WAS DROPPED DURING THE TRANSACTION (e.g. TYPE DROP), SKIP IT
continue;
}| if (!schema.existsIndex(indexName)) | |
| // INDEX WAS DROPPED DURING THE TRANSACTION (e.g. TYPE DROP), SKIP IT | |
| continue; | |
| if (!schema.existsIndex(indexName)) { | |
| // INDEX WAS DROPPED DURING THE TRANSACTION (e.g. TYPE DROP), SKIP IT | |
| continue; | |
| } |
| if (username == null) | ||
| return false; |
There was a problem hiding this comment.
Similar to the previous comment, it's a good practice to use curly braces {} with if statements for consistency and to prevent future errors, even for single-line conditions.
For example:
if (username == null) {
return false;
}| if (username == null) | |
| return false; | |
| if (username == null) { | |
| return false; | |
| } |
🧪 CI InsightsHere's what we observed from your CI run for 01c2058. 🟢 All jobs passed!But CI Insights is watching 👀 |
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferences |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3673 +/- ##
==========================================
+ Coverage 65.20% 65.73% +0.52%
==========================================
Files 1550 1550
Lines 109877 109888 +11
Branches 22936 22940 +4
==========================================
+ Hits 71645 72231 +586
+ Misses 28581 27948 -633
- Partials 9651 9709 +58 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Bumps [pg](https://github.com/brianc/node-postgres/tree/HEAD/packages/pg) from 8.20.0 to 8.21.0. Changelog *Sourced from [pg's changelog](https://github.com/brianc/node-postgres/blob/master/CHANGELOG.md).* > pg@8.21.0 > --------- > > * Handle [SASL SCRAM](https://redirect.github.com/brianc/node-postgres/pull/3521) server error responses properly. > * Add support for [node@26](https://redirect.github.com/brianc/node-postgres/pull/3667). > * Add `scramMaxIterations` [config option](https://redirect.github.com/brianc/node-postgres/pull/3677). > * Add `client.getTransactionStatus()` [method](https://redirect.github.com/brianc/node-postgres/pull/3645). Commits * [`544b1ce`](brianc/node-postgres@544b1ce) Publish * [`cc03fa5`](brianc/node-postgres@cc03fa5) Add scramMaxIterations option to limit SCRAM iteration count ([#3677](https://github.com/brianc/node-postgres/tree/HEAD/packages/pg/issues/3677)) * [`f776327`](brianc/node-postgres@f776327) Remove compatibility code for unsupported versions of Node (<16) ([#3678](https://github.com/brianc/node-postgres/tree/HEAD/packages/pg/issues/3678)) * [`f252870`](brianc/node-postgres@f252870) cleanup: pg utils ([#3675](https://github.com/brianc/node-postgres/tree/HEAD/packages/pg/issues/3675)) * [`c8da6ab`](brianc/node-postgres@c8da6ab) Assorted test cleanup ([#3673](https://github.com/brianc/node-postgres/tree/HEAD/packages/pg/issues/3673)) * [`fa47e73`](brianc/node-postgres@fa47e73) fix: `Client#end` callback being called multiple times when first is no-op (#... * [`88a7e60`](brianc/node-postgres@88a7e60) cleanup: Move declaration to more natural place * [`2095247`](brianc/node-postgres@2095247) cleanup: Combine duplicated code in `Client#query` and avoid unneeded early n... * [`0ac3edd`](brianc/node-postgres@0ac3edd) fix: apply SASLprep (RFC 4013) to passwords before SCRAM-SHA-256 PBKDF2 ([#3669](https://github.com/brianc/node-postgres/tree/HEAD/packages/pg/issues/3669)) * [`be880d4`](brianc/node-postgres@be880d4) Assorted test fixes and cleanup ([#3672](https://github.com/brianc/node-postgres/tree/HEAD/packages/pg/issues/3672)) * Additional commits viewable in [compare view](https://github.com/brianc/node-postgres/commits/pg@8.21.0/packages/pg) [](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- Dependabot commands and options You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
Bumps [pg](https://github.com/brianc/node-postgres/tree/HEAD/packages/pg) from 8.20.0 to 8.21.0. Changelog *Sourced from [pg's changelog](https://github.com/brianc/node-postgres/blob/master/CHANGELOG.md).* > pg@8.21.0 > --------- > > * Handle [SASL SCRAM](https://redirect.github.com/brianc/node-postgres/pull/3521) server error responses properly. > * Add support for [node@26](https://redirect.github.com/brianc/node-postgres/pull/3667). > * Add `scramMaxIterations` [config option](https://redirect.github.com/brianc/node-postgres/pull/3677). > * Add `client.getTransactionStatus()` [method](https://redirect.github.com/brianc/node-postgres/pull/3645). Commits * [`544b1ce`](brianc/node-postgres@544b1ce) Publish * [`cc03fa5`](brianc/node-postgres@cc03fa5) Add scramMaxIterations option to limit SCRAM iteration count ([ArcadeData#3677](https://github.com/brianc/node-postgres/tree/HEAD/packages/pg/issues/3677)) * [`f776327`](brianc/node-postgres@f776327) Remove compatibility code for unsupported versions of Node (<16) ([ArcadeData#3678](https://github.com/brianc/node-postgres/tree/HEAD/packages/pg/issues/3678)) * [`f252870`](brianc/node-postgres@f252870) cleanup: pg utils ([ArcadeData#3675](https://github.com/brianc/node-postgres/tree/HEAD/packages/pg/issues/3675)) * [`c8da6ab`](brianc/node-postgres@c8da6ab) Assorted test cleanup ([ArcadeData#3673](https://github.com/brianc/node-postgres/tree/HEAD/packages/pg/issues/3673)) * [`fa47e73`](brianc/node-postgres@fa47e73) fix: `Client#end` callback being called multiple times when first is no-op (#... * [`88a7e60`](brianc/node-postgres@88a7e60) cleanup: Move declaration to more natural place * [`2095247`](brianc/node-postgres@2095247) cleanup: Combine duplicated code in `Client#query` and avoid unneeded early n... * [`0ac3edd`](brianc/node-postgres@0ac3edd) fix: apply SASLprep (RFC 4013) to passwords before SCRAM-SHA-256 PBKDF2 ([ArcadeData#3669](https://github.com/brianc/node-postgres/tree/HEAD/packages/pg/issues/3669)) * [`be880d4`](brianc/node-postgres@be880d4) Assorted test fixes and cleanup ([ArcadeData#3672](https://github.com/brianc/node-postgres/tree/HEAD/packages/pg/issues/3672)) * Additional commits viewable in [compare view](https://github.com/brianc/node-postgres/commits/pg@8.21.0/packages/pg) [](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- Dependabot commands and options You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
Summary
commit()andaddFilesToLock()threwSchemaExceptionwhen iterating index entries that referenced indexes dropped during the same transaction (e.g., viadropType()). Now pruned before processing.isUserAllowed()threw NPE when called with a null username. Added null guard.Test plan
DropIndexTest.dropAndRecreateTypeWithIndex— passes (was failing)TruncateClassStatementExecutionTest.truncateClass— passes (was failing)MCPPermissionsTest.mcpNullUserNotAllowed— passes (was failing)🤖 Generated with Claude Code