Gracefully handle database rollbacks

Bug #1051890 reported by Raoul Snyman
12
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenLP
Status tracked in Trunk
2.0
Won't Fix
Undecided
Unassigned
Trunk
Fix Released
Medium
Unassigned

Bug Description

Version: {u'full': u'1.9.11-bzr2039', u'version': u'1.9.11', u'build': u'bzr2039'}

--- Details of the Exception. ---

Clicking Save on a new song

--- Exception Traceback ---
Traceback (most recent call last):
File "/Users/martin/Documents/openlp/trunk/build/pyi.darwin/OpenLP/out00-PYZ.pyz/openlp.plugins.songs.forms.editsongform", line 814, in accept
File "/Users/martin/Documents/openlp/trunk/build/pyi.darwin/OpenLP/out00-PYZ.pyz/openlp.plugins.songs.forms.editsongform", line 852, in saveSong
File "/Users/martin/Documents/openlp/trunk/build/pyi.darwin/OpenLP/out00-PYZ.pyz/openlp.core.lib.db", line 341, in get_object_filtered
File "/Users/martin/Documents/openlp/trunk/build/pyi.darwin/OpenLP/out00-PYZ.pyz/sqlalchemy.orm.query", line 2155, in first
File "/Users/martin/Documents/openlp/trunk/build/pyi.darwin/OpenLP/out00-PYZ.pyz/sqlalchemy.orm.query", line 2022, in getitem
File "/Users/martin/Documents/openlp/trunk/build/pyi.darwin/OpenLP/out00-PYZ.pyz/sqlalchemy.orm.query", line 2223, in iter
File "/Users/martin/Documents/openlp/trunk/build/pyi.darwin/OpenLP/out00-PYZ.pyz/sqlalchemy.orm.session", line 1011, in _autoflush
File "/Users/martin/Documents/openlp/trunk/build/pyi.darwin/OpenLP/out00-PYZ.pyz/sqlalchemy.orm.session", line 1587, in flush
File "/Users/martin/Documents/openlp/trunk/build/pyi.darwin/OpenLP/out00-PYZ.pyz/sqlalchemy.orm.session", line 1656, in _flush
File "/Users/martin/Documents/openlp/trunk/build/pyi.darwin/OpenLP/out00-PYZ.pyz/sqlalchemy.orm.session", line 588, in begin
File "/Users/martin/Documents/openlp/trunk/build/pyi.darwin/OpenLP/out00-PYZ.pyz/sqlalchemy.orm.session", line 196, in _begin
File "/Users/martin/Documents/openlp/trunk/build/pyi.darwin/OpenLP/out00-PYZ.pyz/sqlalchemy.orm.session", line 173, in _assert_is_active
InvalidRequestError: This Session's transaction has been rolled back due to a previous exception during flush. To begin a new transaction with this Session, first issue Session.rollback(). Original exception was: (IntegrityError) songs.lyrics may not be NULL u'INSERT INTO songs (song_book_id, title, alternate_title, lyrics, verse_order, copyright, comments, ccli_number, song_number, theme_name, search_title, search_lyrics, create_date, last_modified, "temporary") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, ?)' (None, u'Trading My Sorrows', u'', None, u'v1 v2 c1 b1 v1 v2 c1 c1', u'', u'', u'', u'', u'Blue Burst', u'', u'', 0)

--- System information ---
Platform: Darwin-11.4.0-i386-32bit

--- Library Versions ---
Python: 2.7.3
Qt4: 4.8.2
Phonon: 4.4.0
PyQt4: 4.9.1
QtWebkit: 534.34
SQLAlchemy: 0.7.7
SQLAlchemy Migrate: 0.7.2
BeautifulSoup: 3.2.1
lxml: 2.3.2
Chardet: 2.0.1
PyEnchant: -
PySQLite: -
Mako: 0.7.0
pyUNO bridge: -

Revision history for this message
Raoul Snyman (raoul-snyman) wrote :

I've seen this a couple of times before. We need to catch the InvalidRequestError, issue a rollback, and then run the query again.

Revision history for this message
Raoul Snyman (raoul-snyman) wrote :
Revision history for this message
Raoul Snyman (raoul-snyman) wrote :
Changed in openlp:
importance: Undecided → Critical
importance: Critical → Medium
Revision history for this message
Jonathan Corwin (j-corwin) wrote :

Looking at the original exception in the example above, this was due to the lyrics being None.

Looking in editsongform.py, in _processLyrics there is an catch all error trap, which means if there is an error processing the lyrics then it'll attempt to save the song without them. Wouldn't we be better off removing this error trap and letting it propagate to the user? We shouldn't ignore/hide these errors, and ideally want to fix the original cause.

Revision history for this message
Jonathan Corwin (j-corwin) wrote :

Either that or re-throw the error

tags: added: support-system
Revision history for this message
Phill (phill-ridout) wrote :
Revision history for this message
Raoul Snyman (raoul-snyman) wrote :

I think we've done a bunch of work around this, and are unlikely to get this again.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.