[sqlalchemy] Re: InvalidRequestError: The transaction is inactive due to a rollback... using sqlite with multiple commits.

2009-04-30 Thread Daniel

Hello Michael,

Thank you for your replies.  I've just tried to create a testcase but
proven to myself that it does raise an exception.  I'll go back and
double check where I might be catching and passing on the exception.

Daniel

On Apr 29, 3:19 pm, Michael Bayer mike...@zzzcomputing.com wrote:
 how is it that you know this is due to the SQLite timeout  ?  did you  
 create a test case ?  creating a fully reproducible test case would be  
 the next step.

 On Apr 29, 2009, at 5:15 PM, Daniel wrote:



  I'm not catching it or re-raising it.  Where else could I look to
  solve this.

  On Apr 29, 11:57 am, Michael Bayer mike...@zzzcomputing.com wrote:
  Daniel wrote:

  I've learned a bit more.  Apparently the sqlite database  
  occasionally
  gets locked by another process and that lock lasts longer than the
  five second default timeout.  SQL Alchemy quietly issues a ROLLBACK,
  but doesn't say anything more about it.  The result is that the
  session is no longer active and eventually produces the error I
  mentioned above.  Here are the log messages showing the insert  
  failing
  after the five second default timeout.

  2009-04-28 15:10:48,118 INFO sqlalchemy.engine.base.Engine.0x...ae70
  INSERT INTO table (id, value) VALUES (?, ?)
  2009-04-28 15:10:48,118 INFO sqlalchemy.engine.base.Engine.0x...ae70
  [1, 'my value']
  2009-04-28 15:10:53,148 INFO sqlalchemy.engine.base.Engine.0x...ae70
  ROLLBACK

  Is there some way to configure SQL Alchemy to raise an exception  
  when
  it issues the rollback, or when it finds the database locked?

  SQLAlchemy definitely raises an exception if the DBAPI sends one.  a
  ROLLBACK does not occur if there was no exception thrown.   check if
  you're catching it and not re-raising.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[sqlalchemy] Re: InvalidRequestError: The transaction is inactive due to a rollback... using sqlite with multiple commits.

2009-04-29 Thread Michael Bayer

Daniel wrote:

 I've learned a bit more.  Apparently the sqlite database occasionally
 gets locked by another process and that lock lasts longer than the
 five second default timeout.  SQL Alchemy quietly issues a ROLLBACK,
 but doesn't say anything more about it.  The result is that the
 session is no longer active and eventually produces the error I
 mentioned above.  Here are the log messages showing the insert failing
 after the five second default timeout.

 2009-04-28 15:10:48,118 INFO sqlalchemy.engine.base.Engine.0x...ae70
 INSERT INTO table (id, value) VALUES (?, ?)
 2009-04-28 15:10:48,118 INFO sqlalchemy.engine.base.Engine.0x...ae70
 [1, 'my value']
 2009-04-28 15:10:53,148 INFO sqlalchemy.engine.base.Engine.0x...ae70
 ROLLBACK

 Is there some way to configure SQL Alchemy to raise an exception when
 it issues the rollback, or when it finds the database locked?

SQLAlchemy definitely raises an exception if the DBAPI sends one.  a
ROLLBACK does not occur if there was no exception thrown.   check if
you're catching it and not re-raising.



--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[sqlalchemy] Re: InvalidRequestError: The transaction is inactive due to a rollback... using sqlite with multiple commits.

2009-04-29 Thread Michael Bayer

how is it that you know this is due to the SQLite timeout  ?  did you  
create a test case ?  creating a fully reproducible test case would be  
the next step.


On Apr 29, 2009, at 5:15 PM, Daniel wrote:


 I'm not catching it or re-raising it.  Where else could I look to
 solve this.

 On Apr 29, 11:57 am, Michael Bayer mike...@zzzcomputing.com wrote:
 Daniel wrote:

 I've learned a bit more.  Apparently the sqlite database  
 occasionally
 gets locked by another process and that lock lasts longer than the
 five second default timeout.  SQL Alchemy quietly issues a ROLLBACK,
 but doesn't say anything more about it.  The result is that the
 session is no longer active and eventually produces the error I
 mentioned above.  Here are the log messages showing the insert  
 failing
 after the five second default timeout.

 2009-04-28 15:10:48,118 INFO sqlalchemy.engine.base.Engine.0x...ae70
 INSERT INTO table (id, value) VALUES (?, ?)
 2009-04-28 15:10:48,118 INFO sqlalchemy.engine.base.Engine.0x...ae70
 [1, 'my value']
 2009-04-28 15:10:53,148 INFO sqlalchemy.engine.base.Engine.0x...ae70
 ROLLBACK

 Is there some way to configure SQL Alchemy to raise an exception  
 when
 it issues the rollback, or when it finds the database locked?

 SQLAlchemy definitely raises an exception if the DBAPI sends one.  a
 ROLLBACK does not occur if there was no exception thrown.   check if
 you're catching it and not re-raising.
 


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[sqlalchemy] Re: InvalidRequestError: The transaction is inactive due to a rollback... using sqlite with multiple commits.

