Skip to content

MySQL: After a certain amount of time/transactions connections freeze during spec tests #473

@kalinon

Description

@kalinon

I found that after a certain amount of time/transactions (its unclear which one) spec tests will hang when running against a mysql server.

I was able to add debug and get this traced down to the DB adapter layer where it starts to read a packet but never completes:

2023-04-26T22:01:59.604210Z  DEBUG - db: Executing query -- query: "INSERT INTO `kvs` (`v`, `k`) VALUES (?, ?)", args: [nil, "foo"]
2023-04-26T22:01:59.604372Z  TRACE - db: About to execute query
2023-04-26T22:01:59.604419Z  TRACE - mysql: About to execute query
2023-04-26T22:01:59.604465Z  TRACE - mysql: #<MySql::Connection:0x103b95a20>
2023-04-26T22:01:59.604513Z  TRACE - mysql: write start - #<MySql::WritePacket:0x1074826e0>
2023-04-26T22:01:59.604564Z  TRACE - mysql: write done - #<MySql::WritePacket:0x1074826e0>
2023-04-26T22:01:59.604698Z  TRACE - mysql: read start - MySql::IncomingPacket[length: 5, seq: 4, remaining: 5]

I was able to complete a full spec run only if i manually closed all the connections in the connection pool.

# added to spec_helper.cr
Spec.after_each do
  Granite::Connections["mysql"].not_nil!.database.pool.close
end

I will keep investigating.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions