Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

beta.3 fails db update on particular server #1362

Closed
narration-sd opened this issue Feb 7, 2017 · 8 comments
Closed

beta.3 fails db update on particular server #1362

narration-sd opened this issue Feb 7, 2017 · 8 comments

Comments

@narration-sd
Copy link
Contributor

narration-sd commented Feb 7, 2017

Description

Couldn’t backup the database. How would you like to proceed? --- nice and appreciated message here
Occurs on DO/Docker droplet, while update works fine on Vagrant vm

Steps to reproduce

  1. compose update to get vendor sources up-to-date with beta.3
  2. rsync the full site up to replace working beta.2 site
  3. use admin introducer to reach database update dialog
  4. fails with message above

Additional info

  • phperrors.log has
    PHP Notice: Trying to get property of non-object in /usr/share/nginx/mdo/vendor/craftcms/cms/src/web/View.php on line 514

  • folder perms look right, made 777 to check

  • considering that php line source, there are sites; order 1 in craft_sites is en-US, worked before, including original beta to beta.2

  • web.log has:
    2017-02-07 13:14:30 [63.143.42.243][-][ratr26ddernj2ukt7ngup2k6j5][profile end][yii\db\Command::query] SELECT * FROM craft_info
    2017-02-07 13:14:30 [63.143.42.243][-][ratr26ddernj2ukt7ngup2k6j5][error][yii\web\HttpException:503] craft\web\ServiceUnavailableHttpException in /usr/share/nginx/mdo/vendor/craftcms/cms/src/web/Application.php:588
    Stack trace:
    #0 /usr/share/nginx/mdo/vendor/craftcms/cms/src/web/Application.php(159): craft\web\Application->_processUpdateLogic(Object(craft\web\Request))
    Switching a field type from Checkbox to Lightswitch causes MySQL error about data truncation #1 /usr/share/nginx/mdo/vendor/yiisoft/yii2/base/Application.php(380): craft\web\Application->handleRequest(Object(craft\web\Request))
    Validation isn't performed when enabling entries from entry index page. #2 /usr/share/nginx/mdo/public/index.php(10): yii\base\Application->run()
    Make Matrix fields more scalable in the CP #3 {main}
    2017-02-07 13:14:30 [63.143.42.243][-][ratr26ddernj2ukt7ngup2k6j5][profile begin][craft\web\View::renderTemplate] 503
    2017-02-07 13:14:30 [63.143.42.243][-][ratr26ddernj2ukt7ngup2k6j5][profile begin][craft\web\twig\Template::display] 503
    2017-02-07 13:14:30 [63.143.42.243][-][ratr26ddernj2ukt7ngup2k6j5][profile begin][craft\web\twig\Template::display] _layouts/message
    2017-02-07 13:14:30 [63.143.42.243][-][ratr26ddernj2ukt7ngup2k6j5][profile begin][craft\web\twig\Template::display] _layouts/base

  • Craft version: currently beta.2

  • PHP version: 7.0.12, as worked with beta.2

  • Database driver & version: mysql

  • Plugins & versions: couple of simple local Twig extension plugins; work fine in beta.2

@brandonkelly
Copy link
Member

This happens if mysqldump (or pg_dump if using PostgreSQL) isn’t available, which Craft 3 relies on for creating DB backups.

If it can’t be added, then you can open up config/general.php and add this:

'backupCommand' => false,

@narration-sd
Copy link
Contributor Author

narration-sd commented Feb 7, 2017 via email

@angrybrad
Copy link
Member

angrybrad commented Feb 7, 2017

And because it isn't documented yet, here's the full docblock for that config setting:

/**
 * Craft will use the command line libraries `pg_dump` and `mysqldump` for backing up a database
 * by default.  It assumes that those libraries are in the $PATH variable for the user the web server is
 * running as.
 *
 * If you want to use some other library, or want to specify an absolute path to them,
 * or want to specify different parameters than the default, or you want to implement some other backup
 * solution, you can override that behavior here.
 *
 * There are several tokens you can use that Craft will swap out at runtime:
 *
 *     * `{path}` - Swapped with the dynamically generated backup file path.
 *     * `{port}` - Swapped with the current database port.
 *     * `{server}` - Swapped with the current database host name.
 *     * `{user}` - Swapped with the user to connect to the database.
 *     * `{database}` - Swapped with the current database name.
 *     * `{schema}` - Swapped with the current database schema (if any).
 *
 * This can also be set to `false` to disable database backups completely.
 */

@narration-sd
Copy link
Contributor Author

great stuff, thanks, Brad.

Not sure why this wasn't clear in the logs anyway as a cause, just a seeming blind web app fail?

But when you get to it, among the thousands...or if I missed the requisite line...

C.

@narration-sd
Copy link
Contributor Author

Ok, turned out this just needed adding mariadb-client package to the php-fpm container docker-compose file - built and up in seconds, and immediately worked with the update database dump.

The update itself killed my plugins, some triviata there no doubt also easy to find.

I do have one question, though -- couldn't work out how you get the database user/password added into the sqldump command, which is missing this as it's built.

Closed this was already by Brandon, so I'll email this query, as don't think you'll see it.

@narration-sd
Copy link
Contributor Author

...and the plugins problem was due to the Windows junction => link in vendor being replicated exactly as a soft link from the dev machine, which isn't correct.

What's needed is an rsync -L, which translates to an ansible synchronize copy_links: yes

All done, beta 3 on a Dockered DO droplet as well.

@angrybrad
Copy link
Member

@narration-sd if you leave the backupCommand set to null (default behavior), then you can see the default parameters Craft will pass into mysqldump here: https://github.com/craftcms/cms/blob/develop/src/db/mysql/Schema.php#L138

Credential are passed in through --defaults-extra-file, which creates a tmp file using the credentials you supplied to Craft to connect to the database.

@narration-sd
Copy link
Contributor Author

Ah, slipped over that first parameter when looked at it -- eyes too quick. Makes sense and closure.

Thanks, Brad, as ever, and great to know you look at comments after issue closed -- seems most close out even their notification. But this is P&T...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants