0

I'm using a dockerized MySQL 5.7.13 as part of an integration test of an application. The way the system works is as follows:

  1. I start up the main application. It opens up a connection to MySQL, but does not perform any queries.
  2. I start the integration test setup and drop the old table if it was left behind by the previous run:

    DROP TABLE IF EXISTS unit_device

  3. I then go on and create the table like this:

    CREATE TABLE IF NOT EXISTS unit_device ( id CHAR(36) NOT NULL, unit_id CHAR(36), device_id CHAR(36), deleted_at DATETIME, PRIMARY KEY (id) )

  4. I then insert some values into the table and trigger work in the main application which makes one SELECT:

    SELECT unit_id, device_id FROM unit_device WHERE deleted_at IS NULL

  5. Then I drop the table:

    DROP TABLE IF EXISTS unit_device

However, when I try to run this query, it hangs seemingly forever for some reason. If I close the connection from the main application, the query resumes. One thing that seems suspicious is that once the main application has made its select once, I can see the following information in the output of show engine innodb status: 1 read views open inside InnoDB

I must be doing something seriously wrong here, but after hours of research I was still unable to figure out what's causing the hang, or whether the problem is in the test or the main application.

0

I was able to figure it out. I was using the aiomysql library for Python and it turns out that it somehow bypasses the autocommit setting in the database and requires commits by default. However, this somehow applies to SELECT statements as well, but does not work even when called explicitly. I fixed it by adding autocommit=True to the code which creates the pool, as suggested by this note in Github.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.