You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey. This doesn't affect MariaDB, which I use on my development machine, but unfortunately on MySQL 5.7 there's a length limit of 64 characters on locks. So I wound up with this error during a migration:
Mysql2::Error: Incorrect user-level lock name 'ClosureTree::CreateFrobulatorServiceTypeHierarchies::FrobulatorServiceType'.:
SELECT GET_LOCK('ClosureTree::CreateFrobulatorServiceTypeHierarchies::FrobulatorServiceType', 0) AS tdf2f8c4cdfaa43bc9026d2d607d0b5e7
I know that 64 seems like a pretty high limit, but the code in support_attributes.rb always prepends ClosureTree::, then (at least in my experience) Rails migrations tend to have very long names (CreateACertainTypeOfThing...), and it's best practice (or so I've heard) to redefine a stub model inside of that class (in case its implementation changes a lot after the migration runs). So in a migration, it's easy to exceed the length limit and it bit me today. And because MySQL doesn't have transactional DDL, it's especially painful to clean up after 😦
Hey. This doesn't affect MariaDB, which I use on my development machine, but unfortunately on MySQL 5.7 there's a length limit of 64 characters on locks. So I wound up with this error during a migration:
I know that 64 seems like a pretty high limit, but the code in
support_attributes.rb
always prependsClosureTree::
, then (at least in my experience) Rails migrations tend to have very long names (CreateACertainTypeOfThing...
), and it's best practice (or so I've heard) to redefine a stub model inside of that class (in case its implementation changes a lot after the migration runs). So in a migration, it's easy to exceed the length limit and it bit me today. And because MySQL doesn't have transactional DDL, it's especially painful to clean up after 😦Potential Solution
Would you be open to a different implementation of https://github.com/mceachen/closure_tree/blob/master/lib/closure_tree/support_attributes.rb#L9 , perhaps one which uses the first 30 or so characters of the MD5 of the existing implementation?
The text was updated successfully, but these errors were encountered: