/deadlocks

Experimenting with deadlocks on MySQL and PostgreSQL.

Primary LanguageGo

MySQL vs PostgreSQL

$ docker-compose up -d
$ make build
go build
$ ls deadlocks
deadlocks

See how MySQL fails ...

$ make mysql
.EEE.EE.E. ✗
$ make mysql
EEEEE..EE. ✗
$ make mysql
...EE.E... ✗

... and PostgreSQL succeeds:

$ make postgres
.......... ✔
$ make postgres
.......... ✔
$ make postgres
.......... ✔

Now, start MySQL with retry on failure (will retry only on Error 1213: Deadlock found when trying to get lock; try restarting transaction):

$ make mysql-retry
.......... ✔
$ make mysql-retry
.......... ✔
$ make mysql-retry
.......... ✔

PostgreSQL, again, will make no difference:

$ make postgres-retry
.......... ✔
$ make postgres-retry
.......... ✔
$ make postgres-retry
.......... ✔

Prior art

This code just changes github.com/mlomnicki/mysql-vs-postgres-deadlock slightly.