You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Deleting a BMC failed on MySQL: delete() asked the server for @@in_transaction, which only MariaDB has. MySQL returned error 1193, delete() read that as a lost transaction, and the retry called beginTransaction() on a still-open one, which throws.
inTransaction() now sets a savepoint after BEGIN and releases/re-sets it after each statement. A savepoint lives only as long as its transaction, so a failed release means the server ended it (deadlock). Same behavior on MariaDB and MySQL.
New unit tests: clean delete, rerun after the server ends the transaction, rollback when the BMC row delete keeps failing. The stub models the savepoint.
Verification: Pest unit suite in php:8.2-cli, 294 passed; the 3 new tests fail on main's code. Separately probed SAVEPOINT/RELEASE SAVEPOINT through PDO prepared statements on mysql:8.0 and mariadb:10.11 (works alive, fails after a server-side rollback). CI runs MariaDB only.
Risk: low; confined to BmcRepository::delete().
Summary by CodeRabbit
Bug Fixes
Improved the reliability of delete operations when a database transaction ends unexpectedly, helping prevent incomplete or failed deletions.
BmcRepository::delete() asked the server for @@in_transaction, which only
MariaDB has. On MySQL the query failed, delete() read that as a lost
transaction, retried begin on a live one, and threw. A savepoint lives only
as long as its transaction, so releasing it works on both databases.
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
No actionable comments were generated in the recent review.
Walkthrough
BmcRepository now uses a named savepoint to check transaction status during BMC deletion instead of querying @@in_transaction. The unit-test fixtures and tests cover savepoint handling, transaction endings during deletion, and repeated BMC-row deletion failures.
Each delete attempt creates a named savepoint and returns false if creation fails. inTransaction() releases the savepoint, returns false if release fails, and otherwise recreates it to determine transaction status.
Deletion tests and database fixtures tests/Unit/BmcRepositoryDeleteTest.php, tests/bootstrap-unit.php
Tests cover a successful deletion, a transaction ending during member deletion, and repeated BMC-row deletion failures. The fixtures track savepoint state and simulate transaction endings without queued @@in_transaction responses.
This change fixes BMC deletion on MySQL by replacing an unsupported transaction-state query with a savepoint check. No concrete merge-blocking risk was identified, and the change is confined to the delete path.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the fix and the affected area: BMC deletion on MySQL. The raw summary shows the change centers on BmcRepository delete and transaction checks, which matches the title. The title is sho…
Description check
The description covers the summary of the change and the verification performed, and it links the issue (Fixes #76). It explains the root cause, the savepoint approach, the new tests, and the risk. It…
Linked Issues check
Issue #76 is the only direct linked target and is open. Its coding requirement is a transaction-state check that works on MySQL and MariaDB, with tests. At head, lib/BmcRepository.php replaces the @@i…
Out of Scope Changes check
The changes are confined to lib/BmcRepository.php (delete(), inTransaction(), and the DELETE_SAVEPOINT constant), tests/Unit/BmcRepositoryDeleteTest.php (new tests and helpers), and tests/bootstrap-un…
Full details: Title check
Explanation
The title names the fix and the affected area: BMC deletion on MySQL. The raw summary shows the change centers on BmcRepository delete and transaction checks, which matches the title. The title is short and specific enough for a reviewer to see the main change.
Full details: Description check
Explanation
The description covers the summary of the change and the verification performed, and it links the issue (Fixes #76). It explains the root cause, the savepoint approach, the new tests, and the risk. It does not fill the 'Requirements affected' section, and it does not tick the checklist items (signed-off commits, docs/PLAN.md and REQUIREMENTS.md updates, decision record). The template's Requirements section and checklist are missing or unaddressed.
Resolution
Consider adding: a 'Requirements affected' entry (or 'none'), and a note on the checklist items (commit sign-off, whether docs/PLAN.md or docs/REQUIREMENTS.md need updates, and whether a decision record under docs/decisions/ applies). The template's section headings are not used, so restructuring under the Summary, Issue, Requirements affected, Verification, and Checklist headings would help.
Full details: Linked Issues check
Explanation
Issue #76 is the only direct linked target and is open. Its coding requirement is a transaction-state check that works on MySQL and MariaDB, with tests. At head, lib/BmcRepository.php replaces the @@in_transaction query with a private inTransaction() method. It runs RELEASE SAVEPOINT redfish_delete, then sets the savepoint again. A failed release means the server ended the transaction. delete() sets the savepoint after each db_begin_transaction() and checks inTransaction() after each statement. On a failed attempt it rolls back only while the transaction is still open, and it retries up to DELETE_ATTEMPTS. Per the PR description, three new unit tests cover a clean delete, a rerun after a server-ended transaction, and a rollback when the BMC row delete keeps failing. The tests use a stub that models the savepoint. The stub cannot prove real MySQL behavior. The MySQL behavior rests on the author's external PDO probes on mysql:8.0 and mariadb:10.11, which this review could not reproduce. The issue's alternative CI matrix leg or README narrowing is not in this PR. It is a CI or documentation item, not a coding requirement, so it does not affect this verdict. Scope note: the changed-file diff could not be read, so the test file and bootstrap contents are taken from the supplied summaries.
Full details: Out of Scope Changes check
Explanation
The changes are confined to lib/BmcRepository.php (delete(), inTransaction(), and the DELETE_SAVEPOINT constant), tests/Unit/BmcRepositoryDeleteTest.php (new tests and helpers), and tests/bootstrap-unit.php (the stub's savepoint support and removal of the @@in_transaction queue). All of these support the #76 fix or its tests. The head file read of lib/BmcRepository.php shows no unrelated edits in the delete path, export, import, or audit code. The changed-file diff was unavailable, so the test and bootstrap changes are judged from the summaries only.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
A rabbit watched the savepoint glow, And traced each step the queries go. When transactions came to an end, The tests checked each path again. “Now BMC deletes have a trail!” The rabbit thumped its happy tail.
Recent review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: f2573aea-331e-4776-b229-a5544dbc6a0c
Commits
Reviewing files that changed from the base of the PR and between dd8d5b6 and 8077a12.
Files selected for processing: 3
lib/BmcRepository.php
tests/Unit/BmcRepositoryDeleteTest.php
tests/bootstrap-unit.php
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #76
Deleting a BMC failed on MySQL:
delete()asked the server for@@in_transaction, which only MariaDB has. MySQL returned error 1193,delete()read that as a lost transaction, and the retry calledbeginTransaction()on a still-open one, which throws.inTransaction()now sets a savepoint after BEGIN and releases/re-sets it after each statement. A savepoint lives only as long as its transaction, so a failed release means the server ended it (deadlock). Same behavior on MariaDB and MySQL.Verification: Pest unit suite in php:8.2-cli, 294 passed; the 3 new tests fail on main's code. Separately probed
SAVEPOINT/RELEASE SAVEPOINTthrough PDO prepared statements on mysql:8.0 and mariadb:10.11 (works alive, fails after a server-side rollback). CI runs MariaDB only.Risk: low; confined to
BmcRepository::delete().Summary by CodeRabbit