nextcloud / server

☁️ Nextcloud server, a safe home for all your data
https://nextcloud.com
GNU Affero General Public License v3.0
26.94k stars 4.02k forks source link

Unable to db:convert-type to pgsql: value too long for type character varying(250) #22882

Closed jamesstidard closed 3 years ago

jamesstidard commented 4 years ago

How to use GitHub

Steps to reproduce

  1. php occ db:convert-type --all-apps pgsql user host database (migrating from sqlite to Postgres)

Expected behaviour

Successful migration.

Actual behaviour

The schema produced in the Postgres database doesn't allow records in the current database to be inserted.

I've redacted the values of the fields below just as it's potentially sensitive information. Though I have included the approx lengths of the longer strings.

An exception occurred while executing 'INSERT INTO "oc_filecache" ("fileid", "storage", "path",
  "path_hash", "parent", "name", "mimetype", "mimepart", "size", "mtime", "storage_mtime", "encryp
  ted", "unencrypted_size", "etag", "permissions", "checksum") VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?
  , ?, ?, ?, ?, ?, ?)' with params ["...", "...", "...275 length string here...", "...", "...", "... 252 length string here ...", "...", "...", "...", "...", "...", "...", "...", "...", "...", ""]:

  SQLSTATE[22001]: String data, right truncated: 7 ERROR:  value too long for type character varying(250)

I believe it to be the oc_filecache.name field to be the problem. The generated schema uses a varying(250) and the name of the file exceeds this.

Is it safe to manually edit this and then rerun the migration and have the migration use an existing schema? If so, how would I do this?

Thanks.

Server configuration

Operating system: Ubuntu 18.04.5 LTS

Web server: Docker Image: nextcloud:19.0.3

Database: Docker Image: postgres:12

PHP version: Docker Image: nextcloud:19.0.3 appears to use v7.4.10

Nextcloud version: (see Nextcloud admin page) 19.0.3

Updated from an older Nextcloud/ownCloud or fresh install: Started life as a v16 docker image and incrementally upgraded to v19

Where did you install Nextcloud from: https://hub.docker.com/_/nextcloud

Signing status:

Signing status ``` Login as admin user into your Nextcloud and access http://example.com/index.php/settings/integrity/failed paste the results here. ```

List of activated apps:

App list ``` If you have access to your command line run e.g.: www-data@9c1765f5416f:~/html$ php occ app:list Enabled: - accessibility: 1.5.0 - activity: 2.12.0 - announcementcenter: 3.8.1 - bruteforcesettings: 2.0.1 - cloud_federation_api: 1.2.0 - comments: 1.9.0 - contactsinteraction: 1.0.0 - dav: 1.15.0 - federatedfilesharing: 1.9.0 - federation: 1.9.0 - files: 1.14.0 - files_accesscontrol: 1.9.1 - files_pdfviewer: 1.8.0 - files_rightclick: 0.16.0 - files_sharing: 1.11.0 - files_trashbin: 1.9.0 - files_versions: 1.12.0 - files_videoplayer: 1.8.0 - firstrunwizard: 2.8.0 - logreader: 2.4.0 - lookup_server_connector: 1.7.0 - nextcloud_announcements: 1.8.0 - notifications: 2.7.0 - oauth2: 1.7.0 - onlyoffice: 5.0.0 - password_policy: 1.9.1 - photos: 1.1.0 - privacy: 1.3.0 - provisioning_api: 1.9.0 - recommendations: 0.7.0 - serverinfo: 1.9.0 - settings: 1.1.0 - sharebymail: 1.9.0 - support: 1.2.1 - survey_client: 1.7.0 - systemtags: 1.9.0 - text: 3.0.1 - theming: 1.10.0 - twofactor_backupcodes: 1.8.0 - updatenotification: 1.9.0 - viewer: 1.3.0 - workflowengine: 2.1.0 Disabled: - admin_audit - encryption - files_external - user_ldap ```

Nextcloud configuration:

Config report ``` www-data@9c1765f5416f:~/html$ php occ config:list system { "system": { "htaccess.RewriteBase": "\/", "memcache.local": "\\OC\\Memcache\\APCu", "apps_paths": [ { "path": "\/var\/www\/html\/apps", "url": "\/apps", "writable": false }, { "path": "\/var\/www\/html\/custom_apps", "url": "\/custom_apps", "writable": true } ], "instanceid": "***REMOVED SENSITIVE VALUE***", "passwordsalt": "***REMOVED SENSITIVE VALUE***", "secret": "***REMOVED SENSITIVE VALUE***", "trusted_domains": [ "10.1.62.101:9000", "nextcloud.internal.wv" ], "datadirectory": "***REMOVED SENSITIVE VALUE***", "dbtype": "sqlite3", "version": "19.0.3.1", "overwrite.cli.url": "http:\/\/10.1.62.101:9000", "installed": true, "mail_smtpmode": "smtp", "mail_smtpsecure": "ssl", "mail_sendmailmode": "smtp", "mail_from_address": "***REMOVED SENSITIVE VALUE***", "mail_domain": "***REMOVED SENSITIVE VALUE***", "mail_smtpauthtype": "LOGIN", "mail_smtpauth": 1, "mail_smtphost": "***REMOVED SENSITIVE VALUE***", "mail_smtpport": "465", "mail_smtpname": "***REMOVED SENSITIVE VALUE***", "mail_smtppassword": "***REMOVED SENSITIVE VALUE***", "maintenance": false, "loglevel": 2 } } ```

Are you using external storage, if yes which one: Docker volume binds.

Are you using encryption: yes/no

Are you using an external user-backend, if yes which one: LDAP/ActiveDirectory/Webdav/...

LDAP configuration (delete this part if not used)

LDAP config ``` With access to your command line run e.g.: sudo -u www-data php occ ldap:show-config from within your Nextcloud installation folder Without access to your command line download the data/owncloud.db to your local computer or access your SQL server remotely and run the select query: SELECT * FROM `oc_appconfig` WHERE `appid` = 'user_ldap'; Eventually replace sensitive data as the name/IP-address of your LDAP server or groups. ```

Client configuration

Browser:

Operating system:

Logs

Web server error log

Web server error log ``` Insert your webserver log here ```

Nextcloud log (data/nextcloud.log)

Nextcloud log ``` Insert your Nextcloud log here ```

Browser log

Browser log ``` Insert your browser log here, this could for example include: a) The javascript console log b) The network log c) ... ```
kesselb commented 4 years ago

cc @nickvergessen @icewind1991

nickvergessen commented 4 years ago

can you please share the real strings?

jamesstidard commented 4 years ago

Hey @nickvergessen, thanks for the response. I redacted them initially, incase the file names were sensitive from my company's perspective. I asked for permission to share them now. This is a screenshot I grabbed of the error.

Screenshot 2020-09-16 at 12 23 45 pm

I no longer have the output but I ran the image above through a OCR, so hopefully helpful if you need access to the raw text (but be aware of potential OCR errors). I can rerun the migration if needed, just didn't want to put the nextcloud into maintenance mode and disrupting people if not necessary.

An exception occurred while executing 'INSERT INTO "oc_filecache" ("fileid", "storage", "path", "path_hash", "parent", "name", "mimetype", "mimepart", "size", "mtime", "storage_mtime", "encrypted", "unencrypted_size", "etag", "permissions", "checksum") VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ? , ?, ?, ?, ?, ?, ?)' with params ["233262", "2", "files_trashbin\/files\/Flexible Wave Power — AWS Ocean Energy — clean renewable marine energy — sub—sea wave power — power converter for remote communities — autonomous power generator — award—winning design — the future of wave power — Archimedes Waveswing_files.d1589439525", "c43148c4a0a0998a791f06de3d15651e", "102745", "Flexible Wave Power — AWS Ocean Energy — clean renewable marine energy — sub—sea wave power — power converter for remote communities — autonomous power generator — award—winning design — the future of wave power — Archimedes Waveswing_files.d1589439525", "2", "1", "1980096", "1589439478", "158943 9478", "0", "0", "5ebcebf66d435", "31", ""]: 
SQLSTATE[22001]: String data, right truncated: 7 ERROR: value too long for type character varying(250) 
In PDOStatement.php line 119: 
SQLSTATE[22001]: String data, right truncated: 7 ERROR: value too long for type character varying(250) 
In PDOStatement.php line 117: 
SQLSTATE[22001]: String data, right truncated: 7 ERROR: value too long for type character varying(250) 
nickvergessen commented 4 years ago

yeah, it's 253 for me, but maybe the dashes were utf8 dashes before OCR, so it could be each dash is 2 chars in terms of the database.

Timoses commented 3 years ago

I am hitting the same error:

www-data@DietPi:~/html$ php occ db:convert-type --port 5432 --password="7wYjBFCFz22VU2zj8k1MA" pgsql nextcloud 127.0.0.1 nextcloud
Creating schema in new database
oc_migrations
Skipping migrations table because it was already filled by running the migrations
oc_recent_contact
    0 [>---------------------------]oc_appconfig
 184/184 [============================] 100%oc_storages
 4/4 [============================] 100%oc_addressbooks
 2/2 [============================] 100%oc_mimetypes
 85/85 [============================] 100%oc_filecache
chunked query, 307 chunks
  18700/306316 [=>--------------------------]   6%
