Yet another upgrade thread - I apologize…

Trying to upgrade my 0.12 instance on ubuntu. I wouldn’t mind going to 1.0.x first but couldn’t figure out a way to.

Anyway, I’m getting a connection to pgsql error running migrations.

My .env has this config:
REDASH_DATABASE_URL=“postgresql:///redash:pwd@192.168.8.10/redash012rc”

I have a named database (redash012rc), and user:pwd.
I can connect to the database from a remote client so I’m guessing db connectivity is ok.

Any clues? Putting the error bellow.

Thanks,
Duarte

Error:
arcims@vboxredash:~$ sudo ./redash_upgrade_10.py
Starting Redash upgrade:
Found version: 2.0.0
Current version: 0.12.0+b2093

Full CHANGELOG for this release: https://github.com/getredash/redash/blob/master/CHANGELOG.md#v200---2017-08-08
Continue with upgrade? (y/n): y
Downloading release tarball…
Unpacking to: redash.2.0.0.b2990…
Changing ownership to redash…
Linking .env file…
Installing new Python packages (if needed)…
Running migrations (if needed)…
Failed running: sudo -u redash bin/run ./manage.py db upgrade
Exit status: 1
Output:
Traceback (most recent call last):
File “/opt/redash/redash.2.0.0.b2990/manage.py”, line 9, in
manager()
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 716, in call
return self.main(*args, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/flask/cli.py”, line 345, in main
return AppGroup.main(self, *args, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 696, in main
rv = self.invoke(ctx)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 1060, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 1060, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 889, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 534, in invoke
return callback(*args, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/click/decorators.py”, line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/flask/cli.py”, line 229, in decorator
return __ctx.invoke(f, *args, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 534, in invoke
return callback(*args, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/flask_migrate/cli.py”, line 132, in upgrade
_upgrade(directory, revision, sql, tag, x_arg)
File “/usr/local/lib/python2.7/dist-packages/flask_migrate/init.py”, line 239, in upgrade
command.upgrade(config, revision, sql=sql, tag=tag)
File “/usr/local/lib/python2.7/dist-packages/alembic/command.py”, line 254, in upgrade
script.run_env()
File “/usr/local/lib/python2.7/dist-packages/alembic/script/base.py”, line 425, in run_env
util.load_python_file(self.dir, ‘env.py’)
File “/usr/local/lib/python2.7/dist-packages/alembic/util/pyfiles.py”, line 81, in load_python_file
module = load_module_py(module_id, path)
File “/usr/local/lib/python2.7/dist-packages/alembic/util/compat.py”, line 141, in load_module_py
mod = imp.load_source(module_id, path, fp)
File “migrations/env.py”, line 87, in
run_migrations_online()
File “migrations/env.py”, line 72, in run_migrations_online
connection = engine.connect()
File “/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py”, line 2082, in connect
return self._connection_cls(self, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py”, line 90, in init
if connection is not None else engine.raw_connection()
File “/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py”, line 2168, in raw_connection
self.pool.unique_connection, _connection)
File “/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py”, line 2142, in _wrap_pool_connect
e, dialect, self)
File “/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py”, line 1456, in _handle_dbapi_exception_noconnection
exc_info
File “/usr/local/lib/python2.7/dist-packages/sqlalchemy/util/compat.py”, line 202, in raise_from_cause
reraise(type(exception), exception, tb=exc_tb, cause=cause)
File “/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py”, line 2138, in _wrap_pool_connect
return fn()
File “/usr/local/lib/python2.7/dist-packages/sqlalchemy/pool.py”, line 328, in unique_connection
return _ConnectionFairy._checkout(self)
File “/usr/local/lib/python2.7/dist-packages/sqlalchemy/pool.py”, line 766, in _checkout
fairy = _ConnectionRecord.checkout(pool)
File “/usr/local/lib/python2.7/dist-packages/sqlalchemy/pool.py”, line 516, in checkout
rec = pool._do_get()
File “/usr/local/lib/python2.7/dist-packages/sqlalchemy/pool.py”, line 1229, in _do_get
return self._create_connection()
File “/usr/local/lib/python2.7/dist-packages/sqlalchemy/pool.py”, line 333, in _create_connection
return _ConnectionRecord(self)
File “/usr/local/lib/python2.7/dist-packages/sqlalchemy/pool.py”, line 461, in init
self.__connect(first_connect_check=True)
File “/usr/local/lib/python2.7/dist-packages/sqlalchemy/pool.py”, line 651, in __connect
connection = pool._invoke_creator(self)
File “/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/strategies.py”, line 105, in connect
return dialect.connect(*cargs, **cparams)
File “/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/default.py”, line 392, in connect
return self.dbapi.connect(*cargs, **cparams)
File “/usr/local/lib/python2.7/dist-packages/psycopg2/init.py”, line 164, in connect
conn = _connect(dsn, connection_factory=connection_factory, async=async)
sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket “/var/run/postgresql/.s.PGSQL.5432”?

uau… stupid… turns out I had 3 slashes in my pgsql url… wrong. It should be:

REDASH_DATABASE_URL=“postgresql://redash:pwd@192.168.8.10/redash012rc”

For anyone this blind to know.

Was about to suggest checking this… Did it solve your issue?

Having a look now. Something must have gone wrong. I got the upgrade to succeed without errors, but all queries disappeared. When querying redash metada queries table I got:

Error running query: (psycopg2.ProgrammingError) column queries.version does not exist LINE 1: … AS queries_created_at, queries.id AS queries_id, queries.ve… ^

Strange… it’s a vm I can rollback and try again…

Seems like one (or more) of the migrations wasn’t applied.

Can you think of a fast way to go to 1.0.x first?

Turns out it’s easy. Edit script upgrade, function get_release, just change this line from:
release = response.json()[0]

To
release = response.json()[2]

This will get v 1.0.1
Releases are:
0 = 2.0
1 = 1.0.3
2 = 1.0.1
etc.

I upgraded to 1.0.1 and got the same vanishing queries problem…

So I noticed my version is 0.12.0+b2093.

Not 0.12.0.b2449…

Help…

Looking at b2449 migrations I can see some I didn’t have.

How can I run migrations on 0.12? manage.py db does not exist yet…

When we upgraded to 2.0 which it looks like you are doing. We had to upgrade our Python packages as well. Also, we ended up blowing away our existing data connections and recreating them to Big Query. Then in Redash we had to touch all our queries to point to the newly creation BQ connection. Not sure if that is your issue here, but hopefully it helps.

@edowdy thanks but my problem seems to be missing columns, possibly I don’t have the final 0.12 db model.

@arikfr I tried running all migrations on 0.12 b2449 using the pre-1.0 command:
sudo -u redash PYTHONPATH=. bin/run python migrations/.py

But that got me a 500 error, regarding a template not found (index.html)…

I think I’ll have to install a fresh 0.12b2449 and manually retro fit the db model to my 0.12b2093. Then try to upgrade again.

Thanks.

Hmm… no differences in db between 0.12.0b2093 and 0.12.0b2449…

Last chance… try to upgrade to v2.0 and manually apply diff from 0.12 to 2.0 and see if it runs.

Are you running the migrations with a 0.12 codebase or from the v1/v2 codebase?

You should run them with a 0.12 codebase. Just fetch the tarball of the 0.12 version and run it from that directory. You better do this before upgrading the Python packages.

Yes I think I already did that. redash then complained with a 500 error before upgrading to 2.0.

Let me try again and I’ll let you know.

Thanks for replying.

Just to close this subject.

What I ended up doing is using pgdiff to get sql to migrate v0.12 to v2.0.
Run upgrade script just the 2 first steps: download and upgrade packages.
Run my sql script to effectively migrate the db.
Run upgrade script again but just the last 2 steps: point current to v2, and restart services.

I’ve tested v2 and seems ok. No errors for now. Going to look at logs just to be sure.

Thanks.

1 Like

:clap: glad you got it working.