On Jan 11, 2009, at 11:40 AM, Darren Govoni wrote:

>
> Sorry for the haze. I'm using PostgreSQL and am checking their docs on
> isolation to see that it is consistent with SA.
>
> but here is a simplified example.
>
> I have 2 rows in the database with 1 column "FOO". Both rows have a  
> NULL
> value for column "FOO".
>
> Two programs, A and B. They are the same program.
>
>
> I have a query that: selects for update, all rows with FOO=NULL, limit
> 1. This will block all other processes attempting the same query.
>
>
> A goes first and selects for update. B thus blocks. Both are looking  
> for
> 1 row, FOO=NULL.
>
> A query returns 1 row. Inside the transaction. A updates that row to
> FOO=A. B is still waiting. Only 1 row is updated, because 1 is  
> returned
> from the select. I use session.add(row) to simply re-add the mapped
> object after changing the value.
>
> A commits its change to 1 row. The second row is still FOO=NULL.
>
> B unblocks. B returns 0 results.
>
> A, B exit.
>
> Re-run B.
>
> B finds 1 row where FOO=NULL and sets FOO=B.
>
> B exits.
>
> Does that help clarify?

yeah I understood all that (except for the session.add(row) part,  
which doesn't seem related).   And no, it does not sound correct, in  
that when B is unblocked into the transaction, it should see the same  
thing as if it had just been run completely after the A transaction  
were committed.

in any case you should view the SQL logs (echo=True) to see what the  
conversation is saying.   If that all looks as expected, open up two  
postgres consoles and try the same conversation manually.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to