BookingCart::heldLines() goes through TransactionLookup::lineBookings(), which runs an entity query every time it is called and remembers nothing. The entities themselves come back from the entity static cache on later calls, so what repeats is the query that finds their ids, once per caller.

The endpoint serving a visitor their own half of a slot now pays that twice. It reads the basket to build its answer, and the overlay stamp it restates on the way out reads the basket again to work out what to stamp. Both go through the same method; neither knows the other has just run.

This was introduced with the stamp restatement in #3615965: A hold deadline is read as an empty basket, and one toggle operation guesses whether a click books or releases, described there as costing nothing on the grounds that the endpoint had already read the basket. That was wrong: having read it does not help, because nothing keeps the result.

Why it is worth fixing rather than reverting

Restating the stamp there is what lets a swept basket clear itself, and a sweep runs in cron with no response to announce it on, so there is no other moment to do it. The read is the part to fix.

Proposed resolution

  • Hold the held lines for the length of a request, in BookingCart, and drop them when a line is held or released so a mutation cannot read its own stale list. Every caller benefits, not only this endpoint: the pooled operation and the map builder each ask more than once in a request too.
  • Cover the endpoint with a query count, which is the thing missing here. Nothing measures it today, which is why a green pipeline carried this in: the map document has a cost test and the available-place reads have one, and the visitor's own half has neither.

Remaining tasks

  • Measure the endpoint as it stands, so the before and after are both recorded rather than assumed.
  • Keep the lines for the request, invalidating on hold and on release.
  • Assert the count, so a future caller cannot quietly add a third read.

Issue fork yoyaku-3615974

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

mably created an issue. See original summary.

  • mably committed 4b6c9d6d on 1.x
    fix: #3615974 The basket's held lines are read again for every caller in...
mably’s picture

Status: Active » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.