shopsys icon indicating copy to clipboard operation
shopsys copied to clipboard

Recalculating products availability and prices immediately instead of on finish request

Open jakubhavlak opened this issue 6 years ago • 14 comments

When programmer needs mass create/edit a lot of products (eg. during import at cron module), recalculating by schedulers and clearing internal their caches is a painful - It is easily forgetable and unnecessary.

Price recalculation does not use native query and can be run immediately - There is not any reason why this calling waits on finish request event.

Availability recalculation does not use native query too, but here is one exception - variants. Recalculation of variants calls ProductVisibilityFacade::refreshProductsVisibilityForMarked() and this could cause problem in the future, when some action in background marks a lot of products to availability recalculation and somebody create order at front-end. Order creation calls recalculate availability -> it could take a lot of time.

Because there is problem with variants availabilty, this merge request maybe is not ready to merge, but for me usecase is sufficient solution and problem with executing native query in request is solved by EntityManager::refresh().

Also mentioned in: https://git.shopsys-framework.com/shopsys/shopsys-framework/merge_requests/6

jakubhavlak avatar Jun 05 '18 14:06 jakubhavlak

Created US-4260

Miroslav-Stopka avatar Nov 01 '18 13:11 Miroslav-Stopka

This issue has been automatically marked as stale because there was no activity within the last 4 months (and it is quite a long time). It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Mar 01 '19 13:03 stale[bot]

ping...pong...

pk16011990 avatar Mar 01 '19 13:03 pk16011990

This issue has been automatically marked as stale because there was no activity within the last 4 months (and it is quite a long time). It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jun 29 '19 14:06 stale[bot]

...

pk16011990 avatar Jul 15 '19 05:07 pk16011990

seems to me we are able to solve the problem elegantly using RabbitMQ after https://github.com/shopsys/shopsys/pull/1228 is finished

vitek-rostislav avatar Jul 26 '19 08:07 vitek-rostislav

This issue has been automatically marked as stale because there was no activity within the last 4 months (and it is quite a long time). It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Nov 23 '19 09:11 stale[bot]

bump

henzigo avatar Nov 23 '19 11:11 henzigo

This issue has been automatically marked as stale because there was no activity within the last 4 months (and it is quite a long time). It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Mar 22 '20 12:03 stale[bot]

This issue has been automatically closed because there was no acivity within the last half a year.

stale[bot] avatar May 22 '20 06:05 stale[bot]

reopen

pk16011990 avatar May 22 '20 10:05 pk16011990

This issue has been automatically marked as stale because there was no activity within the last 4 months (and it is quite a long time). It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Dec 25 '20 11:12 stale[bot]

Is there any update or progress? We had 23 internal 500 errors because of it (Deadlock), and manually extended and removed immediate recalculations in our new release. 23 of 60 orders was not processed, because of this error.

abecko47 avatar Dec 03 '21 11:12 abecko47

Hi, yes, disabling recalculation during requests is the way how to solve this quickly. However, this solution has delayed (up to 5 minutes) hiding on sold-out products. This can be a problem for some e-shops. For those that need it, I recommend manually checking for out-of-stock, updating stock quantity and hiding products outside master transaction (https://github.com/shopsys/shopsys/blob/master/packages/framework/src/Component/HttpFoundation/TransactionalMasterRequestListener.php) Updating 1 row outside transaction can't cause deadlock. Another tip for better performance is to do short transactions as much as possible, because a single row update can be blocked by a long transaction in background (cron) with the same updated row - do small transactions eq. during transfers from ERP.

All solutions cause a big BC-break for the behavior of order process and we will work on this on ShopSys Framework version 10. And when will version 10 be released? We want to create a new roadmap in early 2022 year and this will be included.

pk16011990 avatar Dec 06 '21 06:12 pk16011990

resolved by #2917

grossmannmartin avatar Dec 19 '23 13:12 grossmannmartin