Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

permission denied to copy database #56

Open
canassa opened this issue Jun 3, 2016 · 1 comment
Open

permission denied to copy database #56

canassa opened this issue Jun 3, 2016 · 1 comment

Comments

@canassa
Copy link

canassa commented Jun 3, 2016

I got this error when trying to snapshot a Postgres database:

Snapshotting database admin_panel
Traceback (most recent call last):
  File "/home/cesar/venv/lib/python3.4/site-packages/sqlalchemy/engine/base.py", line 1139, in _execute_context
    context)
  File "/home/cesar/venv/lib/python3.4/site-packages/sqlalchemy/engine/default.py", line 450, in do_execute
    cursor.execute(statement, parameters)
psycopg2.ProgrammingError: permission denied to copy database "admin_panel"


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/cesar/venv/bin/stellar", line 9, in <module>
    load_entry_point('stellar==0.4.3', 'console_scripts', 'stellar')()
  File "/home/cesar/venv/lib/python3.4/site-packages/stellar/command.py", line 279, in main
    stellar()
  File "/home/cesar/venv/lib/python3.4/site-packages/click/core.py", line 716, in __call__
    return self.main(*args, **kwargs)
  File "/home/cesar/venv/lib/python3.4/site-packages/click/core.py", line 696, in main
    rv = self.invoke(ctx)
  File "/home/cesar/venv/lib/python3.4/site-packages/click/core.py", line 1060, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/cesar/venv/lib/python3.4/site-packages/click/core.py", line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/cesar/venv/lib/python3.4/site-packages/click/core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "/home/cesar/venv/lib/python3.4/site-packages/stellar/command.py", line 70, in snapshot
    app.create_snapshot(name, before_copy=before_copy)
  File "/home/cesar/venv/lib/python3.4/site-packages/stellar/app.py", line 120, in create_snapshot
    table.get_table_name('master')
  File "/home/cesar/venv/lib/python3.4/site-packages/stellar/operations.py", line 65, in copy_database
    from_database
  File "/home/cesar/venv/lib/python3.4/site-packages/sqlalchemy/engine/base.py", line 906, in execute
    return self._execute_text(object, multiparams, params)
  File "/home/cesar/venv/lib/python3.4/site-packages/sqlalchemy/engine/base.py", line 1054, in _execute_text
    statement, parameters
  File "/home/cesar/venv/lib/python3.4/site-packages/sqlalchemy/engine/base.py", line 1146, in _execute_context
    context)
  File "/home/cesar/venv/lib/python3.4/site-packages/sqlalchemy/engine/base.py", line 1341, in _handle_dbapi_exception
    exc_info
  File "/home/cesar/venv/lib/python3.4/site-packages/sqlalchemy/util/compat.py", line 202, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb, cause=cause)
  File "/home/cesar/venv/lib/python3.4/site-packages/sqlalchemy/util/compat.py", line 185, in reraise
    raise value.with_traceback(tb)
  File "/home/cesar/venv/lib/python3.4/site-packages/sqlalchemy/engine/base.py", line 1139, in _execute_context
    context)
  File "/home/cesar/venv/lib/python3.4/site-packages/sqlalchemy/engine/default.py", line 450, in do_execute
    cursor.execute(statement, parameters)
sqlalchemy.exc.ProgrammingError: (psycopg2.ProgrammingError) permission denied to copy database "admin_panel"
 [SQL: '\n                CREATE DATABASE "stellar_69dc3d044d9f1154" WITH TEMPLATE "admin_panel";\n

After some Googling, I managed to fix the problem running this query:

update pg_database set datistemplate = true where datname = 'admin_panel';

But I am not sure if that's an optimal solution

@quantus
Copy link
Member

quantus commented Nov 25, 2016

I can't replicate the issue with my current setup and I don't have time + motivation to start playing with different postgres permission settings to replicate the issue.

I do agree that the stellar behaves in a really bad way in this case. I would happily merge a PR that somehow fixes the issue, or just lets the user know about the permission issue.

Ps. Sorry for late response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants