Social: Primary index name on "oc_social_a2_cache_documts" is too long.

Created on 15 Jan 2020  ยท  32Comments  ยท  Source: nextcloud/social

Describe the bug
App can not be installed on NC 18.0.0.9 as a error during db-migration occurs. Seems related to #506

To Reproduce
Steps to reproduce the behavior:

1. Go to Social on the Apps-Page of your nextcloud instance
1. Click on 'Download and enable'
1. Error message Primary index name on "oc_social_a2_cache_documts" is too long.
1. App is not installed.

Expected behavior
App is installed correctly with needed db

Client details:

  • OS: Windows 10
  • Browser: Firefox
  • Version: 72.01
  • Device: Desktop


Server details

Social app version:
0.2.101?

Operating system:
Debian (Docker)

Web server:
Apache 2.4.38

Database:
Sqlite3 3.27.2

PHP version:
7.3.13

Nextcloud version:
18.0.0 RC2


Logs

Nextcloud log (data/nextcloud.log)

[settings] Error: InvalidArgumentException: Primary index name  on "oc_social_a2_cache_documts" is too long. at <<closure>>

 0. /var/www/html/lib/private/DB/MigrationService.php line 484
    OC\DB\MigrationService->ensureOracleIdentifierLengthLimit(Doctrine\DBAL\Schema\Schema {}, Doctrine\DBAL\Schema\Schema {}, 3)
 1. /var/www/html/lib/private/DB/MigrationService.php line 414
    OC\DB\MigrationService->executeStep("0002Date20190506000001", false)
 2. /var/www/html/lib/private/Installer.php line 151
    OC\DB\MigrationService->migrate()
 3. /var/www/html/apps/settings/lib/Controller/AppSettingsController.php line 443
    OC\Installer->installApp("social")
 4. /var/www/html/lib/private/AppFramework/Http/Dispatcher.php line 170
    OCA\Settings\Controller\AppSettingsController->enableApps(["social"], [])
 5. /var/www/html/lib/private/AppFramework/Http/Dispatcher.php line 99
    OC\AppFramework\Http\Dispatcher->executeController(OCA\Settings\Con ... {}, "enableApps")
 6. /var/www/html/lib/private/AppFramework/App.php line 125
    OC\AppFramework\Http\Dispatcher->dispatch(OCA\Settings\Con ... {}, "enableApps")
 7. /var/www/html/lib/private/AppFramework/Routing/RouteActionHandler.php line 47
    OC\AppFramework\App::main("OCA\\Settings\\ ... r", "enableApps", OC\AppFramework\ ... {}, {_route: "settin ... "})
 8. <<closure>>
    OC\AppFramework\Routing\RouteActionHandler->__invoke({_route: "settin ... "})
 9. /var/www/html/lib/private/Route/Router.php line 299
    call_user_func(OC\AppFramework\ ... {}, {_route: "settin ... "})
10. /var/www/html/lib/base.php line 1008
    OC\Route\Router->match("/settings/apps/enable")
11. /var/www/html/index.php line 38
    OC::handleRequest()

POST /settings/apps/enable

Browser log

Insert your browser log here, this could for example include:

Object { apps: Getter & Setter, categories: Getter & Setter, updateCount: Getter & Setter, loading: Getter & Setter, loadingList: Getter & Setter, โ€ฆ }

