Draft
Conversation
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The
*_and_logfunctions (update_and_log,insert_and_log, etc.) internally create anEcto.Multiand callrepo.transaction(). When these functions are called from within an outerEcto.Multi.runcallback as happens with valiot-app'smultiple_function_bodyfor batch mutations likeupdateMultipleRecipethis creates a nested Multi-inside Multi pattern.This error path has existed since Ecto 3.0 (PR #2867). The crash surfaced now because the DISABLE_OLD_RECIPES operation triggered the updateMultipleRecipe → Ecto.Multi → update_and_log → nested Ecto.Multi path for the first time in production.
▎ "operation :rollback is rolling back unexpectedly... Nested transactions are discouraged when using
Ecto.Multi. Consider flattening out the transaction instead."
Stack trace confirms the crash at
EctoTrail.run_logging_transaction/5(line 342) called fromEcto.Multi.apply_operation/5.Fix
Each
*_and_logfunction andlog/5now checksrepo.in_transaction?():repo.transaction()Ecto.Multi+repo.transaction()path (unchanged)Both paths produce identical return types and audit log behavior.
Fixes: THBK-950