Skip to content

Preserve named DB transaction outcomes when returning connections - #3311

Merged
jitheshtr merged 5 commits into
linkedin:masterfrom
jitheshtr:jirajan/durable-named-delete-handoff
Nov 25, 2026
Merged

jitheshtr merged 5 commits into
linkedin:masterfrom
jitheshtr:jirajan/durable-named-delete-handoff

Conversation

@jitheshtr

@jitheshtr jitheshtr commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor
Order PR Status Runtime effect
1 (you are here) Executor (#3311) Ready for review Preserves transaction outcomes when returning connections.
2 Named-delete manifests (#3313) Ready for review Adds database operations; public DELETE is unchanged.

Summary

The executor now calls back once with the transaction outcome. On master, a hard delete returned its blob IDs before close() ran. A close() failure alone called back a second time with an error and inflated NamedBlobDBDeleteErrorCount; it did not take the IDs away from the caller. In contrast, an explicit setAutoCommit(true) failure after commit() but before the success callback could prevent the caller from receiving the IDs for an already committed delete.

A cleanup failure now leaves the acknowledged result intact. ConnectionCloseErrorCount counts autocommit reset and close() failures. A failed rollback goes directly to eviction and does not increment that counter. Connection-class failures also reach NamedBlobDBConnectionFailureCount.<dc> without counting an acknowledged write as failed.

Durability risk: Named PUT and TTL updates rely on autocommit. HikariCP 3.4.5 can recycle a connection with autocommit still off if it encounters a nonfatal reset error inside close(). After a confirmed commit or a successful rollback, the executor explicitly restores autocommit before returning the connection. If the reset fails, it discards the connection instead of letting Hikari recycle it. A failed rollback also discards the connection, without attempting a reset. A failed commit() remains indeterminate and its exception remains primary. This PR does not change delete or TTL SQL or implement restart-safe chunk cleanup.

Testing Done

  • ./gradlew --offline --no-daemon --max-workers=2 -q :ambry-named-mysql:test --tests '*MySqlNamedBlobDbTest' — 24 passed, none skipped. With a real single-connection Hikari pool backed by mock JDBC connections, the reset-failure test got the original physical connection back before the fix. It now receives both committed blob versions and checks that the next borrower receives a different physical connection. A separate case covers reset failure after rollback and preservation of the original commit error.
  • Local code review completed

Generated with GitHub Copilot CLI

Pass the locked versions to a database-local handoff before changing the name. Roll back on publication failure and leave the existing delete path unchanged.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@codecov-commenter

codecov-commenter commented Nov 24, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 56.60377% with 23 lines in your changes missing coverage. Please review.
✅ Project coverage is 50.67%. Comparing base (52ba813) to head (2015d18).
⚠️ Report is 427 commits behind head on master.

Files with missing lines Patch % Lines
.../java/com/github/ambry/named/MySqlNamedBlobDb.java 54.90% 22 Missing and 1 partial ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             master    #3311       +/-   ##
=============================================
- Coverage     64.24%   50.67%   -13.58%     
+ Complexity    10398     8715     -1683     
=============================================
  Files           840      939       +99     
  Lines         71755    80948     +9193     
  Branches       8611     9788     +1177     
=============================================
- Hits          46099    41019     -5080     
- Misses        23004    36502    +13498     
- Partials       2652     3427      +775     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

jitheshtr and others added 2 commits November 23, 2026 22:14
Publish only newly retired versions. Never reset autocommit on an unresolved transaction; discard the connection when rollback fails. Check publication and mutation atomicity from a second MySQL connection.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Separate connection-close errors from the operation result. Exercise confirmed and indeterminate commits and the Hikari eviction path. Leave delete publication and TTL SQL out of this change.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jitheshtr jitheshtr changed the title Allow cleanup publication in the named-delete transaction Preserve named DB transaction outcomes when returning connections Nov 24, 2026
jitheshtr and others added 2 commits November 23, 2026 23:01
Restore autocommit before releasing a resolved transaction. Keep cleanup failures separate from the write outcome and visible in the per-datacenter connection failure count.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jitheshtr
jitheshtr marked this pull request as ready for review November 24, 2026 07:42
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