1

I have two machines, M1 and M2, through which I am connecting to MySQL Database on machine M3 using Perl script (DBI.pm).

So, here is the scenario that I am confused about: M1 places a table level lock, and performs some operations. M2 also does the same. Table level locking mechanism is guarantying me that both of them will not be locking the table at the same time.

But, what if M1 has locked the table, and suddenly after performing half hte updates, the machine crashes or the Perl script process crashes, what happens to the lock then? My updates were performed mid-way, do those get rolled back? And what is the best way to deal with these kind of locks?

  • For MyISAM, no rollback. For InnoDB, yes, they will be rolled back. But InnoDB does not do table locks. – Rick James Jul 19 '16 at 3:58
0

http://dev.mysql.com/doc/refman/5.6/en/innodb-autocommit-commit-rollback.html

If a session that has autocommit disabled ends without explicitly committing the final transaction, MySQL rolls back that transaction.

There is a process that monitors active sessions. If any are found to have disconnected, the sessions are cleaned up. This includes rollback of uncommitted transactions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.