Uh oh!
There was an error while loading. Please reload this page.
Issue 12729 postgresql duplicate key value - #13721
Conversation
b028a95 to
f9f6994Compare3b32300 to
c621585CompareMorrisJobke
commented
Jan 29, 2019
Code wise makes a lot of sense. 👍 Let me test this later and then I'm fine with getting this in. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
kesselb
commented
Jan 29, 2019
Please add |
MorrisJobke
commented
Jan 29, 2019
We need to be careful here as it is then a public API we need to keep stable. Maybe we add some PHPDoc to indicate that this is not fully finished and should not be used for now? Maybe we find some cases in the near future where we need to change the API a little bit. |
kesselb
commented
Jan 29, 2019
Is not adding the method to the interface an option? Technically it works 🤔 |
icewind1991
commented
Jan 29, 2019
I would prefer to add the "on conflict" handing to the query builder |
kesselb
commented
Jan 29, 2019
Then query builder has to know which adapter is used by the current connection. Would you prefer to a) introduce child classes I guess both ways have their pros/cons. Maybe you come up with a better idea. |
icewind1991
commented
Jan 29, 2019
You can already determine the sql backend used within the query builder, see the but since this probably makes most sense in the QueryBuilder itself and not a "sub builder" subclassing the QueryBuilder is probably best |
c621585 to
1b1231cCompareoole
commented
Feb 26, 2019
I finally found time to get back to this, thanks for staying with me. I applied the proposed changes to the existing approach, meaning
Though I am interested in the approach of adding it to the QueryBuilder. How would that work, would I just add a function 'upsert' or 'updateIgnoreConflict' to the QueryBuilder that builds the proposed query, and calls the Adapter to build/add the database-specific part to the query? The this could be used directly in the DBLockingProvider. |
| foreach($values as $key => $value) { | ||
| $builder->setValue($key, $builder->createNamedParameter($value)); | ||
| } | ||
| $queryString = $builder->getSQL() . ' ON CONFLICT DO NOTHING'; |
There was a problem hiding this comment.
With which version of Postgres does this work? I only can find it in the docs since Postgres 9.5.
Uh oh!
There was an error while loading. Please reload this page.
MorrisJobke
commented
Feb 26, 2019
Code looks good so far. @icewind1991 Mind to test this? |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
1b1231c to
c0982f7Comparec0982f7 to
86f607cCompare
MorrisJobke
left a comment
There was a problem hiding this comment.
I'm fine with this change 👍
MorrisJobke
commented
Mar 21, 2019
@oole Do you mind to rebase on the latest master because we fixed some failing tests there. |
…file locking. Signed-off-by: Ole Ostergaard <ole.c.ostergaard@gmail.com>
Signed-off-by: Ole Ostergaard <ole.c.ostergaard@gmail.com>
Signed-off-by: Ole Ostergaard <ole.c.ostergaard@gmail.com>
Signed-off-by: Ole Ostergaard <ole.c.ostergaard@gmail.com>
Signed-off-by: Ole Ostergaard <ole.c.ostergaard@gmail.com>
86f607c to
0d778fcCompareoole
commented
Mar 21, 2019
Happy to read! Of course, rebased and pushed. |
blizzz
commented
Mar 21, 2019
What about #13721 (comment) ? Afaik, 9.4 is still suppported until end of this year. |
This comment has been minimized.
This comment has been minimized.
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
MorrisJobke
commented
Mar 21, 2019
I pushed a fix for this. Was a missing |
MorrisJobke
commented
Mar 21, 2019
@kesselb@rullzer@ChristophWurst Mind to review? I would like to get this into beta 1 to have as much test coverage as possible. |
rullzer
left a comment
There was a problem hiding this comment.
Lets do this. And test the hell out of it in real life as well 🚀 🐘
Thanks for your first pull request and welcome to the community! Feel free to keep them coming! If you are looking for issues to tackle then have a look at this selection: https://github.com/nextcloud/server/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22 |

This should fix the
ERROR: duplicate key value violates unique constraint "lock_key_index"errors filling up the PostgreSQL log. As described by Issue 12729.
I moved the insert statement from the DBLockingProvider.php to the Adapter.php, so that database specific inserts are possible.