qertoip / transaction_retry

Retries database transaction on deadlock and transaction serialization errors. Supports MySQL, PostgreSQL and SQLite.
MIT License
116 stars 42 forks source link

Failing transaction rollback test #1

Closed adamonduty closed 12 years ago

adamonduty commented 12 years ago

Hi! Its great to see someone finally taking a serious stab at this problem. Its plagued our application for months.

When running the unit tests on mysql, I noticed that test_does_not_break_transaction_rollback is failing. Here's the output using ea36ecd:

# Running tests:

..F..

Finished tests in 0.071211s, 70.2140 tests/s, 112.3424 assertions/s.

  1) Failure:
test_does_not_break_transaction_rollback(TransactionWithRetryTest) [/home/user/tmp/transaction_retry/test/integration/active_record/base/transaction_with_retry_test.rb:32]:
Expected: 0
  Actual: 1

5 tests, 8 assertions, 1 failures, 0 errors, 0 skips

Could you speak to the impact of this test not passing? As I recall, some features like ActiveRecord validations rely on ActiveRecord::Rollback.

qertoip commented 12 years ago

This test should definitely pass. It's not safe to use it unless all tests pass. We must investigate this issue together.

On my installation of mysql 5.1.61 with default configuration all tests pass.

So firstly I'd like to investigate whether it is the gem's fault or perhaps just your configuration. Could you please test whether raising ActiveRecord::Rollback actually rolls back the transaction without the gem? I.e. you can check it manually on the console. See the failing test for the idea.

adamonduty commented 12 years ago

You're spot on! I checked and ActiveRecord::Rollback had no effect. It turns out that my InnoDB engine wasn't loaded. After a recent upgrade, mysql couldn't load the InnoDB engine and I had to delete ib_logfile0 and ib_logfile1. Once I did this, InnoDB came up and the tests passed.

It might make sense to explicitly check for InnoDB and other engines where raising ActiveRecord::Rollback would result in more than a no-op.

Thanks for the help and the library!

qertoip commented 12 years ago

My pleasure.