Migrating to newer HUE version

Hi all,

Usually we didn’t have any problems with this. However, we tried updating one entity with Hue 4.2 or 4.3 database to 4.6 by doing the following:

  1. fresh HUE 4.6 make install
  2. Updating configs in hue.ini.
  3. sudo -u hue /usr/local/hue/build/env/bin/hue syncdb --noinput
    Result: No changes detected
  4. sudo -u hue /usr/local/hue/build/env/bin/hue migrate
    Resulting in the following error:

Operations to perform:
Synchronize unmigrated apps: about, babeldjango, dashboard, django_extensions, django_prometheus, filebrowser, help, hive, indexer, jobbrowser, kafka, metadata, metastore, proxy, rdbms, staticfiles, webpack_loader, zookeeper
Apply all migrations: admin, auth, axes, beeswax, contenttypes, desktop, jobsub, oozie, pig, search, sessions, sites, useradmin
Synchronizing apps without migrations:
Creating tables…
Running deferred SQL…
Running migrations:
Applying contenttypes.0001_initial…Traceback (most recent call last):
File “/usr/local/hue/build/env/bin/hue”, line 11, in
load_entry_point(‘desktop’, ‘console_scripts’, ‘hue’)()
File “/usr/local/hue/desktop/core/src/desktop/manage_entry.py”, line 225, in entry
execute_from_command_line(sys.argv)
File “/usr/local/hue/build/env/lib/python2.7/site-packages/Django-1.11.22-py2.7.egg/django/core/management/init.py”, line 364, in execute_from_command_line
utility.execute()
File “/usr/local/hue/build/env/lib/python2.7/site-packages/Django-1.11.22-py2.7.egg/django/core/management/init.py”, line 356, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File “/usr/local/hue/build/env/lib/python2.7/site-packages/Django-1.11.22-py2.7.egg/django/core/management/base.py”, line 283, in run_from_argv
self.execute(*args, **cmd_options)
File “/usr/local/hue/build/env/lib/python2.7/site-packages/Django-1.11.22-py2.7.egg/django/core/management/base.py”, line 330, in execute
output = self.handle(*args, **options)
File “/usr/local/hue/build/env/lib/python2.7/site-packages/Django-1.11.22-py2.7.egg/django/core/management/commands/migrate.py”, line 204, in handle
fake_initial=fake_initial,
File “/usr/local/hue/build/env/lib/python2.7/site-packages/Django-1.11.22-py2.7.egg/django/db/migrations/executor.py”, line 115, in migrate
state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
File “/usr/local/hue/build/env/lib/python2.7/site-packages/Django-1.11.22-py2.7.egg/django/db/migrations/executor.py”, line 145, in _migrate_all_forwards
state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
File “/usr/local/hue/build/env/lib/python2.7/site-packages/Django-1.11.22-py2.7.egg/django/db/migrations/executor.py”, line 244, in apply_migration
state = migration.apply(state, schema_editor)
File “/usr/local/hue/build/env/lib/python2.7/site-packages/Django-1.11.22-py2.7.egg/django/db/migrations/migration.py”, line 129, in apply
operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
File “/usr/local/hue/build/env/lib/python2.7/site-packages/Django-1.11.22-py2.7.egg/django/db/migrations/operations/models.py”, line 97, in database_forwards
schema_editor.create_model(model)
File “/usr/local/hue/build/env/lib/python2.7/site-packages/Django-1.11.22-py2.7.egg/django/db/backends/base/schema.py”, line 319, in create_model
self.execute(sql, params or None)
File “/usr/local/hue/build/env/lib/python2.7/site-packages/Django-1.11.22-py2.7.egg/django/db/backends/base/schema.py”, line 136, in execute
cursor.execute(sql, params)
File “/usr/local/hue/build/env/lib/python2.7/site-packages/Django-1.11.22-py2.7.egg/django/db/backends/utils.py”, line 64, in execute
return self.cursor.execute(sql, params)
File “/usr/local/hue/build/env/lib/python2.7/site-packages/Django-1.11.22-py2.7.egg/django/db/utils.py”, line 94, in exit
six.reraise(dj_exc_type, dj_exc_value, traceback)
File “/usr/local/hue/build/env/lib/python2.7/site-packages/Django-1.11.22-py2.7.egg/django/db/backends/utils.py”, line 62, in execute
return self.cursor.execute(sql)
django.db.utils.ProgrammingError: relation “django_content_type” already exists

