PixelSapiens
PixelSapiens

Reputation: 73

Mysql concurrency: what happens if a locked table is accessed?

The question is rather simple but I couldn't find a precise answer: In a myisam db, what happens if a php file locks a table (with an atomic operation, say an INSERT) and another php file tries to access the same table (reading or writing)?

Now, while it is obvious that the second session will not be able to access the table, what exactly happens? Does it return some kind of error? Does it wait in queue until it is able to access it?

Upvotes: 7

Views: 1969

Answers (1)

Mark Willis
Mark Willis

Reputation: 1741

The second connection will wait for the lock to free.

With MyISAM any write (insert / update / delete) will lock the table,

However with INNODB table type the atomic operation will only lock the affected rows

Upvotes: 7

Related Questions