mysqldjangodockermariadbdata-loss

django - Records not saved in MySQL database but AutoIncrement gets increased


I'm facing a weird one here.

I'm using django inside a docker container. When the system tries to save some records (mostly it works!) they don't end up in the database.

When I view the process in the debugger, the django objects gets saved, it gets an ID from the database and inside the django world everything seems fine.

But the record never shows up in the database! Even weirder: If I look at the table's meta options I see that per record which should have been created the AutoIncrement is increased. So it appears the database knows about the records but dedides not so save them...

I tried it on my Windows machine, the server runs UNIX, both have the same issue.

I'm using django==2.0.9 and mysqlclient==1.3.13 connecting to a MariaDB.

When I switch the table engine from InnoDB to MyISAM then it works.

Reproducibly it happens for the django-axes tables but I experienced the issue in other parts of the system as well. The calls come via the django-restframework to django.

Frankly I have no idea where to start looking for the issue.

  1. On Windows and (server's) UNIX it occurs, on another's developers UNIX, it works

  2. I downgraded latest mysqlclient, no effect

  3. Google doesn't say anything or I'm not asking the right questions

  4. MySQL error log keeps silent.

  5. I also tried the latest MariaDB image 10.3.


Solution

  • Ok, without ever finding out what I can do about it, I switched the database engine for these explicit tables to MyISAM, now it works. Super weird.