473,498 Members | 1,832 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

transaction restart

Hi there,
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?

--
MfG, Christian Welzel aka Gawain@Regenbogen

GPG-Key: http://www.camlann.de/key.asc
Fingerprint: 4F50 19BF 3346 36A6 CFA9 DBDC C268 6D24 70A1 AD15
Apr 10 '08 #1
6 1584
Christian Welzel <ga****@camlann.dewrote in news:666rulF2icci8U1
@mid.individual.net:
Hi there,
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?
do you really need transactions for this?

it seems like you're having a MySQL issue, in particular so many
"deadlock"s?

Apr 10 '08 #2
Good Man wrote:
do you really need transactions for this?
I dont know.
We some other problems due the update of some tables what we think
we can solve using transactions. But now we are in some kind of
discrepancy.
it seems like you're having a MySQL issue, in particular so many
"deadlock"s?
This could be the case. The game code is rather old and the access
pattern is a real nightmare.

--
MfG, Christian Welzel aka Gawain@Regenbogen

GPG-Key: http://www.camlann.de/key.asc
Fingerprint: 4F50 19BF 3346 36A6 CFA9 DBDC C268 6D24 70A1 AD15
Apr 10 '08 #3
Christian Welzel wrote:
Hi there,
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?
While the other comments are correct about correcting the way you access
your tables, sometimes it's not practical. If not, about the only way
you can do it is to set up an array holding all of your SQL statements
and re-execute them. It's not bad if you have all of the information,
but if you need to fetch data (i.e. last_insert_id) and use it in the
next statement, it gets a little harrier. Then you almost need a SQL
templating engine.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Apr 10 '08 #4
NC
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
Apr 11 '08 #5
C. (http://symcbean.blogspot.com/) wrote:
Yes - write deadlock free code.
This is not that easy as we inherited the code from the former
programmer of that game. Now we try to extend it a bit ...
but that brings the problems with the database.
We are currently initiating a rewrite of the code, but until than
the old code as to run for another round...
So we try to fix the old code to get more time to write the new one.

But @all, thanks for your hints.

--
MfG, Christian Welzel aka Gawain@Regenbogen

GPG-Key: http://www.camlann.de/key.asc
Fingerprint: 4F50 19BF 3346 36A6 CFA9 DBDC C268 6D24 70A1 AD15
Apr 11 '08 #6
On Thu, 10 Apr 2008 22:27:53 +0200, C. (http://symcbean.blogspot.com/)
<co************@gmail.comwrote:
On 10 Apr, 17:01, Christian Welzel <gaw...@camlann.dewrote:
>Hi there,
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?

Yes - write deadlock free code.

Forget about using database bound transactions unless you can
encapsulate every transaction by locking all the tables right at the
beginning - but this is kind of horrible too - what happens if your
lock fails.

You can't fix the problem in PHP. You can't fix it in MySQL - you need
to fix it in how your application hangs together and how it uses
resources.

Don't use transactions at the database level:
1) Never delete rows if you can possibly avoid it
2) Never update rows if you can avoid it, try to use replace instead
of update
Euhm, never ever use REPLACE instead of UPDATE if not needed... It WILL
remove the previously existing row first, possibly ending in an ON DELETE
CASCADE nightmare...
--
Rik Wasmus
Apr 11 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
2095
by: Charles Nadeau | last post by:
I was trying to relocate my transaction log to a bigger drive using sp_movedevice but I made a mistake in the syntax of the second parameter and put only the path, not the path and the file name....
4
7718
by: A. Tillman | last post by:
We are having a really big problem with a zombie process/transaction that is blocking other processes. When looking at Lock/ProcessID under Current Activity I see a bunch of processes that are...
1
439
by: Avanish Pandey | last post by:
Hello All We have 3 differen services (in 3 different server) Service A,B,C . We want to implement distributed transaction when call methods of B and C from A. Is it possible? if yes then how? ...
7
6634
by: Abdul-Wahid Paterson | last post by:
Hi, I have had a site working for the last 2 years and have had no problems until at the weekend I replace my database server with a newer one. The database migration went like a dream and I had...
6
2746
by: Chris Ochs | last post by:
I want to do a series of inserts within a single transaction block, but with postgresql if one insert fails, the whole block is aborted. Is there any way to get around this behavior so that...
3
4721
by: andy.standley | last post by:
Hi, We have DB2 SDK V8.2.1 running under redhat ES 3 (taroon update 5) kernel 2.4.21 We have an instance that also contains the tools database for the admin server. We tools have been used to...
2
3881
by: John Lee | last post by:
Hi, I have few questions related to .NET 2.0 TransactionScope class behavior: 1. Check Transaction.Current.TransactionInformation.DistributedIdentifier to identify if distributed transaction...
2
8096
by: kanda | last post by:
Hello. I am developing the application (VBA&ODBC, to be exact) which periodically calls the stored procedures in the IBM DB2. A few of the procedures require executing with isolation level RR (...
1
1813
by: Rick | last post by:
I've migrated a web site from VS 2003 to VS 2005. After pushing the a Windows Server 2003 web server. The Framework 2.0 web site works when I go to test it. I'll start working on something else...
0
7121
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6993
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7162
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7197
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
4899
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4584
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3088
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
287
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.