Id either:
- do an optimistic style of locking on the table, i.e. read a unique
token from the row, do stuff with the session, go back to write the
data in a transaction, insure the token is the same, then update it
with a new token, else throw new concurrency exception
- use a column in the row indicating it's LOCKED, or a separate lock
table
- insure that a particular session is only going to hit on one
webserver at a time and not worry about multiple servers
- use file or memcached sessions
however, if row-locking via a cursor does it, thats fine, i dont have
much experience where this kind of thing is an issue since people
usually use round-robin DNS or similar....I dont like to play with
locking because deadlocks are the most disastrous failure
imaginable. anyway, pull out the connection() and just lock the
row; as long as you hold onto that connection, thats the one that
gets used within that thread.
there is also an upcoming backwards-compatible change to the engine
coming in the next few weeks which will provide a SQLSession
interface to give finer-grained control over what connection is dealt
with in a particular thread.
On Mar 15, 2006, at 1:38 PM, Florian Boesch wrote:
How do you solve the problem of sessions represented as rows in
database,
accessed by an array of web-application servers?
The idea is that concurrent write access to session data will
happen inevitably,
and since throwing an error page at your user everytime it does is
not a
satisfactory solution you force no errors to happen by locking.
It'd be grateful not to do that pattern, and if you see some way
which has
escaped me please tell me so.
Quoting Michael Bayer <[EMAIL PROTECTED]>:
this is a wide open question. personally im not a fan locking/cursor
games.
but to answer the question "how do we do this", id need to see, "what
do we want?" what would you want a code example using this concept
to look like ? are we talking ORM, SQL construction layer here ? a
method off of engine ? right now, you can just say
engine.connection
().cursor() and just do what you want with it. what else ?
On Mar 15, 2006, at 5:22 AM, Florian Boesch wrote:
Hi,
I just noticed that Cherrypy's session implementation locks a row
representing a
session by a for update clause.
It releases this lock by closing the cursor.
How do I implement similar behavior in sqlalchemy (aparts from
accessing the
underlying db-api and instanciating/closing db-cursors myself)?
Cheers,
Florian
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting
language
that extends applications into web and mobile media. Attend the
live webcast
and join the prime developer group breaking into this new coding
territory!
http://sel.as-us.falkag.net/sel?
cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Sqlalchemy-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting
language
that extends applications into web and mobile media. Attend the
live webcast
and join the prime developer group breaking into this new coding
territory!
http://sel.as-us.falkag.net/sel?
cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Sqlalchemy-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting
language
that extends applications into web and mobile media. Attend the
live webcast
and join the prime developer group breaking into this new coding
territory!
http://sel.as-us.falkag.net/sel?
cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Sqlalchemy-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Sqlalchemy-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users