Repository navigation
Description
Steps to reproduce
- Login to Owncloud Website
- Open postgresql Serverlog
Expected behaviour
No Error in logs
Actual behaviour
Logfile is being spammed with errors:
2016-03-14 09:48:10 GMT STATEMENT: INSERT INTO "oc_preferences" ("userid", "appid", "configkey", "configvalue") VALUES($1, $2, $3, $4)
2016-03-14 09:48:34 GMT ERROR: duplicate key value violates unique constraint "oc_preferences_pkey"
2016-03-14 09:48:34 GMT DETAIL: Key (userid, appid, configkey)=(testuser, files, quota) already exists.
(I already cleaned up the table, entries being set after next login. After logout und relogin Errors appear again).
Server configuration
Operating system:
Debian 8.3
Web server:
Package: apache2
Version: 2.4.10-10+deb8u1
Database:
Package: postgresql
Version: 9.4+165
PHP version:
Package: php5
Version: 5.6.17+dfsg-0+deb8u1
ownCloud version: (see ownCloud admin page)
9.0.0 (stable)
Updated from an older ownCloud or fresh install:
Update: 7 > 8 > 9
Where did you install ownCloud from:
deb http://download.owncloud.org/download/repositories/stable/Debian_8.0/ /
Signing status (ownCloud 9.0 and above):
No errors have been found.
List of activated apps:
Enabled:
- activity: 2.2.1
- calendar: 1.0
- comments: 0.2
- contacts: 1.0.0.0
- dav: 0.1.5
- external: 1.2
- federatedfilesharing: 0.1.0
- federation: 0.0.4
- files: 1.4.4
- files_external: 0.5.2
- files_pdfviewer: 0.8
- files_sharing: 0.9.1
- files_texteditor: 2.1
- files_trashbin: 0.8.0
- files_versions: 1.2.0
- files_videoplayer: 0.9.8
- firstrunwizard: 1.1
- gallery: 14.5.0
- notifications: 0.2.3
- provisioning_api: 0.4.1
- systemtags: 0.2
- templateeditor: 0.1
- updatenotification: 0.1.0
Disabled: - encryption
- user_external
- user_ldap
The content of config/config.php:
{
"system": {
"instanceid": "_REMOVED",
"passwordsalt": "_REMOVED SENSITIVE VALUE",
"trusted_domains": [
"_REMOVED"
],
"datadirectory": "/var/www/owncloud/data",
"dbtype": "pgsql",
"version": "9.0.0.19",
"dbname": "owncloud",
"dbhost": "localhost",
"dbtableprefix": "oc",
"dbuser": "_REMOVED SENSITIVE VALUE",
"dbpassword": "_REMOVED SENSITIVE VALUE",
"installed": true,
"mail_from_address": "cloud",
"mail_smtpmode": "php",
"mail_domain": "_REMOVED",
"forcessl": true,
"theme": "",
"maintenance": false,
"secret": "_REMOVED SENSITIVE VALUE",
"loglevel": 2,
"memcache.local": "\OC\Memcache\APC",
"trashbin_retention_obligation": "auto",
"updatechecker": false
}
}
Are you using external storage, if yes which one:
No
Are you using encryption:
no
Are you using an external user-backend, if yes which one:
no
Client configuration
Browser:
Firefox 45
Operating system:
Debian 8
Activity
LukasReschke commentedon Mar 14, 2016
Duplicate of #22563
spitzlei commentedon Mar 14, 2016
Why is this a Duplicate?
I'm using Owncloud 9.0 and not 8.0 and here the oc_preferences tables is affected and not the oc_filecache.
nebulade commentedon Mar 14, 2016
We are seeing a similar issue, maybe related but in LDAP code:
If I understand #22563 correctly, can this be ignored for now? I am also using oC 9.0 but with mysql
mobstef commentedon Mar 21, 2016
There is a workaround for this issue, which seems to affect ldap user login in 9.0.
To stop flooding of the logs with the reported error message add a rule to ignore the insert if the constraint violation would occur. After http://dba.stackexchange.com/questions/30499/optimal-way-to-ignore-duplicate-inserts:
CREATE OR REPLACE RULE oc_preferences_ignore_duplicate_inserts AS ON INSERT TO oc_preferences WHERE (EXISTS ( SELECT 1 FROM oc_preferences WHERE oc_preferences.userid = NEW.userid and oc_preferences.appid = NEW.appid and oc_preferences.configkey = NEW.configkey)) DO INSTEAD NOTHING;jknockaert commentedon Mar 22, 2016
Seeing a similar issue, but without LDAP:
The postgres log is full of these lines. Especially with the os x client app this error happens multiple times per user per minute.
@LukasReschke Pls reopen. This happens on OC 9 (with postgres) and is not a duplicate of #22563
jknockaert commentedon Mar 31, 2016
Do we already know which regression caused this behaviour?
voidzero commentedon Apr 21, 2016
@mobstef Any idea how to reverse this query, for when the bug gets fixed?
mobstef commentedon Apr 21, 2016
@voidzero Rather straightforward:
drop rule oc_preferences_ignore_duplicate_inserts on oc_preferences;voidzero commentedon Apr 21, 2016
Perfect, @mobstef. Much thanks.
nickvergessen commentedon Jun 8, 2016
Just had a look at the code, it seems to be expected. We run the insert, then catch the php side exception that is thrown by doctrine when the key is violated and update instead.
Basically we could try and change the preference stuff to use
insertIfNotExists(), but we can't do that in the current methodConnection::setValues()because we don't know for all of the use-cases of the method, what keys they would need to check.21 remaining items
mrow4a commentedon Apr 5, 2017
Seems fixed by @butonic around November 9fe34ef for versions 9.1>
Hail @butonic, @PVince81 can we try to backport it to 9.0 and check if this fixes the issue?
mrow4a commentedon Apr 5, 2017
@DeepDiver1975 Yet another motivation to get rid of <9.1 fantastic legacy code and doing query only with Doctrine and QueryBuilder, yet this is not strictly related to this issue?
jknockaert commentedon Apr 5, 2017
No need for me to backport. If it is fixed then it is ok for me to just close this ticket.
mrow4a commentedon Apr 5, 2017
Yep, but maybe I would need to check it again on Postgre if that really fixed the issue also for < 9.1 versions :>. Lets see what @butonic says, can I just cherry-pick 9fe34ef and test again Posgre, wont it break sth?
butonic commentedon Apr 5, 2017
Skimming this issue I only see a reference to an INSERT statement. The PR mentioned by @mrow4a only touches a SELECT. It does change the statement a little, however, as it adds a NOT NULL check: 9fe34ef#diff-512d39632663dc8e28bba3e11ac5dd52R423
@mrow4a If you can reproduce this I'd like to verify the PR actually fixes this issue as it was intended to fix an oracle only problem. Could you backport?
mrow4a commentedon Apr 5, 2017
@jknockaert @butonic @PVince81 I verified and on OC9.1 the issue exists, and on OC10 issue is solved, because
setUserValuefunction is not being called on repetitive login (called only on first user login) and also different values are being inserted to oc_preferences table. I also upgraded from 9.1->10. However, we cannot backport it to lower version, because code responsible for that has been completely refactored for version 10 and it is not related (directly) to the COMMIT I mentioned above, as I was hoping it will be.Is it ok for you that it is solved in 10 and I can close the ticket? Please reopen if it happens again in OC10
mrow4a commentedon Apr 5, 2017
@DeepDiver1975 Now oc_accounts table is responsible for these things right, I think it was your crazy long PR https://github.com/owncloud/core/pull/27276/files#diff-37958be4e01e8baeb127a59409e1a593R125? Sorry @butonic, it was Thomas hard work i think, not yours .. :>

