Page MenuHomePhabricator

AphrontSchemaQueryException #1054: Unknown column 'task.spacePHID' in 'where clause'
Closed, ResolvedPublic

Description

I recently tried to move my phabricator server to a new server. After I restored the sql dump and logged in with my username and password, I encountered the following message error:

AphrontSchemaQueryException
#1054: Unknown column 'task.spacePHID' in 'where clause'

Proof:

pasted_file (104×784 px, 9 KB)

How can I fix this problem? Here are things I have done:

I thought there were probably changes to the table schema. I previously ran ./bin/storage upgrade already but I did it again to make sure, then I encountered this problem. This probably indicates that I cannot upgrade twice.

> ./bin/storage upgrade --force
Applying patch 'phabricator:20150312.filechunk.1.sql'...
[2015-11-02 05:38:14] EXCEPTION: (AphrontQueryException) #1050: Table 'file_chunk' already exists at [<phutil>/src/aphront/storage/connection/mysql/AphrontBaseMySQLDatabaseConnection.php:311]
arcanist(head=master, ref.master=baf5eb8a8795), phabricator(head=master, ref.master=b7a4d3b9a51c), phutil(head=master, ref.master=59f5a8d2bb82)
  #0 AphrontBaseMySQLDatabaseConnection::throwQueryCodeException(integer, string) called at [<phutil>/src/aphront/storage/connection/mysql/AphrontBaseMySQLDatabaseConnection.php:275]
  #1 AphrontBaseMySQLDatabaseConnection::throwQueryException(mysqli) called at [<phutil>/src/aphront/storage/connection/mysql/AphrontBaseMySQLDatabaseConnection.php:181]
  #2 AphrontBaseMySQLDatabaseConnection::executeRawQuery(string) called at [<phutil>/src/xsprintf/queryfx.php:6]
  #3 queryfx(AphrontMySQLiDatabaseConnection, string, string) called at [<phabricator>/src/infrastructure/storage/management/PhabricatorStorageManagementAPI.php:252]
  #4 PhabricatorStorageManagementAPI::applyPatchSQL(string) called at [<phabricator>/src/infrastructure/storage/management/PhabricatorStorageManagementAPI.php:220]
  #5 PhabricatorStorageManagementAPI::applyPatch(PhabricatorStoragePatch) called at [<phabricator>/src/infrastructure/storage/management/workflow/PhabricatorStorageManagementUpgradeWorkflow.php:192]
  #6 PhabricatorStorageManagementUpgradeWorkflow::execute(PhutilArgumentParser) called at [<phutil>/src/parser/argument/PhutilArgumentParser.php:406]
  #7 PhutilArgumentParser::parseWorkflowsFull(array) called at [<phutil>/src/parser/argument/PhutilArgumentParser.php:301]
  #8 PhutilArgumentParser::parseWorkflows(array) called at [<phabricator>/scripts/sql/manage_storage.php:176]

I checked the integrity of the backup by going to the mysql prompt and checking if the user table was good. The result is positive:

mysql> select id, phid, userName from user limit 3;
+----+--------------------------------+-----------+
| id | phid                           | userName  |
+----+--------------------------------+-----------+
|  1 | PHID-USER-tik7zqm4tjgycrkzocm2 | admin     |
|  2 | PHID-USER-2bzm2mw24qqnyxxwk63f | yuanjian  |
|  4 | PHID-USER-lkcocaf5pmby4xpfqqpa | heqinghua |
+----+--------------------------------+-----------+
3 rows in set (0.00 sec)

Event Timeline

foresightyj assigned this task to epriestley.
foresightyj removed epriestley as the assignee of this task.
foresightyj updated the task description. (Show Details)
foresightyj added a project: Aphront.
foresightyj added a subscriber: foresightyj.

Can you walk me through what commands you used to do your dump/restore? I can't reproduce this problem, and we routinely dump and restore instances in the Phacility cluster.

The backup command is:

/bin/storage dump | gzip > backup_2015_10_26.sql.gz

The backup was done in the old phabricator installation which I haven't updated for quite a while. The last git commit in this installation is:

foresightyj@phabricatorvb:~/phabricator$ git log -2
commit 6d5aec86181c28bcd29cfa7e70a11a5b77cb69ac
Author: epriestley <git@epriestley.com>
Date:   Fri Feb 13 11:00:41 2015 -0800

The restore command is:

gunzip -c backup.sql.gz | mysql --user root --password

It was done in the most recent installation.

In Upgrading Phabricator, it is mentioned that:

We recommend installs upgrade regularly (every 1-2 weeks). Upgrades usually go smoothly and complete in a few minutes. If you put off upgrades for a long time, it may take a lot more work to bring things up to date if you want access to a useful new feature or an important security change.

Could that be the reason? Are there any incompatible schema changes between the two commits?

I realized what I had done wrong, after replying to you.

Now the problem is solved, in the following steps:

  1. I upgraded the old installation to the latest git commit, via the update_phabricator.sh script. The script ran dozens of mysql patch scripts which will update the mysql schema to the latest version. This is the step I forgot to do, which result in a mysql backup with the old schema, which can't be directly used by the latest installation.
  2. Backup the mysql data in the old server.
  3. Restore the backup in the new server.

Thanks for your attention.

chad claimed this task.
chad added a subscriber: chad.

Great!