Closed gianlup closed 8 months ago
I use a read/writer set up on GCP with a cluster and have not run into this issue before but defo makes sense why it could be happening.
It sounds like a race condition with your two databases but you should still be allowed to read from the DB that writes too, that way you should not run into the replication issue.
Do you have some load balancing, that might be forcing you onto the read only DB as a user but the application runtime is sent to the master i.e. writer?
Feel free to create a PR though, as it is worth covering this on the modal.
Expected Behavior
Shop installs correctly
Current Behavior
Shop installs correctly only with a second attempt. At the first attempt it returns 500
Failure Information
I have a DB cluster configured with a reader and a writer. At the first install attempt a new user is created in the DB and instantly re-read, but in this way the writer doesn't have time to replicate itself to reader and the query fails. At the second attempt the new user is already available on the reader so everything works fine.
The action is performed here: https://github.com/Kyon147/laravel-shopify/blob/62849824554f9c9eef3137f60c3880568b7f2117/src/Actions/InstallShop.php#L75
Possible solution: use the function
onWriteConnection
of LaravelModel
class. In this way the DB is forced to read from the writer instance.Steps to Reproduce
Please provide detailed steps for reproducing the issue.
Failure Logs
Please include any relevant log snippets or files here.