This sounds like your transaction has not committed yet.
When we started implementing celery message queuing we would run into this all the time. To fix it we wrote a special piece of logic so that the messages for the message queue would not get queued until the commit occurred. This had the added benefit of not sending the message to the queue if the transaction rolled back.
On Thu, Apr 21, 2016 at 2:58 PM, John de la Garza <john@jjdev.com> wrote:
I have two programs running. One process does an insert. After the insert a message is sent to a message bus. Then the second process responds to the message by inserting a new row that depends on the primary key of the first insert.
Some times I get an integrity error from the second process. I then wait and try again with success.
When my first insert returns what does this mean? Does it mean that the DB has accepted the request and will do it soon? Or does it mean that the DB has accepted the request and it will now be available?