Ensure note is promoted to discussion within reply create transaction
Previously a note on a merge request would be committed to the database
before its type
is promoted to DiscussionNote
. However, as we saw in
#301237 (closed), if a user replies
to an individual note on the merge request but the UPDATE to the note
fails (e.g. due to a SQL timeout), the note will persist in the database
but have the wrong discussion type
.
This can block users from being able to merge a merge request because the backend will detect an unresolved discussion. However, the UI won't show any unresolved discussions because the first note will erroneously appear to be an individual note, which cannot be resolved since it's not a discussion.
To avoid this issue, we now promote the type
within the save
transaction so that the note will always persist with the right value.
SQL statements
Before
After
Closes #301237 (closed)