Uploaded image for project: 'eZ Publish / Platform'
  1. eZ Publish / Platform
  2. EZP-23268

Composer install fails in a cluster environment if we have a database in a different host

    Details

    • Type: Bug Bug
    • Status: InputQ
    • Priority: High High
    • Resolution: Unresolved
    • Affects Version/s: 5.4-dev, 5.4.9, 5.4.10-rc, 5.4.10
    • Fix Version/s: QA tracked issues
    • Labels:
      None
    • Environment:

      Operating System: Debian 7
      PHP Version: PHP 5.4.4-14+deb7u8
      Database and version: Mysql 5.5.35
      Cluster environment with 3 machines. Two with eZ Publish and one with the database.

      Description

      Hi,

      Having my eZ Publish installation in one machine (10.0.5.2) and my database in a different one (10.0.5.4), when doing the composer update i have the following error:

       [eZDBNoConnectionException]
        Unable to connect to the database server 'localhost'
        Error #2002: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
      

      Steps to Reproduce

      – Clone eZ Publish Platform or community
      $ git clone git@github.com:ezsystems/ezpublish-platform.git ezpublish5
      $ cd ezpublish5
      – Change your ezpublish_setup.yml, updating the following settings:

      doctrine:
          dbal:
              connections:
                  default:
                      driver: pdo_mysql
                      host: 10.0.5.4
                      user: ezp
                      password: myPassword
                      dbname: ezp
      

      – execute the composer install
      $ curl -sS https://getcomposer.org/installer | php
      $ php composer.phar install --prefer-dist

      The error appears during this last command.

      Workaround:

      What seems to be happening.
      When executing the composer install, the ezpublish_legacy folder is fetched. There, we have the default settings in site.ini

      [DatabaseSettings]
      DatabaseImplementation=ezmysqli
      Server=localhost
      Port=
      User=root
      Password=
      Database=nextgen
      

      If we change these site.ini settings to

      [DatabaseSettings]
      DatabaseImplementation=ezmysqli
      Server=10.0.5.4
      Port=
      User=ezp
      Password=myPassword
      Database=ezp
      

      and re-execute the composer install
      $ php composer.phar install --prefer-dist

      then the installation seems to be restarted where is stopped last time, and we can finish the installation
      But... it's not a nice thing to do.

        Issue Links

          Activity

          Hide
          Paulo Nunes (Inactive) added a comment -

          No longer happens when installing a 5.4 with db in different host)

          Show
          Paulo Nunes (Inactive) added a comment - No longer happens when installing a 5.4 with db in different host)
          Hide
          Eduardo Fernandes (Inactive) added a comment -

          Paulo Cardiga,

          This issue is not related to the database being in a different host, but if you have or not a mysql server running in your machine.
          That's because the installations tries to connect to the localhost socket and, if there isn't one, he fails with an error similar to

          Unable to connect to the database server 'localhost'
          Error #2002: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'

          You should be able to select your MySQL Server during the installation, so, if you have no socket in your machine, it should open the setup wizard without any fatal error.

          Note

          This will make the composer update fail as well, if you try to update eZP before the Setup wizard

          h6: Steps to reproduce

          • Install MySQL Server in your machine
          • Untar eZP 5.4
          • Open the Setup Wizard
          • The wizard will open just fine
          • Clear the caches if you need
          • Remove the MySQL Server or stop the service
          • Open the Setup Wizard
          • It will fail since it cannot find the socker
          Show
          Eduardo Fernandes (Inactive) added a comment - Paulo Cardiga , This issue is not related to the database being in a different host, but if you have or not a mysql server running in your machine. That's because the installations tries to connect to the localhost socket and, if there isn't one, he fails with an error similar to Unable to connect to the database server 'localhost' Error #2002: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' You should be able to select your MySQL Server during the installation, so, if you have no socket in your machine, it should open the setup wizard without any fatal error. Note This will make the composer update fail as well, if you try to update eZP before the Setup wizard h6: Steps to reproduce Install MySQL Server in your machine Untar eZP 5.4 Open the Setup Wizard The wizard will open just fine Clear the caches if you need Remove the MySQL Server or stop the service Open the Setup Wizard It will fail since it cannot find the socker
          Hide
          Eduardo Fernandes (Inactive) added a comment -

          A possible workaround is to set unix_socket as null in your ezpublish_setup.yml

          doctrine:
              dbal:
                  connections:
                      default:
                          driver: pdo_mysql
                          host: localhost
                          user: root
                          dbname: ezpublish
          +                unix_socket: null

          However, it's not that trivial for customers and users to realize that.

          Show
          Eduardo Fernandes (Inactive) added a comment - A possible workaround is to set unix_socket as null in your ezpublish_setup.yml doctrine: dbal: connections: default: driver: pdo_mysql host: localhost user: root dbname: ezpublish + unix_socket: null However, it's not that trivial for customers and users to realize that.
          Hide
          Eduardo Fernandes (Inactive) added a comment - - edited

          There's a problem with this workaround.

          After the installation, the ezpublish/config/ezpublish.yml will need to be manually edited and the unix_socket: null setting added to the default connection.

          Please notice that the default connection is configured and working with an external MySQL Server.
          Yet, it fail because of the missing local socket.

          Show
          Eduardo Fernandes (Inactive) added a comment - - edited There's a problem with this workaround. After the installation, the ezpublish/config/ezpublish.yml will need to be manually edited and the unix_socket: null setting added to the default connection. Please notice that the default connection is configured and working with an external MySQL Server. Yet, it fail because of the missing local socket.
          Hide
          André Rømcke added a comment -

          This is most likely similar to "SiteAccess hell" issue, where something triggers database load when it should not to early in the process (it's supposed to be lazy), before siteaccess is loaded.

          Way to observe it as Gunnstein Lye did recently on non relevant work in master (clusterize command), is that you'll get database connection error when running composer commands that triggers symfony load in it's composer post_[install/update]_cmd scripts. The error ouput he got can be seen here: https://github.com/ezsystems/ezpublish-kernel/pull/1972#issuecomment-299421354

          So if this is the case, you should be able to also reproduce this on single server setup where database is not/miss configured, running composer commands that should normally not require database connection.

          Show
          André Rømcke added a comment - This is most likely similar to "SiteAccess hell" issue, where something triggers database load when it should not to early in the process (it's supposed to be lazy), before siteaccess is loaded. Way to observe it as Gunnstein Lye did recently on non relevant work in master (clusterize command) , is that you'll get database connection error when running composer commands that triggers symfony load in it's composer post_ [install/update] _cmd scripts. The error ouput he got can be seen here: https://github.com/ezsystems/ezpublish-kernel/pull/1972#issuecomment-299421354 So if this is the case, you should be able to also reproduce this on single server setup where database is not/miss configured, running composer commands that should normally not require database connection.

            People

            • Assignee:
              Unassigned
              Reporter:
              Paulo Nunes (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated: