Reviewboard 2.0: rb-site upgrade failed migrating from 1.5.

617 views
Skip to first unread message

Paul Fee

unread,
Apr 18, 2014, 7:54:45 AM4/18/14
to revie...@googlegroups.com
Hi all,

I was testing migration from a 1.5 system to 2.0RC2.

I took a mysql dump from the old system and copied it to the new system.  Following an "rb-site install" on the new system, I dropped and recreated the reviewboard database, then tried "rb-site upgrade <path>".

This procedure worked on CentOS6/EPEL/ReviewBoard 1.7.22, however with Fedora rawhide/COPR/Reviewboard 2.0RC2, I get this error:

$ sudo rb-site upgrade /var/www/reviewboard
Traceback (most recent call last):
  File "/bin/rb-site", line 9, in <module>
    load_entry_point('ReviewBoard==2.0rc2', 'console_scripts', 'rb-site')()
  File "/usr/lib/python2.7/site-packages/reviewboard/cmdline/rbsite.py", line 1727, in main
    command.run()
  File "/usr/lib/python2.7/site-packages/reviewboard/cmdline/rbsite.py", line 1530, in run
    diff_dedup_needed = site.get_diff_dedup_needed()
  File "/usr/lib/python2.7/site-packages/reviewboard/cmdline/rbsite.py", line 443, in get_diff_dedup_needed
    return FileDiff.objects.unmigrated().count() > 0
  File "/usr/lib/python2.7/site-packages/django/db/models/query.py", line 291, in count
    return self.query.get_count(using=self.db)
  File "/usr/lib/python2.7/site-packages/django/db/models/sql/query.py", line 390, in get_count
    number = obj.get_aggregation(using=using)[None]
  File "/usr/lib/python2.7/site-packages/django/db/models/sql/query.py", line 356, in get_aggregation
    result = query.get_compiler(using).execute_sql(SINGLE)
  File "/usr/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 782, in execute_sql
    cursor.execute(sql, params)
  File "/usr/lib/python2.7/site-packages/django/db/backends/util.py", line 53, in execute
    return self.cursor.execute(sql, params)
  File "/usr/lib/python2.7/site-packages/django/db/utils.py", line 99, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/usr/lib/python2.7/site-packages/django/db/backends/util.py", line 53, in execute
    return self.cursor.execute(sql, params)
  File "/usr/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 124, in execute
    return self.cursor.execute(query, args)
  File "/usr/lib64/python2.7/site-packages/MySQLdb/cursors.py", line 174, in execute
    self.errorhandler(self, exc, value)
  File "/usr/lib64/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
    raise errorclass, errorvalue
django.db.utils.OperationalError: (1054, "Unknown column 'diffviewer_filediff.diff_hash_id' in 'where clause'")

Since this worked with reviewboard 1.7, I presume this is a bug in 2.0.  Would you like more data to help diagnose the issue?

Thanks,
Paul

Christian Hammond

unread,
Apr 18, 2014, 3:00:24 PM4/18/14
to revie...@googlegroups.com
Hi Paul,

rb-site upgrade isn't meant to be used on a completely empty database. It expects an existing install, so when you dropped and recreated the database, it was unable to find the state it needs to perform an actual upgrade.

If you need to just start fresh from a database, you can re-run install, or:

    $ rb-site manage /path/to/site syncdb

That should generate a fresh new database (if there isn't already any schema).

Christian

--
Christian Hammond - chi...@chipx86.com
Review Board - http://www.reviewboard.org
Beanbag, Inc. - http://www.beanbaginc.com


--
Get the Review Board Power Pack at http://www.reviewboard.org/powerpack/
---
Sign up for Review Board hosting at RBCommons: https://rbcommons.com/
---
Happy user? Let us know at http://www.reviewboard.org/users/
---
You received this message because you are subscribed to the Google Groups "reviewboard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to reviewboard...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Paul Fee

unread,
Apr 30, 2014, 7:30:30 AM4/30/14
to revie...@googlegroups.com
Hi Chris,

I repeated the test to ensure the database wasn't empty.  I confirmed that I'd imported the RB1.5 database, ready for "rb-site upgrade".

Steps:
# rb-site install /var/www/reviewboard
mysql> drop database reviewboard;
mysql> create database reviewboard;
# mysql -uroot -p reviewboard < ~/reviewboard.mysql.dump           <= Note reviewboard database is no longer empty, it contains content from RB1.5 from a separate machine.
# rb-site upgrade /var/www/reviewboard


Result: Same failure as previously posted.

django.db.utils.OperationalError: (1054, "Unknown column 'diffviewer_filediff.diff_hash_id' in 'where clause'")

This migration procedure works on Centos6.5 with RB1.7.22, but failed on Fedora rawhide with RB2.0RC2 (from Stephen Gallagher's COPR repo).

Is there more info I can collect to help debug?  How far back does RB2.0 support an upgrade from?  Should I upgrade via an intermediate version?

Thanks,
Paul


You received this message because you are subscribed to a topic in the Google Groups "reviewboard" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/reviewboard/4gNGVu3Gveg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to reviewboard...@googlegroups.com.

Alexander Zhogov

unread,
Apr 30, 2014, 8:35:14 AM4/30/14
to revie...@googlegroups.com, chi...@chipx86.com
Hi Christian,

I faced the same exception with a similar scenario. The "rb-site manage /path/to/site syncdb" command doesn't help.
I am testing migration from the old system with Review Board 1.5 to a new CentOS 6.5 with Review Board 2.0 RC2:
1. Installed Review Board 2.0 RC2 on CentOS 6.5.
2. Restored mysql dump from the old system.
3. Run "rb-site upgrade </path/to/site>".

Could you please help us to resolve the issue with migration?

Christian Hammond

unread,
Apr 30, 2014, 2:45:31 PM4/30/14
to Alexander Zhogov, revie...@googlegroups.com
I'll look into this today.

We decided to do at least one more RC, which will be soon, so I'll have something you guys can test before a final 2.0 is out.

Christian
--

Stephen Gallagher

unread,
Apr 30, 2014, 3:26:34 PM4/30/14
to revie...@googlegroups.com
For what it's worth, I tested a migration on Monday as follows:

1) Took a 'dumpdb' of a 1.7.25 server.
2) Installed a new 1.7.25 site on a new server
3) Imported the DB of the original
4) Tweaked the DB contents to point to the new path on disk (Relic of
OpenShift, didn't have exactly the same location)
5) Upgraded to 2.0 RC2 with easy_install
6) Ran rb-site upgrade

