This issue exists in current HEAD in the develop branch (0c6227d2c0b68f55bc1d7fb0e878a3c597b50653). The bug is very apparent from looking at the code. The environment is irrelevant to the issue.
Save a non-existent product more than once simultaneously (e.g. via the REST API).
For all but the "winning" save operation (i.e. the one which reaches the database first), either an exception should be raised or updates should be made to the product which was created by the "winning" save operation.
Either:
Multiple products are created with the same SKU.
Or:
Multiple products are created with different SKUs (a number is appended to the end of the SKU to make it unique). THIS IS REALLY BAD! If the application detects a duplicate SKU when creating a product then this should be an error! It is critical that products are created with the actual SKU a business uses, and not some other meaningless SKU.
The cause of this issue is very clear when looking at the code [1] [2]. SKU uniqueness is enforced within the application code but not by a constraint in the database. This is totally not robust enough for an application of Magento's importance. Please add database constraints to enforce SKU uniqueness and remove this damaging _generateUniqueSku() method [1].
[1] [Uniqueness is enforced in application code](https://github.com/magento/magento2/blob/0c6227d2c0b68f55bc1d7fb0e878a3c597b50653/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Sku.php#L99)
[2] [There is no uniqueness constraint in the database schema for SKU](https://github.com/magento/magento2/blob/0c6227d2c0b68f55bc1d7fb0e878a3c597b50653/app/code/Magento/Catalog/Setup/InstallSchema.php#L93)
Hi, thank you for your report. Internal issue MAGETWO-61468 is created.
Issue in progress @sinisa86
I am working on this issue.
@joshdifabio, thank you for your report.
We've created internal ticket(s) MAGETWO-61468, MAGETWO-62571 to track progress on the issue.
Hi there
@dimaperedriy did you start to work on this issue?
@mrodespin Hello, do you still work on this issue?
Hi, everybody on #WroCD :)
This issue looks good
@wokisajn thank you for joining. Please accept team invitation here and self-assign the issue.
@ecomchallenger thank you for joining. Please accept team invitation here and self-assign the issue.
I am working on this at #dmcdindia1
i have run product add script simultaneously but unable to reproduce this issue in magento 2.3
Most helpful comment
Hi there