On running drush hostmaster-install --version=HEAD the installer fails a hostmaster install task after downloading required modules.

Created aegir database                                                                        [success]
WD php: Incorrect integer value: '' for column 'version_code' at row 1                               [error]
query: INSERT INTO hosting_package_instance (
      rid, package_id, filename,
      schema_version, version, version_code, status)
      VALUES (5, 4, '', 6055, 6.19, '', 0) in
/var/aegir/hostmaster-HEAD/profiles/hostmaster/modules/hosting/package/hosting_package.instance.inc
on line 86.
Incorrect integer value: '' for column 'version_code' at row 1                   [error]
query: INSERT INTO hosting_package_instance (
      rid, package_id, filename,
      schema_version, version, version_code, status)
      VALUES (5, 4, '', 6055, 6.19, '', 0) in
/var/aegir/hostmaster-HEAD/profiles/hostmaster/modules/hosting/package/hosting_package.instance.inc
on line 86.
An error occurred at function : drush_provision_drupal_provision_install_backend                     [error]
An error occurred at function : drush_provision_drupal_provision_install                             [error]
Could not find a Drupal settings.php file at ./sites/default/settings.php.                           [error]
An error occurred at function : drush_provision_drupal_provision_verify_validate                     [error]
An error occurred at function : drush_provision_hostmaster_install  

The schema specifies that hosting_package_instance.version_code is an integer, but attempts to insert a string, causing this issue. Changing the placeholder in the query from '%s' to %d should fix it.

A patch is available at https://github.com/cafuego/hostmaster/commit/818558fc9ffa1553bb9badc85e8...

CommentFileSizeAuthor
#7 my.cnf_.txt5.63 KBcafuego

Comments

omega8cc’s picture

This is interesting. I'm using MariaDB since January 2010 and never experienced any issues.

What is your MariaDB version and on what OS?

cafuego’s picture

Note that I only mention maria because I haven't tried this on MySQL. I assume that would fail too because the placeholder and column type still won't match.

I'm on Ubuntu 10.04.1 LTS with MariaDB 5.1.49-mariadb82 from the OurDelta repositories, as built by the MariaDB team.

omega8cc’s picture

I'm using the same version of MariaDB on Debian Lenny, and I don't experience those issues at all. I assume you are using some custom settings in your MariaDB configuration. In my case I had to comment out only one line in the vanilla config:

sql_mode = NO_ENGINE_SUBSTITUTION,TRADITIONAL

But the rest just works.

cafuego’s picture

I have tuned the innodb settings, as the defaults are crap.

However, that's not the issue. The issue is the code saving a character ('') to an integer field.

omega8cc’s picture

Default settings always needs to be tuned, but it is interesting that I'm using MariaDB on Lenny and tried it many times on Lucid with Aegir, and never had that problem (or at least, it never caused failed install). Could you share your MariaDB settings?

cafuego’s picture

Actually, to be more precise, the TRADITIONAL keyword disallows saving of a character value into an integer field. Disabling it would resolve the issue, but I still think that if you want to store a character in the database, make the column be a varchar and not an integer or cast the char to an int in the code:

db_query("INSERT INTO {hosting_package_instance} (
      rid, package_id, filename,
      schema_version, version, version_code, status)
      VALUES (%d, %d, '%s', %d, %f, '%s', %d)",
      $instance->rid, $instance->package_id, $instance->filename,
      $instance->schema_version, $instance->version, (int) $instance->version_code, $instance->status);

MySQL might accept it in some configurations, but other DBs are unlikely to.

If you re-enable the sql_mode setting, your setup will likely fail too.

cafuego’s picture

StatusFileSize
new5.63 KB

fwiw, my my.conf is attached.

omega8cc’s picture

Ah, the TRADITIONAL keyword turned off may be the reason it works for me. If I remember correctly, I had to disable it not because of Hostmaster, but because of some other Drupal sites previously running on MySQL, so I suspect using this strict behavior can lead to problems not just with Hostmaster. However I agree this is a bug.

Anonymous’s picture

Status: Active » Fixed

Makes sense, thanks for finding it. Yeah it seems MySQL ignored this, i install several times a day and never saw it.

cafuego’s picture

Lovely, installation now completes :-)

Anonymous’s picture

Status: Fixed » Needs work

Reopening this as apparently this was by design for some reason I don't understand. Saw it in IRC backlog mentioned by Adrian, maybe he can suggest the approach here.

cafuego’s picture

Hmm, I've successfully used a float cast on 32bit PHP to deal with very large integers (lots of bits in 4 gigagbytes) where someone was still using a 32bit Linux install for hysterical raisins- casting worked fine in that case.

Rather than reverting to '%s' and breaking my install again, should the code have a %f placeholder, a float field in the database (as opposed to an integer field) and a (float) $instance->version_code cast in PHP?

Disclaimer: I've not yet looked at the code that sets up the version_code variable.

Anonymous’s picture

Status: Needs work » Fixed

Oh, we fixed this (properly) in the end.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.