Closed imorland closed 4 years ago
Could we have that code run inside a DB transaction? That way if it fails later on the post numbers aren't completely wrong (I think that's how that works anyway, DB changes will be reverted if error is thrown).
Sure, just looking at a related issue at present (merge fails on very large threads)
I'll wrap this and the numbering fix in a transaction in the next commit
FYI, the transaction should apply for the whole code - not just each part separately, as the DB would still be modified if the second DB changes failed.
We can either wrap the whole thing in the transaction
method or manually begin, commit & rollback them - this would use a try/catch, so it's basically the same thing with more code. See more @ https://laravel.com/docs/5.8/database#database-transactions.
I'm going to close this PR, as we're working on a different solution to fix this issue. I'll open a new PR once we have it resolved
@imorland Ok, thanks for trying nonetheless!
@imorland Was going through old issues, and I saw that the issue that this PR was gonna fix still exists. Do you have any updates on the solutin?
@datitisev not yet I'm afraid. The overall issue is reasonably high in our backlog, but I've not yet had another chance to look into it in any great detail yet
Fixes #5
On the giffgaff community, we find that the previous fix does not reliably fix this issue. This was down to the
number
column onposts
not incrementing sequentially (or posts being split/deleted).By adding an additional sort on the discussion first, setting the
number
out of the current range, then continuing with the merge, everything works again 😄