• Hi, so we got a subscription based WC store and are using the Amazon pay plugin for years now. Lately the table actionscheduler_actions ran into deadlock issues because of it’s size of 22GiB. The Table has almost 16 million entries of the hook “wc_amazon_async_polling” with state “complete” and 12 thousand “pending” entries. The pending entries seem to get generated almost every second as I can tell by the column “scheduled_date_gmt”.

    1. What is this good for?
    2. Can I remove all the “complete” entries without running issues?
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support Christian

    (@christian1983)

    Hey @daheadcracker

    Hope you are doing well! and thanks for your patience.

    The deveopment team is checking your issue. Could you tell us the of an average number of orders completed through Amazon Pay every day?

    Best,
    Christian

    Thread Starter daheadcracker

    (@daheadcracker)

    Hi @christian1983 ,
    The average orders per day is up to now in this year at 161.7 for the amazon pay gateway.

    Plugin Support Christian

    (@christian1983)

    Hey @daheadcracker

    Thanks for responding.

    What is this good for?

    the hook “wc_amazon_async_polling” is being used for checking the status of Amazon charges and charge permissions async.

    2. Can I remove all the “complete” entries without running issues?

    The removal of the completed actions in the database should be handled by Action Scheduler itself after 30 days of their completion. Do you have completed actions older than that? In the article, there is also an example to use a filter and change the 30 days settings period.

    Besides this, we are checking if there is an issue with the logic of using “wc_amazon_async_polling” so many times.

    Best,
    Christian

    • This reply was modified 1 year, 5 months ago by Christian.
    Thread Starter daheadcracker

    (@daheadcracker)

    Hey @christian1983

    the hook “wc_amazon_async_polling” is being used for checking the status of Amazon charges and charge permissions async.

    But why is it that the hook with the same args ([“BXX-XXXXXXX-XXXXXXX”,”CHARGE_PERMISSION”])/ for the same order needs to run almost 10 times a day for every day?

    	public function schedule_hook( $id, $type ) {
    		$args = array( $id, $type );
    		// Schedule action to check pending order next hour.
    		if ( false === $this->is_next_scheduled( 'wc_amazon_async_polling', $args, 'wc_amazon_async_polling' ) ) {
    			wc_apa()->log( sprintf( 'Scheduling check for %s %s', $type, $id ) );
    			as_schedule_single_action( strtotime( '+10 minutes' ), 'wc_amazon_async_polling', $args, 'wc_amazon_async_polling' );
    		}
    	}

    According to “wp-content/plugins/woocommerce-gateway-amazon-payments-advanced/includes/class-wc-amazon-payments-advanced-ipn-handler.php:542” it seems to me as after an event “wc_amazon_async_polling” has run, the next one is beenig scheduled in 10 Minutes?
    Why does this plugin need to run a polling functionality in the first place? e.g. the Stripe and Paypal plugins don’t need that and are running code only when it’s necessary e.g. while loading the order edit page in backend or while processing scheduled payments.

    The removal of the completed actions in the database should be handled by Action Scheduler itself after 30 days of their completion. Do you have completed actions older than that? In the article, there is also an example to use a filter and change the 30 days settings period.

    Yes there are older completed entries for this hook. For whatever reason the automated cleanup seems to work for hooks like ‘wc-admin_import_orders’ or ‘woocommerce_scheduled_subscription_payment’ but not for the ‘wc_amazon_async_polling’ hook.

    I have lowered the cleanup schedule already to 7 days.

    So I guess I can also delete the ‘complete’ and ‘failed’ together with the matching log entries manually, right?

    Thanks
    Regards

    Plugin Support Christian

    (@christian1983)

    Hey @daheadcracker ,

    Hope you are doing well! and thanks for your patience!

    So I guess I can also delete the ‘complete’ and ‘failed’ together with the matching log entries manually, right?

    Yes but we always suggest taking a backup beforehand.

    But why is it that the hook with the same args ([“BXX-XXXXXXX-XXXXXXX”,”CHARGE_PERMISSION”])/ for the same order needs to run almost 10 times a day for every day?

    It has been brought up to the dev team’s attention and making this functionality rarer is being considered. This hook should only be executed for Orders that don’t have a final status on the Amazon side. For example, for a Charge with status Captured, it should never run again.

    Why does this plugin need to run a polling functionality in the first place?

    The polling functionality is an alternative to IPNs for receiving updates from Amazon. Unfortunately, we can’t only rely on IPNs even though they are implemented within the plugin. The scheduling of the polling could be altered though as mentioned above.

    Hope this helps you.

    Best,
    Christian

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Spamming actionscheduler_actions table with hook “wc_amazon_async_pollin”’ is closed to new replies.