-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
database table 'lookup' — 'value' column too narrow #121
Comments
When I reproduce this the file is imported without the DBD::mysql::st error, and Warewulf silently inserts the file with truncated entries in the lookup table for PATH and NAME. Guessing due to strict mode not being enabled by default. It looks like we create The existing schema limits our ability to change the value field to a variable length TEXT type or similar. With MariaDB 5.5.56 I'm seeing that the max VARCHAR length we can set is 767. We could also fix the above:
Thoughts? |
The uniquing index would be there to ensure there are no repeated key=value pairs on a given object_id. The odd part is, the implementation of get_lookups() explicitly allows for multiple key=value pairs. So it would seem like we don't want that index at all.
Are you sure you need to drop the foreign key constraint at all? I did:
and then was able to alter the column type without issue. In fact:
takes the size constraint to 65535 bytes at the expense of moving storage outside the row itself. Since we typically end up searching over the object_id and/or field columns (and they're still indexed individually) that shouldn't affect things too badly. On the other hand, 4096 bytes is already a HUGE increase over 64, and if there haven't been complaints about this issue prior to now then keeping all storage in the row won't affect things at all. |
It appears the del_object_impl() will clean up all lookup rows based on object_id, so I agree I think we're fine removing the unique index.
Pretty sure MariaDB 5.5 wouldn't let me remove the object_id INDEX without removing the foreign key constraint. Did you by chance have an empty lookup table when you tried this? We should try reproducing this a bit before committing to the exact migration strategy. Any thoughts on where we actually code the schema migration, or should we even make this change automatically on upgrade?
In We also should consider updating the Postgres and Sqlite schemas to match our decision here, so we have consistent behavior across databases. |
This is why I preferred the schema being outside of the Perl code. :/ I can't speak up any here unfortunately. I know there was a purpose how it was setup in the old code, but can't say with how the new code is laid out. Previously, it should have been indexed and FK there... but I don't know after the DataStore rewrite. I... still haven't went over the full thing. :( |
Found the source of the unique index. It was very early on: http://warewulf.lbl.gov/trac/changeset/87/trunk/common/share/setup.sql, and finalized it basically its current state here: http://warewulf.lbl.gov/trac/changeset/96/trunk/common/share/setup.sql. It's not really been altered since, but moved around to wwinit's 10-database, and then into its current location recently. It seems reasonably likely that the FK was intended to be on the |
Since:
it seems appropriate that we write a single-purpose utility to upgrade an existing MySQL database — if that's needed/desired — and document its use and purpose. All new installations moving forward would use the corrected schema (whatever that ends up being). |
lookup.value
column is defined in MySQL as being a VARCHAR(64); there is no logic in the code to check value sizes before the code attempts to insert them in the database.lookup
then the column width SHOULD allow for that size.For the Postgres and SQLite schemas I used TEXT as the type on
lookup.value
so this is only an issue with the MySQL schema. I temporarily got around the problem by resizing to VARCHAR(256).The text was updated successfully, but these errors were encountered: