Timeline for Best practice regarding concurrency for INSERT into a table with composite primary key?
Current License: CC BY-SA 3.0
6 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Nov 1, 2015 at 0:06 | comment | added | Joishi Bodio | Exception handling at the DB level is a thing, for sure. Often times the best solution is to let the attempt it, catch the exception, and send back a message accordingly. | |
| Oct 31, 2015 at 15:55 | comment | added | Pieter-Jan Vandenbussche | Alright, I'll implement that. Thanks for the helpful answers! | |
| Oct 31, 2015 at 1:46 | comment | added | Erwin Brandstetter | @Pieter-JanVandenbussche: Yes, you'd get 23505 unique_violation. See error codes. But it should only happen on extremely rare occasions under heavy concurrent write load. | |
| Oct 30, 2015 at 23:45 | comment | added | Pieter-Jan Vandenbussche | Oh, so it's not bad practice to just let it error out? How would I then give a response to the client that the relation is already there? Check if the exception that was thrown is a duplicate key exception and assume it's because I tried to insert a relation which is already there? | |
| Oct 30, 2015 at 2:28 | history | edited | Erwin Brandstetter | CC BY-SA 3.0 | added 585 characters in body |
| Oct 30, 2015 at 2:13 | history | answered | Erwin Brandstetter | CC BY-SA 3.0 |