craftcms / digital-products

Sell digital products with Craft Commerce.
https://plugins.craftcms.com/digital-products
MIT License
18 stars 9 forks source link

[4.x] Upgrading from Craft 3 creates resaving batch jobs twice #94

Closed gddotorg closed 12 months ago

gddotorg commented 1 year ago

Description

We are currently upgrading Craft from version 3 to version 4 for one of our clients. We have carried out a test run and found that the resaving batch job is being carried out several times. So "(batch 1 of ...)" is executed twice in the queue. Our issue is that we have about 48,000 digital products and therefore about 480 batch jobs and this is two times. Brief background: We had overall performance issues after the update and I am in the process of reducing the queue jobs overall. Therefore my questions: How can I prevent that each batch is executed twice or is it necessary? Can I prevent a resave job from being generated automatically? If so, we could just trigger the bulk job manually if the load on the server is not too big.

I guess this is the function, which is triggered twice: https://github.com/craftcms/digital-products/blob/3.0/src/Plugin.php#L214

Additional info

Asset Rev 7.0.0 Blitz 4.5.3 CP Field Inspect 1.4.4 Digital Products 3.2.3 Elasticsearch 2.1.1 Element API 3.0.1.1 Empty Coalesce 4.0.0 Feed Me 5.2.0 Field Manager 3.0.7 Formie 2.0.36 ImageOptimize 4.0.5 Imager X 4.2.2 Redactor 3.0.4 Retour 4.1.13 Sentry SDK 2.0.1 SEOmatic 4.0.31 Sprig 2.6.2 Super Table 3.0.9 Vite 4.0.6 Wishlist 2.0.6

gddotorg commented 12 months ago

I have now found out myself how to cancel at least the second run of saving the products. In the resave function I have seen that at the end of the execution process the new batch job is created. This means that if I delete the batch job, which is not yet executed, from the queue, no new batch job is created. Consequently, I can delete one of the two "(batch 1 of ...)" jobs and then only one will run. jobs and then only one will continue to run.