Actions
Bug #19698
closedsave_with_unique_name hides other transaction errors
Story points:
-
Release:
Release relationship:
Auto
Description
save_with_unique_name works like this:
conn.exec_query 'SAVEPOINT save_with_unique_name' begin save! rescue ActiveRecord::RecordNotUnique => rn # tries different names, uses # "ROLLBACK TO SAVEPOINT" # to recover from transaction errors ensure conn.exec_query 'RELEASE SAVEPOINT save_with_unique_name' end
It seems that if some other transaction error happens, then
- transaction is aborted
- the "ensure" block runs "RELEASE SAVEPOINT"
- because the transaction is aborted, it rejects "RELEASE SAVEPOINT"
- it raises a new error about not being able to accept "RELEASE SAVEPOINT" instead of propagating the original error
The result is a cryptic error about ignoring commands in a failed transaction and not the original error that gives some indication of what was wrong.
I need to read up on savepoints, but it may be that there's no real benefit to releasing the savepoint here, presumably it will be released when the transaction is closed either way.
Actions