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

Doesn't appear to be working with PaperTrail Gem. #7

Open joshuapinter opened 5 years ago

joshuapinter commented 5 years ago

When restarting transactions after hitting a deadlock, I'm getting this error message:

ActiveRecord::StatementInvalid: Mysql2::Error: Field 'item_type' doesn't have a default value: INSERT INTO `versions` (`item_id`) VALUES (2148253670)

The versions table is used by the PaperTrail Gem to store changes to records. Since versions are polymorphic, it needs to store item_type and item_id, like User and 1234.

My guess is that when this gem retries the transaction, it loses this somewhere along the way.

Note, this is the only time I've encountered this error and it only occurs with the transaction_retry gem and after hitting a deadlock.

I might be able to investigate further but a little help in the right direction would be good.

Thanks!

Josh