However, running a query in HUE UI warns about missing tables in the database:

How should we proceed with the migration? Is there any way of skipping/overriding the “already exists” issue?

Thanks!

I will add that /usr/local/hue/build/env/bin/hue migrate --fake-initial seems to skip the previous errors, but arrives at:

Operations to perform:
Apply all migrations: admin, auth, axes, beeswax, contenttypes, desktop, jobsub, oozie, pig, search, sessions, sites, useradmin
Running migrations:
Applying beeswax.0001_initial…Traceback (most recent call last):
File “/usr/local/hue/build/env/bin/hue”, line 11, in
load_entry_point(‘desktop’, ‘console_scripts’, ‘hue’)()
File “/usr/local/hue/desktop/core/src/desktop/manage_entry.py”, line 225, in entry
execute_from_command_line(sys.argv)
File “/usr/local/hue/build/env/lib/python2.7/site-packages/Django-1.11.22-py2.7.egg/django/core/management/init.py”, line 364, in execute_from_command_line
utility.execute()
File “/usr/local/hue/build/env/lib/python2.7/site-packages/Django-1.11.22-py2.7.egg/django/core/management/init.py”, line 356, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File “/usr/local/hue/build/env/lib/python2.7/site-packages/Django-1.11.22-py2.7.egg/django/core/management/base.py”, line 283, in run_from_argv
self.execute(*args, **cmd_options)
File “/usr/local/hue/build/env/lib/python2.7/site-packages/Django-1.11.22-py2.7.egg/django/core/management/base.py”, line 330, in execute
output = self.handle(*args, **options)
File “/usr/local/hue/build/env/lib/python2.7/site-packages/Django-1.11.22-py2.7.egg/django/core/management/commands/migrate.py”, line 204, in handle
fake_initial=fake_initial,
File “/usr/local/hue/build/env/lib/python2.7/site-packages/Django-1.11.22-py2.7.egg/django/db/migrations/executor.py”, line 115, in migrate
state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
File “/usr/local/hue/build/env/lib/python2.7/site-packages/Django-1.11.22-py2.7.egg/django/db/migrations/executor.py”, line 145, in _migrate_all_forwards
state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
File “/usr/local/hue/build/env/lib/python2.7/site-packages/Django-1.11.22-py2.7.egg/django/db/migrations/executor.py”, line 238, in apply_migration
applied, state = self.detect_soft_applied(state, migration)
File “/usr/local/hue/build/env/lib/python2.7/site-packages/Django-1.11.22-py2.7.egg/django/db/migrations/executor.py”, line 363, in detect_soft_applied
self.connection.introspection.get_table_description(self.connection.cursor(), table)
File “/usr/local/hue/build/env/lib/python2.7/site-packages/Django-1.11.22-py2.7.egg/django/db/backends/postgresql/introspection.py”, line 87, in get_table_description
)) for line in cursor.description
TypeError: sequence index must be integer, not ‘slice’

Reading about similar issues, it seems that psycopg2 package may be the culprit; however, these errors are still there with both psycopg2-2.8.4: and psycopg2-2.5.3 versions.

This is fishy though,

is old and should be registered as a “executed” migration in the Hue DB. Are you sure you are pointing to the same DB as before?

Maybe I’ve executed the migration incorrectly (1-4 steps)? I’m not familiar with django and other related frameworks, so may have missed some additional steps/settings?

The DB is correct, it’s iteratively updated since Hue 3, maybe that has to do something with it… A fresh setup would be interesting to try, but not yet sure how to properly migrate all the stored documents and queries from the old DB.


I’ve managed get away from the UI errors by --fake-initial and forcing through psycopg2 updates, but I’m not confident in this.

4.2 to 4.6 has not much special so this should work.

–fake–initial should not be needed as you have the first migrations already done a long time ago. Steps 1-4 looks good, juste “Synchronize unmigrated apps” should have only maybe desktop and 1 or 2 more as only those changed since 4.2.

You run with sudo -u, if you run something like

build/env/bin/hue config_dump

Does it feel like the configuration is good?