Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[9.x] Always use the write PDO connection to read the just stored pending batch #43737

Merged
merged 5 commits into from
Aug 17, 2022

Conversation

corneyl
Copy link
Contributor

@corneyl corneyl commented Aug 17, 2022

Setting the sticky option to false for a database connection with separate read/write database nodes, results in problems with finding a batchable job right after creation.

This can happen because the read query is executed on a replicated read-only node directly after writing to the write node. If the select query is executed faster than the database replication takes place, then no batch is found. In that case an exception is thrown because jobs are added to a null batch.

This PR fixes this problem by always using the write PDO connection for finding the just created batchable job in the store() method in DatabaseBatchRepository.php.

@corneyl corneyl force-pushed the fix-sticky-db-bug-for-job-batches branch from aa524e7 to b1343d8 Compare August 17, 2022 11:23
@GrahamCampbell GrahamCampbell changed the title Always use the write PDO connection to read the just stored pending batch [9.x] Always use the write PDO connection to read the just stored pending batch Aug 17, 2022
@corneyl corneyl force-pushed the fix-sticky-db-bug-for-job-batches branch from 78bf6d6 to 0883431 Compare August 17, 2022 12:20
@taylorotwell
Copy link
Member

Probably easier to just always use write PDO in this situation. We can't change a contract method signature on a patch release.

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.

3 participants