Re: transactions, row locking, race condition?

From: Tore Halset (halse..vv.ntnu.no)
Date: Mon Apr 11 2005 - 07:31:45 EDT

  • Next message: tnaki..ofthome.net: "Re: transactions, row locking, race condition?"

    On Apr 11, 2005, at 10:03, tnaki..ofthome.net wrote:

    > Of course. It's about a phone polling system. Several operators work
    > concurrently, each repetatively loading new contacts to poll from the
    > database as they work.
    > My idea for loading the next contact goes something like this:
    > 1. begin transaction
    > 2. select 1 poll candidate from candidates FOR UPDATE (to lock the
    > record)
    > 3. update a timestamp signifying that this candidate is taken
    > 4. retrieve the candidate
    > 5. end transaction

    Hello.

    What about dropping point 2 and use optimistic locking at point 3? It
    someone else has taken that candidate you will just have to try once
    more.

      - Tore.



    This archive was generated by hypermail 2.0.0 : Mon Apr 11 2005 - 07:31:48 EDT