{โ€ฆ}
โ€‹
appId: "social"
โ€‹
error: Error
โ€‹โ€‹
columnNumber: 81448
โ€‹โ€‹
config: Object { url: "/settings/apps/enable", method: "post", data: "{\"appIds\":[\"social\"],\"groups\":[]}", โ€ฆ }
โ€‹โ€‹
fileName: "https://nextcloud.domain.com/apps/settings/js/vue-settings-apps-users-management.js?v=e0c431a9-5"
โ€‹โ€‹
isAxiosError: true
โ€‹โ€‹
lineNumber: 7
โ€‹โ€‹
message: "Request failed with status code 500"
โ€‹โ€‹
request: XMLHttpRequest
โ€‹โ€‹โ€‹
mozAnon: false
โ€‹โ€‹โ€‹
mozSystem: false
โ€‹โ€‹โ€‹
onabort: function onabort()
โ€‹โ€‹โ€‹
onerror: function onerror()
โ€‹โ€‹โ€‹
onload: null
โ€‹โ€‹โ€‹
onloadend: null
โ€‹โ€‹โ€‹
onloadstart: null
โ€‹โ€‹โ€‹
onprogress: null
โ€‹โ€‹โ€‹
onreadystatechange: function onreadystatechange()
โ€‹โ€‹โ€‹
ontimeout: function ontimeout()
โ€‹โ€‹โ€‹
readyState: 4
โ€‹โ€‹โ€‹
response: "{\"data\":{\"message\":\"Primary index name  on \\\"oc_social_a2_cache_documts\\\" is too long.\"}}"
โ€‹โ€‹โ€‹
responseText: "{\"data\":{\"message\":\"Primary index name  on \\\"oc_social_a2_cache_documts\\\" is too long.\"}}"
โ€‹โ€‹โ€‹
responseType: ""
โ€‹โ€‹โ€‹
responseURL: "https://nextcloud.domain.com/settings/apps/enable"
โ€‹โ€‹โ€‹
responseXML: null
โ€‹โ€‹โ€‹
status: 500
โ€‹โ€‹โ€‹
statusText: "Internal Server Error"
โ€‹โ€‹โ€‹
timeout: 0
โ€‹โ€‹โ€‹
upload: XMLHttpRequestUpload { onloadstart: null, onprogress: null, onabort: null, โ€ฆ }
โ€‹โ€‹โ€‹
withCredentials: false
โ€‹โ€‹โ€‹
<prototype>: XMLHttpRequestPrototype { open: open(), setRequestHeader: setRequestHeader(), send: send(), โ€ฆ }
โ€‹โ€‹
response: {โ€ฆ}
โ€‹โ€‹โ€‹
config: Object { url: "/settings/apps/enable", method: "post", data: "{\"appIds\":[\"social\"],\"groups\":[]}", โ€ฆ }
โ€‹โ€‹โ€‹
data: Object { data: {โ€ฆ} }
โ€‹โ€‹โ€‹
headers: Object { "cache-control": "no-cache, no-store, must-revalidate", "content-length": "89", "content-security-policy": "default-src 'none';base-uri 'none';manifest-src 'self'", โ€ฆ }
โ€‹โ€‹โ€‹
request: XMLHttpRequest { readyState: 4, timeout: 0, withCredentials: false, โ€ฆ }
โ€‹โ€‹โ€‹
status: 500
โ€‹โ€‹โ€‹
statusText: "Internal Server Error"
โ€‹โ€‹โ€‹
<prototype>: Object { โ€ฆ }
โ€‹โ€‹
stack: "t.exports@https://nextcloud.domain.com/apps/settings/js/vue-settings-apps-users-management.js?v=e0c431a9-5:7:81448\nt.exports@https://nextcloud.domain.com/apps/settings/js/vue-settings-apps-users-management.js?v=e0c431a9-5:45:2592\nt.exports/</p.onreadystatechange@https://nextcloud.domain.com/apps/settings/js/vue-settings-apps-users-management.js?v=e0c431a9-5:7:80381\n"
โ€‹โ€‹
toJSON: function toJSON()
โ€‹โ€‹
<prototype>: Object { โ€ฆ }
โ€‹
<prototype>: Object { โ€ฆ }
apps.js:38:10

bug

Most helpful comment

