Migrating DB from PostgreSQL to MariaDB - invalid memory alloc

Support intro

sudo -u www-data php ./occ db:convert-type mysql --chunk-size 100 nextcloud localhost nextcloud

  • oc_cards
    chunked query, 27 chunks
    1498/2675 [===============>------------] 56% 1 min/3 mins
    In ExceptionConverter.php line 83:

An exception occurred while executing a query: SQLSTATE[XX000]: Internal error: 7 ERROR: invalid memory alloc request size 1074007083Internal error: 7 ERROR: invalid memory alloc request size 1074007083

In Exception.php line 26:

SQLSTATE[XX000]: Internal error: 7 ERROR: invalid memory alloc request size 1074007083

In Connection.php line 82:

SQLSTATE[XX000]: Internal error: 7 ERROR: invalid memory alloc request size 1074007083

Nextcloud version : 23.0.0
Operating system and version : Ubuntu 20.04
nginx version : nginx/1.18.0 (Ubuntu)
PHP version : PHP 7.4.3
PostgreSQL veriosn: psql (PostgreSQL) 12.9 (Ubuntu 12.9-0ubuntu0.20.04.1)
MariaDB version: mariadb Ver 15.1 Distrib 10.4.17-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2

Issue I am facing:
I am trying to migrate my DB from Postgress to MariaDB using ./occ db:convert-type mysql command.
It starts ok, showing all my installed apps and gets running with migration. How ever on one step (with particular small amount of chinks (there are steps with 500+ chunks) it throws:

Internal error: 7 ERROR: invalid memory alloc request size 1074007083

It does not meter what chunk size I use. With or without the argument the result is the same on the same step.

Is this the first time you’ve seen this error? : Y

Steps to replicate it:

  1. Get your Nextcloud running on PostgreSQL database
  2. start migration to mysql with php ./occ db:convert-type mysql --chunk-size 100 user hostname database_name
  3. Wait for the error to occure.

The output of your Nextcloud log in Admin > Logging:

Nothing there
The output of your config.php file:
<?php
$CONFIG = array (
  'instanceid' => '',
  'passwordsalt' => '',
  'secret' => '',
  'trusted_domains' => 
  array (
    0 => '10.8.0.1',
    1 => '127.0.0.1',
  ),
  'datadirectory' => '/raid5/NX_storage',
  'dbtype' => 'pgsql',
  'version' => '23.0.0.10',
    'overwriteprotocol' => 'https',
  'dbname' => 'nextcloud',
  'dbhost' => '127.0.0.1',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextcloud_user',
  'dbpassword' => 'password',
  'installed' => true,
  'maintenance' => false,
  'preview_max_x' => 512,
  'preview_max_y' => 512,
  'preview_max_scale_factor' => 1,
  'default_phone_region' => 'RU',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'app_install_overwrite' => 
  array (
    0 => 'files_external_gdrive',
    1 => 'previewgenerator',
    2 => 'phonetrack',
    3 => 'maps',
    4 => 'files_fulltextsearch_tesseract',
    5 => 'files_fulltextsearch',
    6 => 'fulltextsearch_elasticsearch',
    7 => 'fulltextsearch',
    8 => 'ocr',
    9 => 'gallery',
    10 => 'bookmarks_fulltextsearch',
    11 => 'documents',
    12 => 'ocsms',
    13 => 'audioplayer_editor',
    14 => 'documentserver_community',
    15 => 'workflow_ocr',
  ),
  'theme' => '',
  'loglevel' => 0,
  'logfile' => '/var/log/nextcloud.log',
  'log_rotate_size' => 104857600,
  'log.condition' => 
  array (
    'apps' => 
    array (
      0 => 'admin_audit',
    ),
  ),
  'debug' => false,
  'trusted_proxies' => 
  array (
    0 => '10.8.0.1',
  ),
  'forwarded-for-headers' => 
  array (
    0 => 'HTTP_X_FORWARDED_FOR',
  ),
  'twofactor_enforced' => 'true',
  'twofactor_enforced_groups' => 
  array (
    0 => 'admin',
  ),
  'twofactor_enforced_excluded_groups' => 
  array (
  ),
  'app.mail.verify-tls-peer' => true,
  'mail_smtpmode' => 'smtp',
  'mail_smtpsecure' => 'tls',
  'mail_sendmailmode' => 'smtp',
  'mail_from_address' => 'admin',
  'mail_domain' => 'dimain',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtpauth' => 1,
  'mail_smtphost' => 'smtp.server.com',
  'mail_smtpport' => '587',
  'mail_smtpname' => 'admin@server.com',
  'mail_smtppassword' => 'password',

The output of your nginx/system log in /var/log/____:

There is nothing in the log reg the error or I can't locate it

OK,
It seems that my Postgre DB was corrupted. Indeed I had a RAID failure after which I restored the data and it may well be corrupted. I lost all my contacts b.t.w.

Ok. I had to drop the table oc_cards and I do have oc_cards_properties with all my contacts there.

Sure it’s possible to restore them one by one (1600+ thus) but is there a way to recreate the oc_cards table based on the available oc_cards_properties ?

Or I have to manually restore them one by one?