Skip to content

Fix race condition where response recording can run before request recording under concurrent workers#10

Open
lloricode wants to merge 3 commits into
saloonphp:mainfrom
lloricode:fix/queued-recorder-race-condition
Open

Fix race condition where response recording can run before request recording under concurrent workers#10
lloricode wants to merge 3 commits into
saloonphp:mainfrom
lloricode:fix/queued-recorder-race-condition

Conversation

@lloricode

Copy link
Copy Markdown
Contributor

Summary

Fixes a race condition in the queued recorder where the response
recording can be processed before the request recording under
concurrent queue workers, causing:

SQLSTATE[HY000]: General error: 1364
Field 'connector_class' doesn't have a default value

Root cause

When barstool.queue.enabled = true, request and response recordings
are dispatched as independent jobs sharing the same uuid. With
multiple workers (e.g. Horizon), there is no guaranteed ordering
between the two — the response job can be picked up first.

Previously, the response path used updateOrCreate() (or equivalent),
so when it ran first, it would insert a new row containing only
response-side fields
, omitting connector_class, request_class,
method, request_headers, request_body. MySQL then rejected the
insert because those columns have no default.

Evidence from production

Sentry captured this INSERT statement generated by the response job
running first:

insert into `barstools` (
    `uid`, `duration`, `url`, `response_headers`,
    `response_body`, `response_status`, `successful`, `created_at`
) values (...)

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