Closed BurtGummer closed 1 year ago
I don't understand the behavior and cannot reproduce this problem. On enabling of Polls the repair steps are beeing executed and all illegal duplicates get removed before creating the indexes.
Please try the following steps until the app is enabled properly
oc_polls_options
for duplicates (poll_id
and poll_option_text
)I ran into the same issue and feel a little stuck.
It looks like https://github.com/nextcloud/polls/blob/787e3e34e4c94ebcc597003c11a28eb0d246b222/lib/Migration/TableSchema.php#L59 shows that the index requires a unique combination of ['poll_id', 'poll_option_hash', 'timestamp']
, not poll_id
and poll_option_text
. This was changed in #2777.
In my oc_polls_options
the poll_option_hash
column is empty and on many rows the timestamp
column is set to 0. I don't know if this happened during the migration or if (some of) these values were already like this. With multiple options for different polls the DBMS is correctly seeing duplicate combinations.
Edit: continuing looking for the cause of this error, I see that during the upgrade to Nextcloud 25 (from the latest 24), the poll_option_hash
column was created and most other columns were converted from integer to bigint. But this migration did not fill the hash column apparently.
A look at the backup of the database indicates that the cells in the timestamp column were 0
before the migration. So to fix the table contents, setting the timestamp to a reasonable unique value for each option may solve this breaking error.
Thanks for your analysis. This helps. I will come back on this later today.
In my
oc_polls_options
thepoll_option_hash
column is empty
This is strange, because all hashes should get updated in a repairstep right after executing the migration. I guess, that the problem lies here.
on many rows the
timestamp
column is set to 0.
This is right for options of a text poll.
The request for checking poll_id
and poll_option_text
is because it is readable. The hash is calculated from poll_id
and poll_option_text
.
Same problem here. After NC update, the App was disabled. Can't enable it again, because it will fail with this error. Also, removing and downloading it again will yield the same result.
[settings] Error: Exception: Database error when running migration 040102Date20230123072601 for app polls
An exception occurred while executing a query: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1--0' for key 'UNIQ_options' at <<closure>>
0. /var/www/virtual/wwnc/html/lib/private/Installer.php line 153
OC\DB\MigrationService->migrate("latest", false)
1. /var/www/virtual/wwnc/html/apps/settings/lib/Controller/AppSettingsController.php line 451
OC\Installer->installApp("polls")
2. /var/www/virtual/wwnc/html/lib/private/AppFramework/Http/Dispatcher.php line 230
OCA\Settings\Controller\AppSettingsController->enableApps(["polls"], [])
3. /var/www/virtual/wwnc/html/lib/private/AppFramework/Http/Dispatcher.php line 137
OC\AppFramework\Http\Dispatcher->executeController(["OCA\\Settings\ ... "], "enableApps")
4. /var/www/virtual/wwnc/html/lib/private/AppFramework/App.php line 183
OC\AppFramework\Http\Dispatcher->dispatch(["OCA\\Settings\ ... "], "enableApps")
5. /var/www/virtual/wwnc/html/lib/private/Route/Router.php line 315
OC\AppFramework\App::main("OCA\\Settings\\ ... r", "enableApps", ["OC\\AppFramewo ... "], ["settings.AppSettings.enableApps"])
6. /var/www/virtual/wwnc/html/lib/base.php line 1056
OC\Route\Router->match("/settings/apps/enable")
7. /var/www/virtual/wwnc/html/index.php line 36
OC::handleRequest()
In my Database oc_polls_options
the poll_option_hash
is 0
for all entries.
EDIT: I've tried to solve this via running this SQL query:
UPDATE `oc_polls_options` SET poll_option_hash = MD5(CONCAT(poll_id,poll_option_text,timestamp)) WHERE poll_option_hash=0;
But the problem also seems to affect other tables, because now I get a similar error for another table:
Exception: Database error when running migration 040102Date20230123072601 for app polls An exception occurred while executing a query: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1-moritz-' for key 'UNIQ_votes'
EDIT2: After also running this SQL statement:
UPDATE `oc_polls_votes` SET vote_option_hash = MD5(CONCAT(poll_id,user_id,vote_option_text)) WHERE vote_option_hash=0;
Now everything seems like it's working again. So as a hotfix (at your own risk), try running these 2 SQL statements to create all the necessary hashes to be able to fulfill the unique constraints.
OMG. 🙈 I did not recognize it came from the migration routine. Fix will come along shortly with the next version.
This issue seems to have re-appear in a slightly different form...
I've just updated from NC24 to NC25.0.10:
Database error when running migration 050100Date20230515083001 for app polls Column "oc_polls_options"."poll_option_hash" is NotNull, but has empty string or null as default.
From looking at discussion above this looks like similar problem relating to poll_option_hash. My guess is that the migration fix added to 5.0.5 added as result of discussion above is failing because neither hash is present or column is null...
These are Nextcloud error log enteries. I'm going to try and have a look at the table in the database ...
Just logged into the database, and it would appear that 'poll_option_hash' column doesn't exist...
So I can't try setting it with Hash manually. If anyone has any advise that would be much appreciated.
First of all: Please always open a new issue and try to avoid sharing new observations in a closed issue.
Try to fix it with occ polls:db:rebuild
Thanks @dartcafe -- I've created new issue https://github.com/nextcloud/polls/issues/3067 for this and tried occ polls:db:rebuild but is say's command not found in name-space (possibility because polls app isn't enabled?)
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.
⚠️ This issue respects the following points: ⚠️
What went wrong, what did you observe?
I upgrade Nextcloud from 24.0.12 to 25.0.6 on a Debian 11 with MySQL, everything is OK. But polls (5.0.4) was disabled, if I enable it, this error occure:
I try to disable/enable it, it seems its the same problem from this issue: https://github.com/nextcloud/polls/issues/2853 but there is no change.
What did you expect, how polls should behave instead?
Just enable the app polls:
root@server /var/www/html/nextcloud # sudo -u www-data php occ app:update polls root@server /var/www/html/nextcloud # cd /var/www/html/nextcloud/ ; sudo -u www-data php occ app:enable polls Database error when running migration 040102Date20230123072601 for app polls An exception occurred while executing a query: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '2--0' for key 'UNIQ_options' root@server /var/www/html/nextcloud #
What steps does it need to replay this bug?
Installation method
Installed/updated from the appstore (Apps section of your site)
Installation type
Updated from a minor version within same major version (i.e. 4.0.0 to 4.1.1)
Affected polls version
5.0.4
Which browser did you use, when experiencing the bug?
Which System did you use, when experiencing the bug?
Nextcloud 25 (Nextcloud Hub 3)
PHP engine version
PHP 7.3
Database engine
MySQL
Which user-backends are you using?
Configuration report