Skip to content

Fix race condition on multiple bill creation

klonfish requested to merge klonfish/cospend-nc:fix_bill_id_race_cond into master

While testing the split modes with personal parts, I sometimes encountered the problem that when multiple bills were created, some owers got assigned two times to one bill and the some bills were created with no ower at all (see attached image of the bill list after a page reload). I think this was due to a race condition when the ID of the inserted bill is fetched by selecting the maximum ID in the table. This could lead to to the situation that the simultaneous requests from JS all use the ID of the same (last) bill created instead of the one actually created during that request. It seems that using getLastInsertId() to explicitly get the last ID inserted by the current connection fixes this issue.

2019-04-30-111230_405x210_scrot

Edited by klonfish

Merge request reports