My code is as follows:
- read max(id) from table A
- insert new row with new_id = max(id)+1 in table A
- insert multiple rows in another table B, with this new_id.
So if there are multiple users trying to do this operation at the same time, they can get the same max(id) and insert two rows with the same id. Can I use TRANSACTION_SERIALIZABLE to prevent this, or is there another way to do it?