On Apr 10, 9:01 am, Christian Welzel <gaw...@camlann.dewrote:
>
currently i'm looking for a way to repeat a rolled back transaction
in a nice way.
my problem: in my webapp (a browser game) i get a lot of deadlocks
in the mysql innodb tables. mysql then terminates the transaction
and tells me to restart the transaction.
for this i have to rebuild my queries and send them to the database
(and probably get the next deadlock).
Does anybody know a nice way to build some logic into the php code
to handle this?
Well, it's possible that the reason you're getting deadlocks in the
first place is that too many clients are trying to access the
database
simultaneously. So you may be attacking the wrong bottleneck; rather
than thinking about code, you should think about upgrading the
database
server or at least change some configuration settings...
Failing that, you could try batch processing:
1. A PHP script writes a complete set of queries into a text file
located in a pre-defined directory.
2. Every, say, minute, a cron job starts a shell (or PHP) script that
searches the pre-defined directory for text files, executes SQL in
them, and deletes ones that have been executed.
You may need to do some equilibristics to make sure that only one
instance of batch processor runs at a time.
Cheers,
NC