-
-
Notifications
You must be signed in to change notification settings - Fork 504
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
Indices from sub classes always get re-created #2561
Comments
@buffcode thanks for the report! Would the same be true if |
@malarzm The effect seems to be the same. Having the parent being abstract without Nevertheless, while testing various combinations of
Output:
IMHO the index comparison needs to take all subclasses into account and perform the index deletion/creation only once per collection. The subclasses can be skipped, as they have already been processed by the parent. |
Thanks for checking! You're right, we'll need to improve how indices are created. Most probably in the same vein as #2392 did. Mind taking a stab at it? :) |
Bug Report
Summary
Having an inheritance and defining indices on a subclass (eg.
UniqueIndex
) will always re-create the subclasses' indices.Current behavior
Having an inheritance and defining indices on a subclass (eg.
UniqueIndex
) will result in the subclass indices to be dropped on every run ofdoctrine:mongodb:schema:update
and re-created afterwards.Notice that the index will exist after the command, so the collection looks okay, but the indices are effectively dropped and recreated.
This is usually not such of a big problem but it put some our our databases down after dropping an index on a 0,5 TB collection and starting to recreate it for multiple hours.
How to reproduce
For debugging purposes add the following code to
\Doctrine\ODM\MongoDB\SchemaManager::updateDocumentIndexes
, right before$collection->dropIndex(...)
:Run:
Expected behavior
No index drop
Workaround
All indices have to be defined on the root class.
The text was updated successfully, but these errors were encountered: