Internal Server Error (500) when updating a newly created product (e.g. its visibilitiy)

(System: Shopware

Hi there,

we regularly synchronize product data from our PIM-systems to shops via the admin api. Creation a new product via POST request to the product entity endpoint works as expected.

But sometimes (not always), when we update a freshly created product, the shop returns an internal server error. For example, when we update the product visibility via API directly after creating the product, we get something like:

Cannot add or update a child row: a foreign key constraint fails (xxxxxxx_shop_sw6.product_visibility, CONSTRAINT fk.product_visibility.product_id FOREIGN KEY (product_id, product_version_id) REFERENCES product (id, version_id) ON DELETE)"}]}

If we retry the synchronisation after a couple of minutes, the exact same call of updating the visibility, succeeds without any trouble.

I somehow have the feeling, that some caching or orm settings have the effect that the product is not directly written into the db and that the subsequent fails because of that.

Any idea, how to proceed?

Kind regards