Lock wait timeout exceeded; Try restarting transaction

172 views
Skip to first unread message

frasse

unread,
Dec 12, 2011, 4:50:13 PM12/12/11
to web2py-users
Hi
I have two function one is running in controller when users access the
page (manageGame) and one is running as cron job (cleanDB). I am
geting "Lock wait timeout exceeded; Try restarting transaction"
error in mysql database.
How can I avoid this problem ?

def manageGame():
now = datetime.datetime.now()
activeBigGame = db((db.games.LotteryDrawTime > now) &
(db.games.Type == 'Big Game') & (db.games.active == 'Yes')).select()
activeone_of_7 = db((db.games.Type == '1 of 7')& (db.games.active
== 'Yes') & (db.games.LotteryDrawTime > now)).select()
db(db.games.LotteryDrawTime < now).update(active = 'No')
......


def cleanDB(now):
db((db.games.LotteryDrawTime < now) &(db.games.numberPlayer ==
0) ).delete()

Thanx Frasse

Anthony

unread,
Dec 12, 2011, 5:10:57 PM12/12/11
to web...@googlegroups.com
You probably need to add db.commit() to your cron job to commit the transaction. This is necessary in external scripts, but not in models, views, and controllers. See http://web2py.com/book/default/chapter/06#commit-and-rollback and http://web2py.com/book/default/chapter/04#Cron.

Anthony
Reply all
Reply to author
Forward
0 new messages