It worked cleanly for me.



I haven't tested trying to load the 1.7.25 DB directly into the 2.0
install, but this path worked.

Bruce Cran

unread,
Apr 30, 2014, 3:53:50 PM4/30/14
to revie...@googlegroups.com
When I upgraded from 1.7.9 to 2.0 RC2 I had to go via 1.7.24 otherwise I got an 'Unknown column' error (I can't remember if it was the same one).

--
Bruce

Christian Hammond

unread,
Apr 30, 2014, 5:01:51 PM4/30/14
to revie...@googlegroups.com
Hi guys,

I committed a fix for this. It's pretty trivial to hand-apply. Not at the computer or I'd send a link.

This will be in RC3.

Christian
--
Get the Review Board Power Pack at http://www.reviewboard.org/powerpack/
---
Sign up for Review Board hosting at RBCommons: https://rbcommons.com/
---
Happy user? Let us know at http://www.reviewboard.org/users/
---
You received this message because you are subscribed to the Google Groups "reviewboard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to reviewboard...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--

Paul Fee

unread,
May 1, 2014, 8:00:07 AM5/1/14
to revie...@googlegroups.com, chi...@chipx86.com
Hi Christian,

I found your fix on github and manually applied the change to rbsite.py

https://github.com/reviewboard/reviewboard/commit/11a850ca279416feed96beae9efd6c4c1f188f15

Repeating the procedure allows "rb-site upgrade" to get past the previous error:

django.db.utils.OperationalError: (1054, "Unknown column 'diffviewer_filediff.diff_hash_id' in 'where clause'")

However, I see new errors now:
=====================================

$ sudo rb-site upgrade /var/www/reviewboard
Rebuilding directory structure
Updating database. This may take a while.

The log output below, including warnings and errors,
can be ignored unless upgrade fails.

------------------ <begin log output> ------------------
Creating tables ...
Creating table extensions_registeredextension
Creating table attachments_fileattachment

[!] There was an error synchronizing the database. Make sure the
    database is created and has the appropriate permissions, and then
    continue.
[!] Details: (1005, 'Can\'t create table `reviewboard`.`#sql-605_11`
    (errno: 150 "Foreign key constraint is incorrectly formed")')

Press Enter to continue
======================================

Pressing enter a few times gives the same error for the following tables:
* site_localsite_users
* site_localsite_admins
* accounts_localsiteprofile

After that rb-site continues and finally exits with this error output:
=====================
Installing custom SQL ...
Installing indexes ...
Installed 0 object(s) from 0 fixture(s)
Registering new SCM Tool Plastic SCM (reviewboard.scmtools.plastic.PlasticTool) in database
ERROR:root:Unexpected error: 'NoneType' object is not iterable

Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/django_evolution/management/commands/evolve.py", line 65, in handle
    self.evolve(*app_labels, **options)
  File "/usr/lib/python2.7/site-packages/django_evolution/management/commands/evolve.py", line 125, in evolve
    sql.extend(self.evolve_app(app))
  File "/usr/lib/python2.7/site-packages/django_evolution/management/commands/evolve.py", line 165, in evolve_app
    app_mutator_sql = app_mutator.to_sql()
  File "/usr/lib/python2.7/site-packages/django_evolution/mutators.py", line 303, in to_sql
    sql.extend(mutator.to_sql())
  File "/usr/lib/python2.7/site-packages/django_evolution/mutators.py", line 186, in to_sql
    return self.evolver.generate_table_ops_sql(self, self._ops)
  File "/usr/lib/python2.7/site-packages/django_evolution/db/common.py", line 42, in generate_table_ops_sql
    prev_sql_result, prev_op)
  File "/usr/lib/python2.7/site-packages/django_evolution/db/common.py", line 92, in generate_table_op_sql
    sql_result.add(op['sql'])
  File "/usr/lib/python2.7/site-packages/django_evolution/db/sql_result.py", line 105, in add
    super(AlterTableSQLResult, self).add(sql_result)
  File "/usr/lib/python2.7/site-packages/django_evolution/db/sql_result.py", line 30, in add
    self.sql += sql_or_result
TypeError: 'NoneType' object is not iterable

Traceback (most recent call last):
  File "/bin/rb-site", line 9, in <module>
    load_entry_point('ReviewBoard==2.0rc2', 'console_scripts', 'rb-site')()
  File "/usr/lib/python2.7/site-packages/reviewboard/cmdline/rbsite.py", line 1733, in main
    command.run()
  File "/usr/lib/python2.7/site-packages/reviewboard/cmdline/rbsite.py", line 1556, in run
    site.migrate_database()
  File "/usr/lib/python2.7/site-packages/reviewboard/cmdline/rbsite.py", line 425, in migrate_database
    self.run_manage_command("evolve", ["--noinput", "--execute"])
  File "/usr/lib/python2.7/site-packages/reviewboard/cmdline/rbsite.py", line 626, in run_manage_command
    execute_from_command_line([__file__, cmd] + params)
  File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
    utility.execute()
  File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/lib/python2.7/site-packages/django/core/management/base.py", line 242, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/usr/lib/python2.7/site-packages/django/core/management/base.py", line 285, in execute
    output = self.handle(*args, **options)
  File "/usr/lib/python2.7/site-packages/django_evolution/management/commands/evolve.py", line 65, in handle
    self.evolve(*app_labels, **options)
  File "/usr/lib/python2.7/site-packages/django_evolution/management/commands/evolve.py", line 125, in evolve
    sql.extend(self.evolve_app(app))
  File "/usr/lib/python2.7/site-packages/django_evolution/management/commands/evolve.py", line 165, in evolve_app
    app_mutator_sql = app_mutator.to_sql()
  File "/usr/lib/python2.7/site-packages/django_evolution/mutators.py", line 303, in to_sql
    sql.extend(mutator.to_sql())
  File "/usr/lib/python2.7/site-packages/django_evolution/mutators.py", line 186, in to_sql
    return self.evolver.generate_table_ops_sql(self, self._ops)
  File "/usr/lib/python2.7/site-packages/django_evolution/db/common.py", line 42, in generate_table_ops_sql
    prev_sql_result, prev_op)
  File "/usr/lib/python2.7/site-packages/django_evolution/db/common.py", line 92, in generate_table_op_sql
    sql_result.add(op['sql'])
  File "/usr/lib/python2.7/site-packages/django_evolution/db/sql_result.py", line 105, in add
    super(AlterTableSQLResult, self).add(sql_result)
  File "/usr/lib/python2.7/site-packages/django_evolution/db/sql_result.py", line 30, in add
    self.sql += sql_or_result