In AbstractPostgreSQLDriver.php line 79:

  An exception occurred while executing 'INSERT INTO "oc_filecache" ("fileid", "storage", "path", "path_hash", "paren
  t", "name", "mimetype", "mimepart", "size", "mtime", "storage_mtime", "encrypted", "unencrypted_size", "etag", "per
  missions", "checksum") VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)' with params ["24877", "5", "unikiste
  \/KTH\/Periods\/P1\/MedIT\/ShortPaper\/MedIT\/Sources\/Timo\/2007_A_Working_Brain_Model_MIT_Technology_Review_files
  \/Mjk2ODIxOm5pZF81MzEyMTEsYXJ0aWNsZV8xOTc2NyxuaWRfNDE1MTA0LGFydGljbGVfMjIzMzksYXJ0aWNsZV8xODYyNixuaWRfNDA2NDAzLG5pZ
  F80MDQ2MDQsbmlkXzUzMTI5MSxuaWRfNTMxMDg2LG5pZF81Mjk2OTEsbmlkXzUyOTYwNixuaWRfNTMwNjk2LG5pZF81MzEwNTYsbmlkXzUzMDcwNixu
  aWRfNTMwNjg2LG5pZF81Mz.json", "fc21d3356f4f7bc8a4c24281dd5dbb36", "24854", "Mjk2ODIxOm5pZF81MzEyMTEsYXJ0aWNsZV8xOTc
  2NyxuaWRfNDE1MTA0LGFydGljbGVfMjIzMzksYXJ0aWNsZV8xODYyNixuaWRfNDA2NDAzLG5pZF80MDQ2MDQsbmlkXzUzMTI5MSxuaWRfNTMxMDg2LG
  5pZF81Mjk2OTEsbmlkXzUyOTYwNixuaWRfNTMwNjk2LG5pZF81MzEwNTYsbmlkXzUzMDcwNixuaWRfNTMwNjg2LG5pZF81Mz.json", "4", "3", "
  2584", "1412156085", "1412156085", "0", "0", "842cabe7b8e523b08a6a177f43b8f88a", "27", ""]:

  SQLSTATE[22001]: String data, right truncated: 7 ERROR:  value too long for type character varying(250)

In PDOStatement.php line 129:

  SQLSTATE[22001]: String data, right truncated: 7 ERROR:  value too long for type character varying(250)

In PDOStatement.php line 127:

  SQLSTATE[22001]: String data, right truncated: 7 ERROR:  value too long for type character varying(250)

db:convert-type [--port PORT] [--password PASSWORD] [--clear-schema] [--all-apps] [--chunk-size CHUNK-SIZE] [--] <type> <username> <hostname> <database>

www-data@DietPi:~/html$ echo $?
1

Nextcloud Docker image: 20-fpm Pgsql: 11

I removed the file manually in Nextcloud, but it still seems to be present in the DB.

Any way to solve this?

Timoses commented 3 years ago

@nickvergessen Is there anything I can do to further investigate?

@jamesstidard Did you find a solution yet?

jamesstidard commented 3 years ago

@Timoses, I've not resolved this problem yet. Would very much like a solution though, be it a bug fix or a manual work-around. I'm hesitant to do any work around myself without guidance from a project maintainer though, as I dont want to introduce any data corruption that'll bite me later.

Timoses commented 3 years ago

Even after the following I still receive the same error.... I would have expected that below would clean the filecache entry (the file no longer actually exists) and thus delete the DB entry.

~/html$ php occ files:cleanup
0 orphaned file cache entries deleted
0 orphaned mount entries deleted
~/html$ php occ files:scan --path="/timoses/files/Syncthing/unikiste/KTH/Periods/P1/MedIT"
Starting scan for user 1 out of 1 (timoses)
+---------+-------+--------------+
| Folders | Files | Elapsed time |
+---------+-------+--------------+
| 506     | 853   | 00:00:33     |
+---------+-------+--------------+
Timoses commented 3 years ago

Correction: I was now able to come across this error seemingly (the same file was duplicated in another similar directory; after deleting that, conversion went through).

szaimen commented 3 years ago

Is this Issue still valid in NC21.0.2? If not, please close this issue. Thanks! :)

Timoses commented 3 years ago

Sorry, I  can no longer reproduce as I migrated manually.

Jun 25, 2021, 17:16 by @.***:

Is this Issue still valid in NC21.0.2? If not, please close this issue. Thanks! :)

— You are receiving this because you were mentioned. Reply to this email directly, > view it on GitHub https://github.com/nextcloud/server/issues/22882#issuecomment-868576153> , or > unsubscribe https://github.com/notifications/unsubscribe-auth/ABU2MQZCRAMH5EJPJIWBAFTTUSMVHANCNFSM4ROXOLBQ> .

ghost commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity and seems to be missing some essential information. It will be closed if no further activity occurs. Thank you for your contributions.