Coder Social home page Coder Social logo

[Bug]: db:convert-type uses systemConfig instead of command line parameters for connection to new target database about server HOT 11 OPEN

ksmonkey123 avatar ksmonkey123 commented on July 20, 2024 2
[Bug]: db:convert-type uses systemConfig instead of command line parameters for connection to new target database

from server.

Comments (11)

joshtrichards avatar joshtrichards commented on July 20, 2024 1

Yes, unfortunately. 😢 The end result is the parameters get swapped so it likely dropped the source database.

Fortunately, recovery should be a simple matter of restoring from backup (just the db portion): https://docs.nextcloud.com/server/latest/admin_manual/maintenance/restore.html#restore-database (or whatever other mechanism you utilize in your environment for database backup/recovery)

from server.

joshtrichards avatar joshtrichards commented on July 20, 2024 1

@Delagen Mind pushing that as PR? I know there may be additional changes needed, but it'll start things in motion.

from server.

Delagen avatar Delagen commented on July 20, 2024 1

@joshtrichards I don't mind that my changes solve the problem correctly. It only makes possible for me successful conversion from MySQL to Postgres

from server.

rotdrop avatar rotdrop commented on July 20, 2024 1

Would not be it the simplest solution, if the ConnectionFactory::getConnection() method would first check if the $additionalConnectionParams argument contains explicit connection parameters and in that case simply skip that fancy primary / replica stuff? At least for the case were the explicitly specified connection differs from the "internal" database connection configured in config/config.php. In principle this should restore the previous behaviour when using the factory for alternate database connections.

from server.

ksmonkey123 avatar ksmonkey123 commented on July 20, 2024

Logging the Parameter $additionalConnectionParams in ConnectionFactory.php on Line 166 shows the following values for the "fromDB" and the "toDB":

FromDB

Array
(
    [adapter] => OC\DB\AdapterMySQL
    [charset] => utf8mb4
    [driver] => pdo_mysql
    [wrapperClass] => OC\DB\Connection
    [driverOptions] => Array
        (
            [1005] => 1
        )

    [user] => nextcloud
    [password] => *************
    [host] => nextcloud-db
    [dbname] => nextcloud
    [tablePrefix] => oc_
    [sqlite.journal_mode] => WAL
    [defaultTableOptions] => Array
        (
            [collate] => utf8mb4_bin
            [charset] => utf8mb4
            [tablePrefix] => oc_
        )

    [primary] => Array
        (
            [adapter] => OC\DB\AdapterMySQL
            [charset] => utf8mb4
            [driver] => pdo_mysql
            [wrapperClass] => OC\DB\Connection
            [driverOptions] => Array
                (
                    [1005] => 1
                )

            [user] => nextcloud
            [password] => ****************
            [host] => nextcloud-db
            [dbname] => nextcloud
            [tablePrefix] => oc_
            [sqlite.journal_mode] => WAL
            [defaultTableOptions] => Array
                (
                    [collate] => utf8mb4_bin
                    [charset] => utf8mb4
                    [tablePrefix] => oc_
                )

        )

    [replica] => Array
        (
            [0] => Array
                (
                    [adapter] => OC\DB\AdapterMySQL
                    [charset] => utf8mb4
                    [driver] => pdo_mysql
                    [wrapperClass] => OC\DB\Connection
                    [driverOptions] => Array
                        (
                            [1005] => 1
                        )

                    [user] => nextcloud
                    [password] => *************
                    [host] => nextcloud-db
                    [dbname] => nextcloud
                    [tablePrefix] => oc_
                    [sqlite.journal_mode] => WAL
                    [defaultTableOptions] => Array
                        (
                            [collate] => utf8mb4_bin
                            [charset] => utf8mb4
                            [tablePrefix] => oc_
                        )

                )

        )

)

ToDB

Array
(
    [adapter] => OC\DB\AdapterMySQL
    [charset] => utf8mb4
    [driver] => pdo_mysql
    [wrapperClass] => OC\DB\Connection
    [driverOptions] => Array
        (
            [1005] => 1
        )

    [user] => nextcloud_app
    [password] => ***************
    [host] => postgres
    [dbname] => nextcloud
    [tablePrefix] => oc_
    [sqlite.journal_mode] => WAL
    [defaultTableOptions] => Array
        (
            [collate] => utf8mb4_bin
            [charset] => utf8mb4
            [tablePrefix] => oc_
        )

    [primary] => Array
        (
            [adapter] => OC\DB\AdapterMySQL
            [charset] => utf8mb4
            [driver] => pdo_mysql
            [wrapperClass] => OC\DB\Connection
            [driverOptions] => Array
                (
                    [1005] => 1
                )

            [user] => nextcloud
            [password] => *************
            [host] => nextcloud-db
            [dbname] => nextcloud
            [tablePrefix] => oc_
            [sqlite.journal_mode] => WAL
            [defaultTableOptions] => Array
                (
                    [collate] => utf8mb4_bin
                    [charset] => utf8mb4
                    [tablePrefix] => oc_
                )

        )

    [replica] => Array
        (
            [0] => Array
                (
                    [adapter] => OC\DB\AdapterMySQL
                    [charset] => utf8mb4
                    [driver] => pdo_mysql
                    [wrapperClass] => OC\DB\Connection
                    [driverOptions] => Array
                        (
                            [1005] => 1
                        )

                    [user] => nextcloud
                    [password] => **********
                    [host] => nextcloud-db
                    [dbname] => nextcloud
                    [tablePrefix] => oc_
                    [sqlite.journal_mode] => WAL
                    [defaultTableOptions] => Array
                        (
                            [collate] => utf8mb4_bin
                            [charset] => utf8mb4
                            [tablePrefix] => oc_
                        )

                )

        )

    [port] => 5432
)

It is notable that in the second case (which should be the postgres-database configured via the CLI arguments), the host, dbname and port in the top-level array are set correctly from the CLI, Both the primary and the replica fields and even some top-level fields obviously use the DB-configs from config.php

from server.

joshtrichards avatar joshtrichards commented on July 20, 2024

Possibly related: #45097

I don't have time to look tonight, but your analysis seems sound (and, given the added evidence from the log output, even more so).

Cc: @juliushaertl

from server.

intersectRaven avatar intersectRaven commented on July 20, 2024

I can verify but can't contribute logs. I used the --clear-schema option in my attempt and my original MariaDB DB got deleted. Good thing I have backups.

from server.

Delagen avatar Delagen commented on July 20, 2024

I modified https://github.com/nextcloud/server/blob/master/core/Command/Db/ConvertType.php#L247
to

$connectionParams = $this->connectionFactory->getDefaultConnectionParams($type);

and seems all converted

Also have to remove mysql.utf8mb4 parameter from config.php to perform conversion to remove client_encoding from params of DbFactory

from server.

HammyHavoc avatar HammyHavoc commented on July 20, 2024

Got hit by this a week ago. Is that particular Nextcloud instance completely screwed?

from server.

chimpboy avatar chimpboy commented on July 20, 2024

I have just experienced this problem on a new installation.

from server.

szaimen avatar szaimen commented on July 20, 2024

Hi, is this #45013 fixing the problem?

from server.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.