TypeError: 'NoneType' object is not iterable
=======================

On your code review, you say you tested RB1.5 and RB1.6 upgrades to RB2.0 and they passed.  Can I collect more information for you to identify why this RB1.5 to 2.0 migration failed?
https://reviews.reviewboard.org/r/5756/

Thanks,
Paul

Christian Hammond

unread,
May 1, 2014, 2:01:53 PM5/1/14
to revie...@googlegroups.com
Hi Paul,

Your database is using MyISAM while MySQL is configuring new databases to use InnoDB. You'll need to edit your database dump to set all table types to InnoDB and re-import/upgrade.

This is a more general MySQL issue, and not one we really have control over during upgrade.

Christian
--
Get the Review Board Power Pack at http://www.reviewboard.org/powerpack/
---
Sign up for Review Board hosting at RBCommons: https://rbcommons.com/
---
Happy user? Let us know at http://www.reviewboard.org/users/
---
You received this message because you are subscribed to the Google Groups "reviewboard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to reviewboard...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Paul Fee

unread,
May 2, 2014, 6:50:30 AM5/2/14
to revie...@googlegroups.com
Hi Chris,

I replaced ") ENGINE=MyISAM" with ") ENGINE=InnoDB" in my database dump and repeated the import.  This fixed the "Foreign key constraint is incorrectly formed" errors.

Thanks for that tip, mysql table types may be outside the scope of "rb-site upgrade", however if the upgrade could recognise this error and give an informative error message it may help others with future migrations, allowing them to fix the error themselves.

The upgrade now proceeds past the "Creating table X" section, but I still get "'NoneType' object is not iterable" errors:
Can you help with this problem?

Thanks,
Paul


You received this message because you are subscribed to a topic in the Google Groups "reviewboard" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/reviewboard/4gNGVu3Gveg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to reviewboard...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages