Magento 2.4-develop
The table eav_attribute_label should contain a unique key constraint on the (store_id, attribute_id) pair.
Version:
_Also layered navigation disappears on frontend._
Relates issues:
https://github.com/magento/magento2/issues/24581
https://github.com/magento/magento2/issues/24718
Steps to reproduce:
eav_attribute_label and add a new row with the same attribute_id and store_id values
Actual Result: :heavy_multiplication_x: Item with the same id already exists.

Expected Result: :heavy_check_mark: should be notified that duplicate values cannot be created for these fields

One (faulty?) 3rd party extension inserted something in the eav_attribute_label using insertOnDuplicate, but since there is no unique key on the table I ended up with duplicate pairs (store_id, attribute_id).
This resulted in "item with id X already exists" error when loading attribute labels
Add a unique key constraint on the (store_id, attribute_id) pair.
<constraint xsi:type="unique" referenceId="EAV_ATTRIBUTE_LABEL_ATTRIBUTE_ID_STORE_ID_UNIQUE">
<column name="store_id"/>
<column name="attribute_id"/>
</constraint>
as a bonus, since this is becoming a unique index, the existing index on the store_id, attribute_id pair can be dropped
<index referenceId="EAV_ATTRIBUTE_LABEL_ATTRIBUTE_ID_STORE_ID" indexType="btree">
<column name="attribute_id"/>
<column name="store_id"/>
</index>
Hi @tzyganu. Thank you for your report.
To help us process this issue please make sure that you provided the following information:
Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:
@magento give me 2.3-develop instance - upcoming 2.3.x release
For more details, please, review the Magento Contributor Assistant documentation.
@tzyganu do you confirm that you were able to reproduce the issue on vanilla Magento instance following steps to reproduce?
Hi @engcom-Charlie. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:
Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.[ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.
[ ] 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.
[ ] 4. Verify that the issue is reproducible on 2.3-develop branchDetails
- Add the comment @magento give me 2.3-develop instance to deploy test instance on Magento infrastructure.
- If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
- If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and _stop verification process here_!
[ ] 5. Add label Issue: Confirmed once verification is complete.
[ ] 6. Make sure that automatic system confirms that report has been added to the backlog.
Hello @tzyganu !
Could you add any steps?
@engcom-Charlie Steps to what?
There are no steps. There is just an explanation.
One attribute should only have one single label on one store view. But the eav_attribute_label allows multiple labels for the same attribute for a single store view.
This can lead to errors when loading an attribute collection.
I know that duplicate labels cannot happen via admin UI, but it can still happen. (happened to me).
A simple unique key should prevent this.
@engcom-Charlie Thank you for verifying the issue.
Unfortunately, not enough information was provided to acknowledge ticket. Please consider adding the following:
"Component: " label(s) to this ticket based on verification result. If uncertain, you may follow the best guessOnce all required information is added, please add label "Issue: Confirmed" again.
Thanks!
:white_check_mark: Confirmed by @engcom-Charlie
Thank you for verifying the issue. Based on the provided information internal tickets MC-20164 were created
Issue Available: @engcom-Charlie, _You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself._
Hi @KaushikChavda. Thank you for working on this issue.
Looks like this issue is already verified and confirmed. But if you want to validate it one more time, please, go though the following instruction:
Component: XXXXX label(s) to the ticket, indicating the components it may be related to.[x] 2. Verify that the issue is reproducible on 2.3-develop branchDetails
- Add the comment @magento give me 2.3-develop instance to deploy test instance on Magento infrastructure.
- If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
- If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and _stop verification process here_!
[ ] 3. If the issue is not relevant or is not reproducible any more, feel free to close it.
Hi @tzyganu. Thank you for your report.
The issue has been fixed in magento/magento2#24682 by @KaushikChavda in 2.3-develop branch
Related commit(s):
The fix will be available with the upcoming 2.3.4 release.
Changes that were fixing this issue were reverted in https://github.com/magento/magento2/commit/e1958fece28f2726d2d7cb6a48b1b25cb5b3862e for 2.3.x and https://github.com/magento/magento2/commit/f3d3bce01229df6c47949036bf04921b52ecd6ba for 2.4.0. Re-opening
Closing since it was fixed on https://github.com/magento/magento2/pull/24682
Changes that were fixing this issue were reverted in https://github.com/magento/magento2/commit/e1958fece28f2726d2d7cb6a48b1b25cb5b3862e for 2.3.x and https://github.com/magento/magento2/commit/f3d3bce01229df6c47949036bf04921b52ecd6ba for 2.4.0. Re-opening
Hi @gabrieldagama here is quote of my comment why this issue was reopened
@magento I am working on this
Hi @alex311982! :wave:
Thank you for collaboration. Only members of Community Contributors Team are allowed to be assigned to the issue. Please use @magento add to contributors team command to join Contributors team.
@magento add to contributors team
Hi @alex311982! :wave:
Thank you for joining. Please accept team invitation :point_right: here :point_left: and add your comment one more time.
@magento I am working on this
@gabrieldagama as we discussed in Slack - this is really terrible issue, it's causing not obvious issues. In my case it was caused by some custom module, and behavior was like was "I just pressed some button and whole website went down", but real issue came from NOT OBVIOUS missing unique key.
We have 2 the same issues for two tables:
https://github.com/magento/magento2/issues/24581 - P2 S2 (as for me this is right priority)
https://github.com/magento/magento2/issues/24718 - P3 S3
Also for them we have open PRs:
https://github.com/magento/magento2/pull/28796 (in "to approval" status since end of July)
https://github.com/magento/magento2/pull/30981 (in review currently, waiting for test results, but I'm ready to approve it)
Would be good to move them forward together
BTW the issue was already fixed in October 2019, but then fix was reverted
https://github.com/magento/magento2/issues/24581#issuecomment-537933794
:white_check_mark: Confirmed by @engcom-Alfa
Thank you for verifying the issue. Based on the provided information internal tickets MC-39328 were created
Issue Available: @engcom-Alfa, _You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself._