fastmonkeys / stellar

Fast database snapshot and restore tool for development
MIT License
3.86k stars 119 forks source link

Source database "template1" is being accessed by other users #77

Open mohamedanees6 opened 5 years ago

mohamedanees6 commented 5 years ago

Am using postgres (PostgreSQL) 9.3.24 and installed(also, init) stellar.

I am getting this error whenever I try to take a snapshot

Traceback (most recent call last): File "/usr/local/bin/stellar", line 9, in load_entry_point('stellar==0.4.5', 'console_scripts', 'stellar')() File "/Library/Python/2.7/site-packages/stellar/command.py", line 279, in main stellar() File "/Library/Python/2.7/site-packages/click/core.py", line 764, in call return self.main(args, kwargs) File "/Library/Python/2.7/site-packages/click/core.py", line 717, in main rv = self.invoke(ctx) File "/Library/Python/2.7/site-packages/click/core.py", line 1137, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/Library/Python/2.7/site-packages/click/core.py", line 956, in invoke return ctx.invoke(self.callback, ctx.params) File "/Library/Python/2.7/site-packages/click/core.py", line 555, in invoke return callback(args, *kwargs) File "/Library/Python/2.7/site-packages/stellar/command.py", line 60, in snapshot app = get_app() File "/Library/Python/2.7/site-packages/stellar/command.py", line 28, in get_app app = Stellar() File "/Library/Python/2.7/site-packages/stellar/app.py", line 45, in init self.init_database() File "/Library/Python/2.7/site-packages/stellar/app.py", line 64, in init_database tables_missing = self.create_stellar_database() File "/Library/Python/2.7/site-packages/stellar/app.py", line 72, in create_stellar_database self.operations.create_database('stellar_data') File "/Library/Python/2.7/site-packages/stellar/operations.py", line 57, in create_database get_engine_url(raw_conn, database) File "/Library/Python/2.7/site-packages/sqlalchemy_utils/functions/database.py", line 570, in create_database result_proxy = engine.execute(text) File "/Library/Python/2.7/site-packages/sqlalchemy/engine/base.py", line 2166, in execute return connection.execute(statement, multiparams, **params) File "/Library/Python/2.7/site-packages/sqlalchemy/engine/base.py", line 982, in execute return self._executetext(object, multiparams, params) File "/Library/Python/2.7/site-packages/sqlalchemy/engine/base.py", line 1155, in _execute_text parameters, File "/Library/Python/2.7/site-packages/sqlalchemy/engine/base.py", line 1248, in _execute_context e, statement, parameters, cursor, context File "/Library/Python/2.7/site-packages/sqlalchemy/engine/base.py", line 1466, in _handle_dbapi_exception util.raise_from_cause(sqlalchemy_exception, exc_info) File "/Library/Python/2.7/site-packages/sqlalchemy/util/compat.py", line 383, in raise_from_cause reraise(type(exception), exception, tb=exc_tb, cause=cause) File "/Library/Python/2.7/site-packages/sqlalchemy/engine/base.py", line 1244, in _execute_context cursor, statement, parameters, context File "/Library/Python/2.7/site-packages/sqlalchemy/engine/default.py", line 552, in do_execute cursor.execute(statement, parameters) sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) source database "template1" is being accessed by other users DETAIL: There is 1 other session using the database.

However, when I type in,

sudo ps aux | grep template1

mohamedanees 32492 0.0 0.0 4268020 788 s002 S+ 10:14AM 0:00.00 grep template1

I am unable to see any process using template1.

Any pointers to solve this? I tried restarting postgres, disabled pgAdmin. Still this problem exisits.

joey999 commented 5 years ago

SQLAlchemy==1.2.5 and SQLAlchemy-Utils==0.33.1

volkanunsal commented 5 years ago

Same here.

@joey999 Does it work with those versions?

catogonzalez commented 5 years ago

I had the same issue and fixed by editing stellar.yaml and changing template1 in this line

url: 'postgresql://charlie@localhost:5432/template1'

for whatever db name you are using.

leonelgalan commented 4 years ago

Same here.

@joey999 Does it work with those versions?

It did for me after getting these errors.

ramonakira commented 4 years ago

SQLAlchemy==1.2.5 and SQLAlchemy-Utils==0.33.1

Thanks this works for me, but is actually a downgrade since I had the following versions installed:

SQLAlchemy==1.3.16
SQLAlchemy-Utils==0.36.5

Anyone have an idea why this works?