2009-04-28 Thread Michael Bayer

squelching typically means one of two things.

either you're doing this:

try:
 # do stuff with session
except:
print error !
# .. keep going

or, you are allowing concurrent access to a single session with  
multiple threads, one of your threads is throwing an exception  
(usually due to the corrupted state of the session, since the session  
is not mutexed) and the other thread gets this error.


On Apr 28, 2009, at 4:53 PM, Daniel wrote:


 Hello,

 In my application I have a function that looks more or less like this

def run(self):
# process first object in sequence
for firstObject in firstObjects:
self.session.add(firstObject)
self.session.commit()

# process second object in sequence
# lots of these, so break along the way
count = 0
for secondObject in secondObjects:
self.session.add(secondObject)
count += 1
if (count  100):
#**
self.session.commit()
#**
count = 0
time.sleep(1)   # pause to let other process access
 the db
self.session.commit()

# process third objects
for thirdObject in thirdObjects:
self.session.add(thirdObject)
self.session.commit()

 The commit nested inside the second loop (highlighted by asterisks) is
 potentially called many times (occasionally there are thousands of
 objects to deal with).  intermittently that commit will produce the
 following error:

 Traceback (most recent call last):
  File C:\Aptina\pop\tester\AptinaStagingService.py, line 106, in
 __init__
self.run(self.pushPath,self.stagingPath)
  File C:\Aptina\pop\tester\AptinaStagingService.py, line 231, in
 run
self.session.commit()
  File c:\python25\Lib\site-packages\sqlalchemy\orm\session.py, line
 673, in commit
self.transaction.commit()
  File c:\python25\Lib\site-packages\sqlalchemy\orm\session.py, line
 378, in commit
self._prepare_impl()
  File c:\python25\Lib\site-packages\sqlalchemy\orm\session.py, line
 351, in _prepare_impl
self._assert_is_active()
  File c:\python25\Lib\site-packages\sqlalchemy\orm\session.py, line
 247, in _assert_is_active
The transaction is inactive due to a rollback in a 
 InvalidRequestError: The transaction is inactive due to a rollback in
 a subtransaction.  Issue rollback() to cancel the transaction.

 I've read elsewhere in this group (http://groups.google.com/group/
 sqlalchemy/browse_thread/thread/b87af73232998fe4) about this error
 message, but I'm not sure what they mean by squelching the original
 exception somewhere.  Can someone please help me understand why I'm
 getting this error and ideas on how to fix it.

 Thanks.

 


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[sqlalchemy] Re: InvalidRequestError: This transaction is inactive

2007-01-24 Thread Jose Soares

Jose Soares ha scritto:
 Michael Bayer ha scritto:
   
 not sure about that, i thought maybe the multiple flush()es are
 breaking something but I just added a test case and it doesnt
 reproduce.  make sure youre on the most recent versions since that was
 broken a few versions back...

   
 
 This error happens some times, not every time.
 my versione is SQLAlchemy-0.3.0

 jo


   
Hi Mike,
I upgraded to 0.3.4
but this function works only without create_transaction()...

def add_user(self,data):
#transaction = session.create_transaction()
try:
anagrafica = Anagrafica(
nome = data.get('display_name'),
email= data.get('email'),
)
session.save(anagrafica)
session.flush()
user = User(
id_anagrafica= anagrafica.id, #ultimo record 
inserito in anagrafica
data_inizio_attivita = data.get('data_inizio_attivita'),
data_fine_attivita   = data.get('data_fine_attivita'),
)
for item in data.get('dettaglio'):
if item.get('cod_ruolo'):
user.ruoli.append(UserGroup(
   id_operatore = item.get('id_operatore'),
   group_id = item.get('cod_ruolo'),
   id_asl   = item.get('id_asl'),
   )
)
session.save(user)
session.flush()
#transaction.commit()
return inserito il record %d!%user.id
except:
#transaction.rollback()


jo

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: InvalidRequestError: This transaction is inactive

2007-01-24 Thread Michael Bayer

then its likely a threading issue.  not sure what your setup is but  
you should make sure that the session is used in only a single  
thread, typically via using a thread local variable (or using  
SessionContext which provides this service).


On Jan 24, 2007, at 8:28 AM, Jose Soares wrote:


 Michael Bayer ha scritto:
 not sure about that, i thought maybe the multiple flush()es are
 breaking something but I just added a test case and it doesnt
 reproduce.  make sure youre on the most recent versions since that  
 was
 broken a few versions back...


 This error happens some times, not every time.
 my versione is SQLAlchemy-0.3.0

 jo



 


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: InvalidRequestError: This transaction is inactive

2007-01-22 Thread Michael Bayer

not sure about that, i thought maybe the multiple flush()es are
breaking something but I just added a test case and it doesnt
reproduce.  make sure youre on the most recent versions since that was
broken a few versions back...


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---