Try caching get_remaining_tickets() in APCu to allow tickets to be 'reserved' during checkout, avoiding race condition #1296
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Draft PR due to inability to properly test this right now, and unsure if it's the proper direction forward or worth it.
Ref: https://wordpress.slack.com/archives/C08M59V3P/p1712066063709249
WordCamp Sylhet ran into an issue where WordCamp tickets were oversold, due to a race condition during the checkout process.
The ticket are counted on every pageload, and in the event of a few hundred people attempting to checkout at the same instant, resulted in multiple tickets inserting tickets after the initial
do we have available tickets
check passed.This PR attempts to add some caching/locking using APCu to the process.
This appears to work at first glance, but is not entirely complete.
While writing this PR, I've noticed something that was rather odd.
It appears that some of the order verification is checked after the check for errors, resulting in some of the validation being skipped during checkout, although it seems duplicative.. ba27a3a moved that and I've split it into #1295