mrow4a commentedon Apr 5, 2017
Debugging further the issue to find corner cases, one could experience "one-time" violation if he is changing the language e.g. from English to Polish etc, so next login after the change will once experience it, however any consequtive login wont. @DeepDiver1975 any priority on fixing this, since it is only happening once user changes his preference? (It is not violating during initialization of the preference and not with consequtive logins)
mrow4a commentedon Apr 5, 2017
I could not stand looking at this "universal querying" and there is ongoing PR #27576, which will fix above issue in OC10 and potentialy all other if backported to <9.1 (needs checking the backport). However ideally we should kill that setValue thing, I am not a fan of "universality" in big scale instances, but this i not in scope of OC10 I guess ( @DeepDiver1975 ?)
PVince81 commentedon Apr 6, 2017
There is more code that changes stuff in oc_preferences than just changing the language I think.
Third party apps are also able to store user preferences there, so I suspect the exception might be logged for those cases as well.
israel-lugo commentedon Apr 24, 2017
@mrow4a Please note that the message does appear after consecutive logins, at least in my use case. I am not changing languages every day, yet I had 142 occurrences of the message in the last 12 hours. Just normal contact/calendar sync traffic from my clients (cellphone, MUA).
mrow4a commentedon Apr 24, 2017
Yep, will wake up the topic in here #27576, I already fixed it, however needs some adjustment.
lock commentedon Aug 2, 2019
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.