Andrew Zick
09/13/2023, 6:20 PMERROR 1062 (23000): Duplicate entry '' for key 'hosts.hosts_search'
Wondering if anyone has seen it before specifically for the migration 20220915165116_HostDisplayName? I saw a few mentions in this slack about editing rows in order make things work e.g. this thread, been testing with manually dedupping the table (on a snapshot of the real db) but still ran into the error after clearing all duplicates for (hostname, uuid, computer_name) which appears to be the index that the migration is trying to add. Thanks for any help or advice!Kathy Satterlee
09/13/2023, 6:22 PMAndrew Zick
09/13/2023, 6:29 PMfleet-prepare-db-v4.21.0-62jfq . Do we maybe need to be pausing certain pods while that pod is executing?Kathy Satterlee
09/13/2023, 6:45 PMKathy Satterlee
09/13/2023, 6:46 PMAndrew Zick
09/13/2023, 6:47 PMfleet-webserver-958cb485f-79c2q , then deploy the upgrade? Wondering if the CDK deploy might restart the pods though, will keep thinking.Benjamin Edwards
09/13/2023, 6:53 PMAndrew Zick
09/13/2023, 7:04 PMALTER TABLE hosts DROP INDEX hosts_search;
causes a different error
2023/09/12 21:04:16 FAIL 20220915165116_HostDisplayName.go (upHostDisplayName: delete index: Error 1091: Can't DROP 'hosts_search'; check that column/key exists), quitting migration.
but we’ve successfully tested a workaround of manually adding the index for it to then delete.
So we think it’s the next line CREATE FULLTEXT INDEX hosts_search ON hosts(hostname, uuid, computer_name) that’s causing the error in my question. Here’s the full error btw:
2023/09/12 21:30:03 FAIL 20220915165116_HostDisplayName.go (upHostDisplayName: create index: Error 1062: Duplicate entry '' for key 'hosts.hosts_search'), quitting migration.
And I still get this error when testing this SQL line on my snapshot. So I’m worried that turning off the webservers, while correct and something I’ll do + add to our documentation, won’t address this?Andrew Zick
09/13/2023, 8:56 PMAndrew Zick
09/14/2023, 2:49 PMAndrew Zick
09/21/2023, 5:21 PMhosts table, added the FULLTEXT index, then copied all the data over from old to new
• We ran the SQL commands from the failing migration, but skipped deleting the nonexistent index, of course (and it doesn’t have an IF EXISTS clause)
• We inserted a row into migration_status_tables so that the Fleet db upgrade would think the migration had already been applied
• Deployed to 4.22.0 and it upgraded just fine ✅Andrew Zick
09/21/2023, 5:24 PM