Skip to content

CIVIPLMMSR-655: Lower default reconcile batch_size from 100 to 30#27

Closed
erawat wants to merge 1 commit into
masterfrom
CIVIPLMMSR-655-lower-reconcile-batch-size
Closed

CIVIPLMMSR-655: Lower default reconcile batch_size from 100 to 30#27
erawat wants to merge 1 commit into
masterfrom
CIVIPLMMSR-655-lower-reconcile-batch-size

Conversation

@erawat

@erawat erawat commented Jun 4, 2026

Copy link
Copy Markdown
Member

Overview

Lower the default batch_size for the "Reconcile stuck payment attempts" cron job from 100 to 30, to avoid hitting the GoCardless API rate limit when draining a large backlog.

Before

Default batch_size=100. On a backlog drain (one production site with ~1,500 stuck contributions), a single cron run reconciled only ~54 contributions before GoCardless's API throttle kicked in, leaving the remaining ~42 attempts erroring with "Rate limit exceeded". Errored attempts are retried next run, but the same throttle is hit again, so net progress per run is capped at ~54%.

After

Default batch_size=30. Empirically 30 reconcile attempts comfortably fit under the GoCardless per-token throttle on the same site. Net progress per run is closer to 100% with the smaller batch size.

Sites needing more throughput can still raise batch_size per-site via the cron Job UI (or civicrm_job.parameters).

Technical Details

managed/Job_PaymentAttemptReconcile.mgd.php — two changes:

  • Default value batch_size=100batch_size=30 in the parameters string.
  • Doc-comment for batch_size updated to reflect the new default.

Core overrides

None.

Comments

Linked ticket: https://compucorp.atlassian.net/browse/CIVIPLMMSR-655

On next cv upgrade:db -n, existing installs with the old default will be reset to 30 (Civi's default managed-entity update behaviour).

@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request adjusts the default batch size for the payment reconciliation cron job to improve reliability when processing large backlogs. By lowering the limit, the job is less likely to trigger API rate limits with providers like GoCardless, ensuring more consistent progress during automated reconciliation runs.

Highlights

  • Performance Optimization: Reduced the default batch_size for the payment reconciliation cron job from 100 to 30 to prevent hitting GoCardless API rate limits during large backlog processing.
  • Documentation Update: Updated the inline documentation for the batch_size parameter to accurately reflect the new default value.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the default batch_size parameter from 100 to 30 in the managed job configuration for PaymentAttemptReconcile. The reviewer points out that the underlying API PaymentAttemptReconcile.Run still defaults to 100 in its implementation and API spec, and recommends updating the default value there as well to prevent inconsistency.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

'api_action' => 'Run',
'api_version' => 3,
'parameters' => "processor_parameters=[Stripe Connect,2],[GoCardless,6]\nbatch_size=100\nmax_retry_count=3",
'parameters' => "processor_parameters=[Stripe Connect,2],[GoCardless,6]\nbatch_size=30\nmax_retry_count=3",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

WARNING: While updating the default batch_size to 30 in the managed job parameters is correct, the underlying API PaymentAttemptReconcile.Run still defaults to 100 in both its implementation (api/v3/PaymentAttemptReconcile/Run.php line 34) and its API spec (_civicrm_api3_payment_attempt_reconcile_Run_spec line 106).

To prevent inconsistency and ensure that manual API calls or other invocations also benefit from this safer default, please update the default value in the API file as well.

@erawat

erawat commented Jun 4, 2026

Copy link
Copy Markdown
Member Author

Closing in favour of compucorp/io.compuco.gocardless#204 (cache payout items in PayoutService).

The rate-limit pressure that drove this PR turned out to be caused by getPayoutItems re-paginating the same payout for every contribution in a batch. With PR #204 caching the result per request, the original default batch_size=100 runs clean (100/100 reconciled, 0 rate-limit errors, ~110s in production test). Lowering the default is no longer needed.

@erawat erawat closed this Jun 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant