Skip to main content

176 posts tagged with "Database"

Databases, Data Modeling, and Data Access

View All Tags

FOR SHARE vs FOR UPDATE in MySQL

· 5 min read
Jagdish Kumawat
Founder @ Dewiride

FOR UPDATE locks a row so only you can touch it. FOR SHARE locks it so nobody can change it, while others can hold the same lock with you. They look like small variations, and picking the wrong one can deadlock two sessions that seem to be doing nothing wrong.

READ COMMITTED vs REPEATABLE READ in MySQL

· 7 min read
Jagdish Kumawat
Founder @ Dewiride

Under one isolation level, a transaction reads 50 twice while another session has already saved 40. Under the other, its second read says 40. Neither is a bug, and the right choice depends on what your code does with the number. Here are the two levels running side by side, and what a write does under both.

How Autocommit Works in MySQL

· 5 min read
Jagdish Kumawat
Founder @ Dewiride

You run an UPDATE, and it's saved. You didn't ask for that, and that's autocommit doing its job. It's on by default, and turning it off changes what every later statement does in that session. Here's each setting at work, and the surprise waiting when you close the client.

Fixed: "ERROR 1356 (HY000): View 'sys.innodb_lock_waits' references invalid table(s) or column(s) or function(s)" in MySQL

· 4 min read
Jagdish Kumawat
Founder @ Dewiride

Reading sys.innodb_lock_waits failed with ERROR 1356 (HY000): View 'sys.innodb_lock_waits' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them. The view isn't broken. The end of that long message is the real reason: the account lacks a right.