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

Issue with using "sticky" option with Postgresql driver and read/write connections. #32966

Closed
nesh-ua opened this issue May 26, 2020 · 2 comments

Comments

@nesh-ua
Copy link
Contributor

nesh-ua commented May 26, 2020

  • Laravel Version: 7.4.3
  • PHP Version: 7.12.0
  • Database Driver & Version: PostgreSQL 12

Description:

I have 2 connection with db (read/write). Also i set "sticky" option as true. After creating new row all request to DB use "read" connection. After updating some row, there are not any problem. This problem is happened when table has auto increment.

Steps To Reproduce:

//create some row.
$quest = factory(Quest::class)->create();
// update this row. if i remove comment for next lines, everything work alright. Because update was made. But when we make only create, selection works via "read" connection.
//$quest->limit_winners = random_int(1, 200);
//$quest->update();
// find this row. (use read connection), but if i understood right have to use write connection, because new row was created.
$quest = Quest::query()->where('id', $quest->id)->first();
print_r($quest);
@taylorotwell
Copy link
Member

Don't see any issue in the code. Feel free to make a PR to address any bug you find.

@nesh-ua
Copy link
Contributor Author

nesh-ua commented May 26, 2020

@taylorotwell
I found a problem here:
/framework/src/Illuminate/Database/Query/Processors/PostgresProcessor.php
When called "processInsertGetId" function we only create new row via selectFromWriteConnection. But function "recordsHaveBeenModified" is not called (this need because all next requests have to use "write connection").

This is my pr #32973

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

No branches or pull requests

2 participants