ActiveRecord 7.1 test failures

I am attempting to bring Occams CMS into Rails 7.1 compatibility (Rails 7.1 compatibility by avonderluft · Pull Request #14 · avonderluft/occams · GitHub). My test suite passes consistently on 6.1 and 7.0, but fails roughly 1 out of 4 times on 7.1 with things like:

  • Cannot expire connection, it is owned by a different thread
  • cannot start a transaction within a transaction
  • SQLite3::BusyException: database is locked

I’ve tried a lot of different workarounds, but to no avail. I tried running test suite in postgresql and mysql, but with much the same results. Any tips or hints would be very much appreciated!

Have you tried setting use_transactional_tests to false?

yes, thanks @pbstriker38. Still get lock errors:

SQLite3::BusyException: database is locked

I’m familiar with Postgres but wondering whether SQLite has a mechanism to log query text when a query is canceled (blocked) due to failing to acquire a lock? If so you might be able to identify the source query or query holding a lock.

Is it SQLite only where the failure happens?

no, I tried with MySQL as well.

This is curious, because it’s possible in PostgreSQL anyway. There are warnings but not errors.

@localhost:5432 # BEGIN;
BEGIN
@localhost:5432 # BEGIN;
WARNING:  there is already a transaction in progress
BEGIN
@localhost:5432 # COMMIT;
COMMIT
@localhost:5432 # COMMIT;
WARNING:  there is no transaction in progress
COMMIT

For Cannot expire connection I’d have to search the source code.

What version of PostgreSQL did you try? And I assume it’s a “stock” configuration with things like the transaction isolation level left in their default values?

psql (16.1) on macos running this minitest suite hangs and/or produces errors like:

WARNING:  there is already a transaction in progress
Emessage type 0x49 arrived from server while idle
message type 0x5a arrived from server while idle
.....................................................................................F.........................................................................................................................message type 0x49 arrived from server while idle
message type 0x5a arrived from server while idle
message type 0x49 arrived from server while idle