Repository navigation
Conversation
FirebirdCreateBlobCommandExecutor registered a BLOB and returned success for any transaction handle, including one that was never started, unlike the Firebird server and every other transaction-scoped executor in this module. Validate the handle via FirebirdTransactionIdGenerator#isTransactionActive, throwing InvalidTransactionHandleException on an unknown handle, mirroring the existing check in FirebirdExecuteStatementCommandExecutor, FirebirdBatchExecuteCommandExecutor, FirebirdCommitTransactionCommandExecutor, and FirebirdRollbackTransactionCommandExecutor. Fixes apache#40393 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The validation added in e5fba55 carried a stray 4-space indent from a local revert/restore cycle; CI's Checkstyle run caught it since the check isn't run locally with -Pcheck in a way that touched this exact line previously. Aligned with the identical construct in FirebirdExecuteStatementCommandExecutor#validateTransactionHandle. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…te helper createBlobWithSegment() drives the real FirebirdCreateBlobCommandExecutor to set up fixtures. Its transaction handle validation (3505750) needs an active transaction registered on the mock packet, or the shared FirebirdTransactionIdGenerator has no connection entry to check against. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
terrymanu
left a comment
There was a problem hiding this comment.
Summary
This PR fixes #40393 by validating transaction handles before allocating a Firebird BLOB. It rejects unknown literal handles, but introduces two regressions involving transaction recovery and lazy-protocol handles.
Result
Review Result: Not Mergeable
Feedback Mode: Change Request
Blocking Issues: 2
Blocking Issues
[P1] Preserve pending work when rejecting an unknown handle
- Evidence: The new exception reaches FirebirdFrontendEngine:49–53, marking the active transaction failed. LocalTransactionManager:49–55 consequently rolls back during commit.
- Impact: Start a transaction, execute DML, send CREATE_BLOB2 with an unknown transaction handle, then commit using the correct handle. Pending work is rolled back while COMMIT returns success. A component reproduction confirmed this change from the base.
- Required Change: Reject the invalid BLOB request without marking the unrelated active transaction failed, and add regression coverage proving its work remains committable.
[P2] Preserve valid lazy-protocol transaction references
- Evidence: The new check at lines 48–49 checks raw integer membership. Native Firebird resolves INVALID_OBJECT in lazy mode before looking up the transaction.
- Impact: After negotiating lazy-send type 5 and starting a transaction, an immediate CREATE_BLOB2 using
0xFFFFvalidly references that transaction. The new guard rejects it. Ordinary explicit transaction IDs remain unaffected. - Required Change: Resolve valid lazy-mode references before validation and cover this success case alongside unknown-handle rejection.
Coverage
Reviewed all three changed files at public head 4288e15479a25c60c0a0bebe95d1ec38ac619dda. Exact-head Spotless and Checkstyle passed for all three files; 12 affected tests passed, all with exit code 0.
Native semantics were checked against Firebird v5.0.4 source; component reproductions used mocked collaborators. No end-to-end database test was run. This is a code-scope review; CI was not reviewed.
An unknown transaction handle rejected by create_blob named a transaction other than the one the session was tracking, but FirebirdFrontendEngine#handleException marked the session's actual active transaction failed anyway, silently rolling back its otherwise- successful work at the next commit. Excluded InvalidTransactionHandleException from that poisoning, alongside the existing InTransactionException exclusion. Also, a lazy-send client that starts a transaction and immediately references it from create_blob with Firebird's INVALID_OBJECT sentinel (0xFFFF, since it has not yet received the real handle) was rejected as unknown. FirebirdTransactionIdGenerator#isTransactionActive now resolves that sentinel to the connection's most recently started transaction, matching rem_port::getHandle in Firebird's own remote.h for this specific case. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
Thanks, addressed in af082c1. 1. Preserve pending work when rejecting an unknown handle Confirmed and fixed. 2. Preserve valid lazy-protocol transaction references Confirmed and fixed. Checked the real mechanism in Firebird's own Verification All affected tests pass ( |
…eject Mirrors the fixes accepted on PR apache#40511 for the same shared files: FirebirdTransactionIdGenerator#isTransactionActive now resolves Firebird's INVALID_OBJECT sentinel (0xFFFF) to the connection's most recently started transaction instead of rejecting it outright, matching terrymanu's review finding on this PR. FirebirdFrontendEngine#handleException now also excludes InvalidTransactionHandleException from poisoning the active transaction, proactively porting apache#40511's P1 fix since this branch throws the same exception type and has the identical latent regression. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…te-blob-unknown-transaction-handle # Conflicts: # proxy/frontend/dialect/firebird/src/main/java/org/apache/shardingsphere/proxy/frontend/firebird/FirebirdFrontendEngine.java # proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/FirebirdFrontendEngineTest.java
terrymanu
left a comment
There was a problem hiding this comment.
Correction
Previous Finding or Conclusion: Native signed placeholder references are still rejected.
Current Status: Retained
Reason: The previous XDR source link used an incorrect path. It now points to src/common/xdr.cpp; source inspection and an actual-packet component reproduction both support the finding.
Summary
PR #40511 validates transaction handles before creating BLOBs and prevents invalid-handle errors from marking the current transaction as failed. The approach addresses the original defect, but lazy-response handle processing still has three behavioral defects and two explicit coding-standard violations.
Result
Review Result: Not Mergeable
Feedback Mode: Change Request
Blocking Issues: 5
The complete review and remaining confirmation gates are finished. The following is the complete blocking-issue set for the current head.
Blocking Issues
[P1] Invalid placeholders can commit or roll back the current transaction
- Evidence: The new resolution logic unconditionally maps
65535to the latest transaction. The native implementation requires lazy mode and resolves the most recently allocated object. - Impact: On a non-lazy connection, or when the latest object is not a transaction, COMMIT/ROLLBACK requests that should be rejected can still operate on the current transaction. Component reproductions confirmed that both backend operations can be invoked.
- Required Change: Determine reference validity from the negotiated mode, latest object and its type, preserving rejection of invalid transaction handles.
[P2] Successful transaction completion leaves the real handle active
- Evidence: COMMIT passes validation using the resolved handle but still passes the original
65535tocloseTransaction. ROLLBACK follows the same path. - Impact: After the command returns success, the real transaction remains registered as active, and the next START fails with
ExcessTransactionsException. Both paths were reproduced. - Required Change: Use the same resolved transaction ID for execution and cleanup, and cover starting another transaction after completion.
[P2] Native signed placeholder encoding is still rejected
- Evidence: Native XDR encodes the placeholder as
FFFFFFFF. Proxy decodes it as-1, while the new resolution logic recognizes only positive65535. - Impact: In lazy mode, a valid CREATE_BLOB2 request using this encoding immediately after START is still rejected. A component reproduction using an actual packet and the current executor confirmed this behavior.
- Required Change: Normalize the wire transaction-object reference before validation and add regression coverage using a packet containing
FFFFFFFF.
[P2] Keep the new ordinary-declaration Javadocs concise
- Evidence: The Engine private-method description and generator private-constant description include implementation steps, design rationale and scenario explanations, contrary to the existing Javadoc rules.
- Impact: These additions violate an explicit applicable standard that automated formatting checks do not enforce.
- Required Change: Use short, accurate responsibility descriptions and retain necessary contract information.
[P2] Apply the required list-wrapping form to the expanded Stream.of
- Evidence: The updated test argument list reconstructs to 232 characters on one line and does not follow the list-wrapping rule.
- Impact: The layout violates an explicit written standard, even though Spotless preserves it.
- Required Change: Keep
Stream.of(on the opening line and place each top-levelArguments.of(...)on its own continuation line.
Coverage
Public head: a8ea0914192dcc2c2bba351863e91a64b02db441. All seven changed files and relevant consumers were reviewed; independent-review ledger validation and final session validation passed.
Checkstyle and Spotless covered all 7/7 files and passed. All 61 tests across eight relevant test classes passed, and component reproductions completed; all commands exited with code 0.
Only PR objects were fetched; no branch switches or workspace file edits were performed. This is a code-scope review; CI was not reviewed, and no database end-to-end tests were run.
…st object The INVALID_OBJECT placeholder is only valid when lazy send was negotiated and the connection's most recently allocated object is a transaction, and it can arrive as 0xFFFF or as the sign-extended -1 that xdr_short produces. Commit and rollback now use the resolved ID for validation, execution and cleanup so the transaction no longer stays registered after a placeholder commit or rollback. Assisted with AI Claude (Claude Code). Affected files: FirebirdLatestObjectRegistry, FirebirdTransactionIdGenerator, FirebirdStatementIdGenerator, FirebirdBlobHandleGenerator, FirebirdCommit/RollbackTransactionCommandExecutor, FirebirdAcceptPacket, FirebirdAuthenticationEngine, FirebirdFrontendEngine and their tests. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Thanks, addressed in 03e3aa7. [P1] Invalid placeholders can commit or roll back the current transaction The placeholder is now accepted only when lazy send was negotiated at handshake, mirroring [P2] Successful transaction completion leaves the real handle active COMMIT and ROLLBACK now resolve the handle once and use it for validation, execution and [P2] Native signed placeholder encoding is still rejected Both [P2] Javadocs and [P2] I removed the Javadoc on 🤖 Generated with Claude Code |
terrymanu
left a comment
There was a problem hiding this comment.
Summary
This PR rejects unknown Firebird transaction handles before allocating a BLOB. It also tracks lazy-protocol state and resolves handles for transaction completion. The earlier placeholder and transaction-poisoning issues are addressed, but signed concrete handles and several written-standard violations remain.
Result
Review Result: Not Mergeable
Feedback Mode: Change Request
Review Status: Not Converged
Confirmed Blocking Issues: 8
These are confirmed findings, not a claimed exhaustive set. Formal review-record validation remains unavailable because the public-head Git object is absent locally.
Blocking Issues
[P2] Normalize signed concrete transaction handles
- Evidence: The resolver recognizes the two sentinel encodings but leaves other negative handles unchanged. Native xdr_short sign-extends concrete handles too.
- Impact: After 32,767 completed transactions, handle
32768is encoded asFFFF8000, decoded as-32768, and rejected by the new BLOB guard. An exact-source probe reproduced this with one active transaction. This case predates the latest commit and was missed in the earlier reviews. - Required Change: Normalize the 16-bit wire handle before lookup and add a regression case for a signed concrete handle.
[P2] Restore protocol-version state after the authentication test
- Evidence: The new test executes real CONNECT for connection
1, but its cleanup removes only latest-object state. - Impact:
FirebirdConnectionProtocolVersionretains the test’s entry, violating the static-state restoration requirement. - Required Change: Restore the original protocol-version entry or isolate that collaborator.
[P2] Make the new singleton constructor private
- Evidence: AccessLevel.NONE suppresses constructor generation. Compilation and
javapconfirm an implicit public constructor. - Impact: The new singleton exposes unnecessary public construction, contrary to minimum-access requirements.
- Required Change: Generate a private no-argument constructor.
[P2] Apply the high-frequency rules to the new execution paths
- Evidence: New
resolveTransactionIdand registry marking/lookup methods repeat during normal SQL and transaction workloads withoutHighFrequencyInvocation; their private helper also concatenates strings with+. - Impact: These additions violate the high-frequency requirements.
- Required Change: Annotate the smallest applicable scopes and comply with their expression restrictions.
[P2] Place new private helpers after their first callers
- Evidence: getType, the registry helpers, and createPacket are separated from their first callers.
- Impact: Their placement violates the explicit private-helper ordering rule.
- Required Change: Move these helpers immediately after their first callers, preserving call order.
[P2] Restructure the thirteen two-case parameterized tests
- Evidence: The added CREATE_BLOB, COMMIT, ROLLBACK and transaction-generator cases each use exactly
{0xFFFF, -1}; see the BLOB cases. - Impact: Each violates the minimum of three meaningful argument sets.
- Required Change: Use ordinary tests or a meaningful larger scenario matrix; avoid redundant third values.
[P2] Use the prescribed Boolean assertion
- Evidence: The authentication assertion uses Hamcrest equality for a Boolean result.
- Impact: This violates the required
assertTrue/assertFalseassertion form. - Required Change: Express the Boolean cases using the prescribed assertions.
[P2] Name the expected resolved handle accordingly
- Evidence: In the resolver test,
transactionIdsupplies the expected side of the assertion. - Impact: It violates the expected-value naming requirement.
- Required Change: Rename this local and its reference to
expectedTransactionId.
Coverage
Public head: 03e3aa7da2df4d3568302908e20dcba1d084f9f8. Both independent assessments covered all 21 changed files; their findings were substantively adjudicated.
Exact-head Checkstyle and Spotless passed for 21/21 files. Component probes passed. Focused Maven tests stopped before execution because shardingsphere-database-exception-firebird:5.5.4-SNAPSHOT was unavailable.
This is a code-scope review; CI and database E2E tests were not reviewed. Git-backed ledger/session validation could not complete; no repository source or Git state was changed.
Mask the wire transaction handle to 16 bits before lookup so sign-extended concrete handles resolve, mark the per-allocation registry paths as high frequency, make the registry constructor private, order private helpers after their callers, restore protocol-version state in the authentication test, and replace two-case parameterized tests with ordinary tests. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Thanks, addressed in c0059fe. [P2] Normalize signed concrete transaction handles
[P2] Restore protocol-version state after the authentication test The test now unsets the [P2] Make the new singleton constructor private
[P2] High-frequency rules
[P2] Private helper placement
[P2] Two-case parameterized tests The thirteen tests are now ordinary tests. The accepted-sentinel tests use the sign-extended [P2] Boolean assertion and [P2] Expected-value naming The authentication cases use 🤖 Generated with Claude Code |
The E2E transaction job on opengauss failed before running any test because the Maven wrapper could not download its distribution. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
terrymanu
left a comment
There was a problem hiding this comment.
Summary
PR #40511 validates transaction handles before creating BLOBs and adds lazy-protocol reference resolution and recoverable exception handling. The new 16-bit normalization is inconsistent with the existing incremental handle generator, preventing long-lived connections from completing transactions they have just started.
Result
Review Result: Not Mergeable
Feedback Mode: Change Request
Review Status: Not Converged
Confirmed Blocking Issues: 1
The following issue is confirmed. Formal review-record validation remains incomplete, so this is not claimed to be an exhaustive blocking-issue set.
Blocking Issues
[P2] Keep generated transaction handles consistent with normalization
- Evidence: FirebirdTransactionIdGenerator.java:73–101 still generates and registers handles using an incrementing counter without a wire-range bound, but applies
& 0xFFFFto every lookup handle. Component reproductions using the base and current source confirm that, after generating65536, the base accepts that handle while the current code converts it to0and rejects it. - Impact: After a connection completes 65,535 transactions, the handle returned by the next START cannot be used for COMMIT or ROLLBACK. The exception occurs before transaction completion and registry cleanup, leaving the transaction active and causing subsequent START requests to be rejected.
- Required Change: Make handle generation, normalization, active registration and cleanup use a consistent range, exclude reserved placeholder values, preserve signed-handle support, and add sequential commit and rollback regression tests across this boundary.
Coverage
Public head: 19391891dfee8afa605be999c2fecafe4136fa55. Two independent assessments covered all 21 changed files; their conclusions and supporting evidence were substantively reviewed.
Checkstyle and Spotless passed for all 21/21 files. All 21 tests across two test classes passed, and base/current-source component reproductions completed.
This is a code-scope review. CI was not queried, and database E2E tests were not run. The public-head Git object is unavailable locally, preventing coverage-ledger initialization and completion of session validation.
Allocate transaction handles from 1 to 0xFFFE and wrap around, so every handle returned by START survives the 16-bit normalization applied to COMMIT, ROLLBACK and lookups, and never equals the lazy placeholder. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Thanks, addressed in f25f4c5. [P2] Keep generated transaction handles consistent with normalization
Regression tests cover the wrap in the generator ( 🤖 Generated with Claude Code |
* Reject open_blob with an unknown transaction handle FirebirdOpenBlobCommandExecutor opened a BLOB and returned success for any transaction handle, including one that was never started, unlike the Firebird server and every other transaction-scoped executor in this module. Validate the handle via FirebirdTransactionIdGenerator#isTransactionActive, throwing InvalidTransactionHandleException on an unknown handle, mirroring the identical check in FirebirdCreateBlobCommandExecutor (#40393), FirebirdExecuteStatementCommandExecutor, FirebirdBatchExecuteCommandExecutor, FirebirdCommitTransactionCommandExecutor, and FirebirdRollbackTransactionCommandExecutor. Fixes #40510 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * Resolve lazy-send transaction sentinel and preserve pending work on reject Mirrors the fixes accepted on PR #40511 for the same shared files: FirebirdTransactionIdGenerator#isTransactionActive now resolves Firebird's INVALID_OBJECT sentinel (0xFFFF) to the connection's most recently started transaction instead of rejecting it outright, matching terrymanu's review finding on this PR. FirebirdFrontendEngine#handleException now also excludes InvalidTransactionHandleException from poisoning the active transaction, proactively porting #40511's P1 fix since this branch throws the same exception type and has the identical latent regression. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * Fix trailing-whitespace blank lines from the merge resolution Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * Resolve Firebird lazy transaction handles by negotiated mode and latest object The INVALID_OBJECT placeholder is only valid when lazy send was negotiated and the connection's most recently allocated object is a transaction, and it can arrive as 0xFFFF or as the sign-extended -1 that xdr_short produces. Commit and rollback now use the resolved ID for validation, execution and cleanup so the transaction no longer stays registered after a placeholder commit or rollback. Assisted with AI Claude (Claude Code). Affected files: FirebirdLatestObjectRegistry, FirebirdTransactionIdGenerator, FirebirdStatementIdGenerator, FirebirdBlobHandleGenerator, FirebirdCommit/RollbackTransactionCommandExecutor, FirebirdAcceptPacket, FirebirdAuthenticationEngine, FirebirdFrontendEngine and their tests. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * Normalize signed Firebird transaction handles and apply review standards Mask the wire transaction handle to 16 bits before lookup so sign-extended concrete handles resolve, mark the per-allocation registry paths as high frequency, make the registry constructor private, order private helpers after their callers, restore protocol-version state in the authentication test, and replace two-case parameterized tests with ordinary tests. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * Keep Firebird transaction handles within the 16-bit wire range Allocate transaction handles from 1 to 0xFFFE and wrap around, so every handle returned by START survives the 16-bit normalization applied to COMMIT, ROLLBACK and lookups, and never equals the lazy placeholder. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
terrymanu
left a comment
There was a problem hiding this comment.
Summary
This PR validates transaction handles before creating BLOBs and completes lazy-protocol handling, signed-handle compatibility, and transaction cleanup. The two naming issues are accepted as non-blocking for this review and will be addressed in a follow-up PR.
Result
Review Result: Mergeable
No other blocking issues were found within the explicitly accepted scope. This conclusion applies to code scope only.
Evidence
- Two independent assessments completed, with review-ledger and session validation passing.
- Checkstyle and Spotless passed for all 21/21 changed files.
- All 195 existing repository tests and 8 wire-protocol state sequences passed for the same head.
Coverage
Head: f25f4c5ba67c51359eeddd51db649ef825c47fe6. All 21 changed files were covered.
CI was not reviewed. A full Maven build and live-database E2E tests were not performed. The shared SNAPSHOT dependencies used by direct-source tests were not verified to have been built from the reviewed head.
Issue
Fixes #40393
FirebirdCreateBlobCommandExecutorregistered a BLOB and returned success forop_create_blob2regardless of the transaction handle in the packet, including a handle that was never started. The real Firebird server rejects this withisc_bad_trans_handle.Fix
Validate the transaction handle via
FirebirdTransactionIdGenerator#isTransactionActive, throwing the existingInvalidTransactionHandleExceptionon an unknown handle. This mirrors the identical check already present inFirebirdExecuteStatementCommandExecutor,FirebirdBatchExecuteCommandExecutor,FirebirdCommitTransactionCommandExecutor, andFirebirdRollbackTransactionCommandExecutor— no new abstractions, exception types, or mapper registrations needed.Verification
assertExecuteWithUnknownTransactionHandle) fails against the pre-fix code for the right reason, then restored it.FirebirdCreateBlobCommandExecutorTestpass with the fix.spotless:apply/checkstyle:check -Pcheckclean on both changed files; no line exceeds 200 characters.AI assistance disclosure
Assisted with AI Claude (Claude Code) for investigating the root cause, implementing the fix, and writing the regression test. Affected files:
FirebirdCreateBlobCommandExecutor.java,FirebirdCreateBlobCommandExecutorTest.java.🤖 Generated with Claude Code