-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
fix(db): Create replacement index where original index is missing #51439
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
fix(db): Create replacement index where original index is missing #51439
Conversation
|
/backport to stable31 |
|
/backport to stable30 |
| $table = $schema->getTable($toReplaceIndex['tableName']); | ||
| // If none of the previous indices existed we have to add the index | ||
| if (array_filter($toReplaceIndex['oldIndexNames'], static fn (string $indexName) => $table->hasIndex($indexName)) === []) { | ||
| $missingIndices[] = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw an entry in the Nextcloud log saying "Undefined array key "dropUnnamedIndex" at /knickrehm/www/cloud/core/Command/Db/AddMissingIndices.php#79" after applying this fix. From what I see, this array should contain a value for the key "dropUnnamedIndex" or 79 should not expect a value to exist for that key.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I get it, there was a code path for when all old names existed, you added one for when non of them exists, but there is still an issue if only some of them exists, no?
Why not simply ignore the existing, add the new one and then drop the old ones if they exist?
|
Actually fair point. I'll look into that! |
|
@come-nc thanks a lot for the suggestion. The code is a lot simpler now! |
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
063c77f to
29161c0
Compare
Summary
While working on #51438 I noticed that replacement indexes are not created if the old indexes don't exist. This can happen in the following deployment
Before: old and new index were missing
After: new index is added
The setup check has already reported the affected indices as missing, but they were never added.
TODO
Checklist