Database conversion crash - part 2 and 3

The Basics

  • Nextcloud Server version (e.g., 29.x.x):
  • Operating system and version (e.g., Ubuntu 24.04):
    • openSUSE Leap 15.6
  • Web server and version (e.g, Apache 2.4.25):
    • apache2, 2.4.66
  • Reverse proxy and version _(e.g. nginx 1.27.2)
    • none atm, I am testing on a offline copy
  • PHP version (e.g, 8.3):
    • PHP 8.2.30
  • Is this the first time you’ve seen this error? (Yes / No):
    • Yes, this is my first attempt to convert a database
  • When did this problem seem to first start?
    • at first attempt
  • Installation method (e.g. AlO, NCP, Bare Metal/Archive, etc.)
    • Cant remember
  • Are you using CloudfIare, mod_security, or similar? (Yes / No)
    • No

Summary of the issue you are facing:

In preparation for moving to All-In-One I want to convert the database from mariadb to postgrsql, but conversion breaks down after a while. I preparation I deleted apps Shifts-next and Mail (error similar to this) as these made the process crash.
Now I am stuck again and I dont know what to skip this time.

Steps to replicate it (hint: details matter!):

There is currently 2 servers in this setup, a database host and a apache host. Both are cloned from the production ones, and slightly modified to run with internal servernames/ip

  1. added postgresql on the database host and set it up for receiving the database as described on migration page.

  2. verified that Nexcloud was responding in the cloned setup and that I could establish connection to postgreSQL from the web server

  3. Deleted Apps: Mail, Shiftsnext in the web ui

  4. start migration using the occ db:convert-type command (se full command in log below)

Log entries

Nextcloud

Ran this on the command line, so I guess this is more relevant:

sudo -u wwwrun /usr/bin/php  /srv/www/htdocs/nextcloud/occ  maintenance:repair --include-expensive
localadm@skykino-02:~> sudo -u wwwrun -s /srv/www/htdocs/nextcloud/occ db:convert-type --port 5432 --password "$PG_PASSWORD" pgsql "$PG_USER" 192.168.80.131 "$PG_DATABASE"
PHP Warning:  Module "pgsql" is already loaded in Unknown on line 0
PHP Warning:  Module "pdo_pgsql" is already loaded in Unknown on line 0
Creating schema in new database
 - activity
 - app_api
 - approval
 - appstore
 - bruteforcesettings
 - calendar
 - circles
 - cloud_federation_api
 - comments
 - contacts
 - contactsinteraction
 - dashboard
 - dav
 - deck
 - federatedfilesharing
 - federation
 - files
 - files_downloadlimit
 - files_lock
 - files_pdfviewer
 - files_reminders
 - files_sharing
 - files_trashbin
 - files_versions
 - fileslibreofficeedit
 - firstrunwizard
 - forms
 - groupfolders
 - logreader
 - lookup_server_connector
 - nextcloud_announcements
 - notifications
 - notify_push
 - oauth2
 - office
 - password_policy
 - passwords
 - passwords_handbook
 - photos
 - privacy
 - profile
 - provisioning_api
 - recommendations
 - related_resources
 - serverinfo
 - settings
 - spreed
 - support
 - survey_client
 - suspicious_login
 - systemtags
 - text
 - theming
 - twofactor_backupcodes
 - twofactor_nextcloud_notification
 - twofactor_totp
 - updatenotification
 - user_status
 - viewer
 - weather_status
 - webhook_listeners
 - workflowengine
The following tables will not be converted:
oc_cms_pico_websites
oc_collectives
oc_collectives_pages
oc_collectives_shares
oc_ex_event_handlers
oc_ex_speech_to_text
oc_ex_speech_to_text_q
oc_ex_text_processing
oc_ex_text_processing_q
oc_ex_translation
oc_ex_translation_q
oc_file_metadata
oc_mail_accounts
oc_mail_actions
oc_mail_action_step
oc_mail_aliases
oc_mail_attachments
oc_mail_blocks_shares
oc_mail_cc_tasks
oc_mail_coll_addresses
oc_mail_delegations
oc_mail_internal_address
oc_mail_local_messages
oc_mail_mailboxes
oc_mail_messages
oc_mail_messages_retention
oc_mail_messages_snoozed
oc_mail_message_tags
oc_mail_provisionings
oc_mail_recipients
oc_mail_smime_certificates
oc_mail_tags
oc_mail_text_blocks
oc_mail_trusted_senders
oc_onlyoffice_filekey
oc_onlyoffice_instance
oc_onlyoffice_permissions
oc_polls_comments
oc_polls_groups
oc_polls_groups_polls
oc_polls_log
oc_polls_notif
oc_polls_options
oc_polls_polls
oc_polls_preferences
oc_polls_share
oc_polls_votes
oc_polls_watch
oc_preview_generation
oc_richdocuments_assets
oc_richdocuments_direct
oc_richdocuments_wopi
oc_secrets
oc_shifts
oc_shifts_cal_changes
oc_shifts_change
oc_shifts_type
oc_twofactor_admincodes
Please note that tables belonging to disabled (but not removed) apps
can be included by specifying the --all-apps option.
Continue with the conversion (y/n)? [n] y
 - oc_accounts
 55/55 [============================] 100% < 1 sec/< 1 sec
 - oc_accounts_data
 828/828 [============================] 100%  1 sec/1 sec 
 - oc_activity
chunked query, 109 chunks
 108332/108332 [============================] 100% 1 min, 46 secs/1 min, 46 secs
 - oc_activity_mq
    0 [>---------------------------] < 1 sec
 - oc_addressbookchanges
chunked query, 4 chunks
 3853/3853 [============================] 100% 2 secs/2 secs
 - oc_addressbooks
 40/40 [============================] 100% < 1 sec/< 1 sec
 - oc_appconfig
 363/363 [============================] 100%  1 sec/1 sec 
 - oc_appconfig_ex
    0 [>---------------------------] < 1 sec
 - oc_approval_activity
    0 [>---------------------------] < 1 sec
 - oc_approval_rule_approvers

.... lots of stuff

- oc_users
 55/55 [============================] 100% < 1 sec/< 1 sec
 - oc_vcategory
 3/3 [============================] 100% < 1 sec/< 1 sec
 - oc_vcategory_to_object
 3/3 [============================] 100% < 1 sec/< 1 sec
 - oc_webauthn
 2/2 [============================] 100% < 1 sec/< 1 sec
 - oc_webhook_listeners
    0 [>---------------------------] < 1 sec
 - oc_webhook_tokens
    0 [>---------------------------] < 1 sec

In ExceptionConverter.php line 62:
                                                                                                                       
  An exception occurred while executing a query: SQLSTATE[42601]: Syntax error: 7 ERROR:  syntax error at or near ")"  
  LINE 1: SELECT setval('oc_jobs_id_seq', (SELECT MAX() FROM ))                                                        

In Exception.php line 24:
                                                                        
  SQLSTATE[42601]: Syntax error: 7 ERROR:  syntax error at or near ")"  
  LINE 1: SELECT setval('oc_jobs_id_seq', (SELECT MAX() FROM ))         

In Connection.php line 71:
                                                                        
  SQLSTATE[42601]: Syntax error: 7 ERROR:  syntax error at or near ")"  
  LINE 1: SELECT setval('oc_jobs_id_seq', (SELECT MAX() FROM ))         

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

Configuration

Except for the Shift-next and mail app removed the configuration is as described in my previus post Database conversion crash

Test with option --clear-schema ?

Nope, got to exactly to the same table, it still crashes on converting “oc_webhook_tokens”.

I am testing on cloned snapshot of both the database server and the webserver, this means that I can revert to the same clean state for every test.

I see there is already an open a bug report on this, so I will give up for now :frowning: