A strange bug, is Mysql asynchronous?
I have a strange bug. I launch a PHP Unit test Suite. At the beginning, it executes a big query to initialize the database.
If I put a breakpoint just after the execution of the sql, there is no problem and my tests pass.
If I don开发者_C百科't put any break point, they don't pass and say that the tables don't exist!
It works as if the sql query was asynchronous!
Do you have an idea of the bug? Or how to debug that?
To debug this, you need to look at the query log - particularly at the sequence of events around the point where the data load finishes, and the first unit test begins. Has a drop database snuck in from somewhere ?
The query log is switched on using a setting in the config file:
MySQL Manual - 5.1.2 Server Command Options
You can switch the log on and off again from within the MySQL command line tool, but the file it writes to needs to be configured in the config file and the server restarted.
I have tripped over a similar problem before in a test environment using replicas - I eventually found that I was writing to the master and reading from the replica. Sometimes, if replication was fast enough, some tests would pass. Be careful that your tests are doing what you think they are doing.
精彩评论