[Twisted-Python] mutexes in twisted.enterprise?

Bob Ippolito bob at redivi.com
Fri Apr 19 02:53:44 EDT 2002


It's not the order of the rows, it's the order in which the database 
*processes* those rows.  I'm not doing inserts, I'm calling user defined 
functions that do a pretty complex set of updates and inserts on 
multiple tables depending on the new data and existing data.  It really 
needs to process them in the order that they are received.

It's not that the order of every row is significant, the rows represent 
certain events.  Such as remove or add.  There's a big difference 
between add and then remove versus remove and then add.. it's very much 
not commutative, like matrix multiplication.  The order has meaning.  
Each row does have a timestamp, but there isn't a way to say "process 
this once you're sure you're not going to receive another row with an 
earlier timestamp than yourself" and it's not easy to insert rows out of 
order because you need to know exactly what the preceding row(s) 
accomplished, roll it all back, do your thing, and then commit them 
again.

If I can make sure that the rows are processed in the order that they 
are received, I don't have to worry about the consistency.

On Thursday, April 18, 2002, at 10:50 PM, Sean Riley wrote:

> well, knowing nothing about your application... relying on the order of 
> rows
> in a relational database table is generally a bad practice - this order 
> is
> really arbitrary and in some cases could actually change (depending on 
> the
> db you are using - clustered indices as primary keys for example). If 
> you
> want sequence information, I'd recommend you embed it in your rows - 
> don't
> rely on the order of the rows in the table.
>
> anyway.. you can perform syncronous operations through a
> twisted.enterprise.ConnectionPool by creating your own Transaction 
> objects
> and passing them to ConnectionPool::_runIteraction(). Maybe a queue 
> with a
> single db thread that you use syncronously?
>
> twisted.enterprise needs more docs... especially the Row interface, but 
> it
> is good to hear that someone else is using it.
>
> -----Original Message-----
> From: twisted-python-admin at twistedmatrix.com
> [mailto:twisted-python-admin at twistedmatrix.com]On Behalf Of Bob Ippolito
> Sent: Thursday, April 18, 2002 8:14 PM
> To: twisted-python at twistedmatrix.com
> Subject: Re: [Twisted-Python] mutexes in twisted.enterprise?
>
>
> Well see the thing is that yes, the db supports transactions [postgres],
> but I need to make sure the db processes requests in the order that
> they're received over the wire, not whenever that particular db
> connection gets around to it.
>
> I don't think I'm currently having issues w/ it right now, but I'm just
> concerned that potentially it could be a problem someday.
>
> On Thursday, April 18, 2002, at 09:04 PM, Andrew Bennetts wrote:
>
>> On Thu, Apr 18, 2002 at 08:49:41PM -0400, Bob Ippolito wrote:
>>>
>>> I'm doing some twisted.enterprise crap and I was wondering if it was
>>> safe to use thread mutexes to make sure that only one interaction goes
>>> at a time?  I have some queries that shouldn't run in parallel under
>>> certain conditions and I believe forcing it w/ mutexes would be the
>>> safest and easiest solution... but I haven't looked much into what's
>>> going on under the hood and I'm wondering if it'll do Very Bad Things?
>>
>> Interactions all run inside a db transaction, I think (someone please
>> correct me if I'm wrong).  So if your DB supports transactions, then 
>> you
>> should be fine already.  I'm presuming that by "interaction" you mean
>> twisted.enterprise.adbapi.Augmentation.runInteraction?
>>
>>> I'm using Twisted 0.15.2, I believe.. I don't want to upgrade at the
>>> moment because it's in testing for a few weeks.
>>
>> So already we have legacy systems to support :)
>>
>> I'm not aware of any significant changes to twisted.enterprise since
>> 0.15.2.
>>
>> -Andrew.
>>
>>
>> _______________________________________________
>> Twisted-Python mailing list
>> Twisted-Python at twistedmatrix.com
>> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>
>
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>
>
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python





More information about the Twisted-Python mailing list