whwen is this fixed ;(

All 32 comments

For NC 18.0.0.10 it is the same.

Same for me with latest 18 docker image and latest MariaDB. The maximum index length is 64 characters according to this documentation: https://mariadb.com/kb/en/identifier-names/#maximum-length

Same for me on the Docker Apache 18 image.

Also true for 18.0.0.0

Any update on this?

+1 on 18.0.1 Docker with MariaDb

+1 on 18.0.1 on MySQL

Can't you just increase the max character limit for the index keys in mariaDB somehow?

Maybe someone knows an answer: https://stackoverflow.com/questions/60455877/increase-the-max-character-limit-for-the-index-keys-in-mariadb

Could we decrease the table name size for this plugin until this is fixed?

It seems like there is no table definition, It is just the result of all Migration steps, starting with lib/Migration/Version0002Date20190506000001.php which creates the new tables.

I'll try adding a Migration step using this function:

https://github.com/nextcloud/3rdparty/blob/d183b9cbdc62f2302f34cdf51f92aa45a1bb9f60/doctrine/dbal/lib/Doctrine/DBAL/Schema/Schema.php#L330

But I am afraid, the error already occurs in the first step, where the cache table is created. am I right?

I found a workaround, but it seems like the tables social_a2_request_queue and social_a2_stream_action are too long also

workaround:

Go into your nextcloud directory and rename the tables in all files with sed:

grep -rl social_a2_cache_documts custom_apps/social/| xargs sed -i s/social_a2_cache_documts/social_a2_cache_docum/g
grep -rl social_a2_request_queue custom_apps/social/| xargs sed -i s/social_a2_request_queue/social_a2_req_queue/g
grep -rl social_a2_stream_action custom_apps/social/| xargs sed -i s/social_a2_stream_action/social_a2_stream_act/g

I added those changes in a PR ...

I can confirm that rubo77's workaround will allow social to be installed.

The only thing I had to change was custom_apps to apps.

Unfortunately, I now get a ".well-known/webfinger isn't properly set up!". Should I open a separate bug report for that?

whwen is this fixed ;(

I can confirm that rubo77's workaround will allow social to be installed.

The only thing I had to change was custom_apps to apps.

Unfortunately, I now get a ".well-known/webfinger isn't properly set up!". Should I open a separate bug report for that?

double confirmed.

I have been fighting with this for days and had resorted to digging to code, but thought to check here first - then I saw this. I had removed the limitation from the Database though - but that required a fix to MariaDB, in any case, this was the better fix. so i applied it, and worked first time.

if you are migrating from an old version of nextcloud with social enabled already, it 'seems' to work but later down the line seems to have issues with autodiscovery (but maybe that's my setup) - however, that went away also once i removed the app (after the upgrade to latest) and reinstalled after applying the fix above.

for me, i went straight to the app/social folder, adjusted his three commands to point to ./ and immediatly my 4 production sites (applying the same fix to all as they are running) fixed it for me.

so THANK you for that fix!

Unfortunately, I now get a ".well-known/webfinger isn't properly set up!". Should I open a separate bug report for that?

Unfortunately, I now get a ".well-known/webfinger isn't properly set up!". Should I open a separate bug report for that?

look into your autoconfigure or proxy settings on nginx

Look into - Nextcloud - Autoconfigure for WebCal etc documentation - while enabling autoconfigure - there similar settings required I believe for web finger to work, but not sure if fix is related, as a note, my webfinger issue (as I forced the social install by manually adjusting shit in the db etc and moving files about, removing checks and adding some redirection inside of social itself) at one stage appeared to be working, but was also throwing the webfinger issue - but it went away after applying the fix above - but previously in my troubleshooting I had gone back and noticed I had not configured autoconfigure correctly and had to play with some nginx settings (on plesk) to get social to see my 'domain name' and not 'localhost' - it was due to a misconfiguration or incomplete configuration on my part, the issue might be just down to similar on yours.

I found a workaround, but it seems like the tables social_a2_request_queue and social_a2_stream_action are too long also

workaround:

Go into your nextcloud directory and rename the tables in all files with sed:

grep -rl social_a2_cache_documts custom_apps/social/| xargs sed -i s/social_a2_cache_documts/social_a2_cache_docum/g
grep -rl social_a2_request_queue custom_apps/social/| xargs sed -i s/social_a2_request_queue/social_a2_req_queue/g
grep -rl social_a2_stream_action custom_apps/social/| xargs sed -i s/social_a2_stream_action/social_a2_stream_act/g

I added those changes in a PR ...

All three fail...

root@nextcloud:/usr/local/www/nextcloud # grep -rl social_a2_cache_documts apps/social/ | xargs sed -i s/social_a2_cache_documts/social_a2_cache_docum/g
sed: 1: "apps/social/lib/Db/Core ...": command a expects \ followed by text

had removed the limitation from the Database

How did you do that?

Maybe I did sth wrong but after fix I have an error after enable plugin:

An exception occurred while executing 'ALTER TABLE oc_social_a2_stream_act ADD COLUMN liked BOOLEAN NOT NULL': SQLSTATE[HY000]: General error: 1 Cannot add a NOT NULL column with default value NULL

SW: nextcloud:stable-fpm 18.0.3 & SQLite

I had to rebuild and rejig mariadb under the hood. It was a hack. Not a fix

On Sun., Apr. 12, 2020, 10:35 a.m. Ruben Barkow-Kuder, <
[email protected]> wrote:

had removed the limitation from the Database

How did you do that?

โ€”
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/nextcloud/social/issues/850#issuecomment-612650315,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AE2ZSMG74NVFI4IJADDS7VLRMH3VNANCNFSM4KHH6PJA
.

Who is gonna check #879 which would fix this?

Maybe I did sth wrong but after fix I have an error after enable plugin:

An exception occurred while executing 'ALTER TABLE oc_social_a2_stream_act ADD COLUMN liked BOOLEAN NOT NULL': SQLSTATE[HY000]: General error: 1 Cannot add a NOT NULL column with default value NULL

SW: nextcloud:stable-fpm 18.0.3 & SQLite

On MariaDB-1:10.4.12+maria~bionic it works!

I did changes by myself in the code using slightly modified proposition from @profzelonka

Unfortunately, the content of Social tab/app is empty.

Unfortunately, the content of Social tab/app is empty.

have you checked that you 'post' content to a channel that has people to 'view it'. if you post as non public and you have no other accounts to view it the post doesn't seem to get posted. i had to post public to test and then set up some test contacts before i got social to target and view stuff correctly. it first appeared when i posted nothing happened but once i had contacts (besides a solo admin) it worked fine. might not be the case but double check that yourself. it might actually be working

I don't know if this is helpful information or not. The install works with postgres but not with Maria DB.

I don't know if this is helpful information or not. The install works with postgres but not with Maria DB.

Can confirm, not working with Maria DB. :(

The problem here is that you have dbtableprefix set to "oc_" in your nextcloud config.

The problem here is that you have dbtableprefix set to "oc_" in your nextcloud config.
The Problem is either, that maria db is limited on string name length. So far it is a valid bug and needs to be changed.

  • [ ] Request for Change table Name

Affected files: (18.03&18.04)
cloud.patch.txt

  • [ ] change: apps/social/lib/Db/CoreRequestBuilder.php
  • [ ] change: apps/social/lib/Migration/Version0002Date20190506000001.php
  • [ ] change: apps/social/lib/Migration/Version0002Date20190622000001.php
  • [ ] change: apps/social/lib/Migration/Version0002Date20190717000001.php

i submit a patch to fix this

@djdomi I already created a PR: https://github.com/nextcloud/social/pull/879

I think we also have to change the migration steps, otherwise it crashes there. I did that in my PR, but maybe we have to enhance it, so NC instances, that are already working with the long table-names need a table-rename Migration in the right place, before the ordinary Migration begins

The problem here is that you have dbtableprefix set to "oc_" in your nextcloud config.

So another workaround would be to reinstall nextcloud without oc_ as EXTCLOUD_TABLE_PREFIX

I tried this in my docker-test-install, but it seems, like it is impossible to install the docker Nextcloud without oc_ as prefix (#776)

The problem here is that you have dbtableprefix set to "oc_" in your nextcloud config.

No, I tried this, I removed the "oc_" prefix from all my tables and edited config.php but then I get the same according error:

Primary index name on "social_a2_cache_documts" is too long.

so removing the prefix is not enough!

Trying to install social after an occ:social reset --uninstall still yields Primary index name on "oc_social_a2_cache_documts" is too long. when installing via app store on NC19 - doesn't seem closed on my side

Trying to install social after an occ:social reset --uninstall still yields Primary index name on "oc_social_a2_cache_documts" is too long. when installing via app store on NC19 - doesn't seem closed on my side

my merge request was denied, as it would rename documts to doc which would fix this issue

alpha3 should be released later today.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lachmanfrantisek picture lachmanfrantisek  ยท  7Comments

juliushaertl picture juliushaertl  ยท  6Comments

ArtificialOwl picture ArtificialOwl  ยท  6Comments

bernd-wechner picture bernd-wechner  ยท  5Comments

riemy picture riemy  ยท  6Comments