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

backy2 du fails w/query error #71

Closed
andrewbogott opened this issue Aug 9, 2020 · 3 comments
Closed

backy2 du fails w/query error #71

andrewbogott opened this issue Aug 9, 2020 · 3 comments

Comments

@andrewbogott
Copy link

I've set up my mysql database using the patch at #32. Most features seem to work, but du errors like this:

root@cloudvirt1004:~# backy2 -vd du
INFO: [backy2.logging] $ /usr/bin/backy2 -vd du
DEBUG: [backy2.logging] backup.du(**{'fields': 'Real,Null,Dedup Own,Dedup Others,Individual,Est. Space,Est. Space freed', 'version_uid': None})
INFO: [alembic.runtime.migration] Context impl MySQLImpl.
INFO: [alembic.runtime.migration] Will assume non-transactional DDL.
ERROR: [backy2.logging] Unexpected exception
ERROR: [backy2.logging] (_mysql_exceptions.ProgrammingError) (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ') own_shared,\n (select count() cnt from blocks where uid=a.uid)' at line 1") [SQL: '\n select a.uid, a.size, count(a.) own_shared,\n (select count() cnt from blocks where uid=a.uid) shared\n from blocks a\n where a.version_uid=%s\n and a.uid is not NULL\n group by a.uid, a.size\n '] [parameters: ('be6dc186-d8f3-11ea-9d64-f0921c05f570',)] (Background on this error at: http://sqlalche.me/e/f405)
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/sqlalchemy/engine/base.py", line 1236, in _execute_context
cursor, statement, parameters, context
File "/usr/lib/python3/dist-packages/sqlalchemy/engine/default.py", line 536, in do_execute
cursor.execute(statement, parameters)
File "/usr/lib/python3/dist-packages/MySQLdb/cursors.py", line 250, in execute
self.errorhandler(self, exc, value)
File "/usr/lib/python3/dist-packages/MySQLdb/connections.py", line 50, in defaulterrorhandler
raise errorvalue
File "/usr/lib/python3/dist-packages/MySQLdb/cursors.py", line 247, in execute
res = self._query(query)
File "/usr/lib/python3/dist-packages/MySQLdb/cursors.py", line 411, in _query
rowcount = self._do_query(q)
File "/usr/lib/python3/dist-packages/MySQLdb/cursors.py", line 374, in _do_query
db.query(q)
File "/usr/lib/python3/dist-packages/MySQLdb/connections.py", line 292, in query
_mysql.connection.query(self, query)
_mysql_exceptions.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ') own_shared,\n (select count() cnt from blocks where uid=a.uid)' at line 1")

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

Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/backy2/scripts/backy.py", line 757, in main
func(**func_args)
File "/usr/lib/python3/dist-packages/backy2/scripts/backy.py", line 223, in du
stats = backy.du(version_uid)
File "/usr/lib/python3/dist-packages/backy2/backy.py", line 113, in du
return self.meta_backend.du(version_uid)
File "/usr/lib/python3/dist-packages/backy2/meta_backends/sql.py", line 275, in du
result = self.session.execute(statement, params={'version_uid': version_uid})
File "/usr/lib/python3/dist-packages/sqlalchemy/orm/session.py", line 1263, in execute
clause, params or {}
File "/usr/lib/python3/dist-packages/sqlalchemy/engine/base.py", line 980, in execute
return meth(self, multiparams, params)
File "/usr/lib/python3/dist-packages/sqlalchemy/sql/elements.py", line 273, in _execute_on_connection
return connection._execute_clauseelement(self, multiparams, params)
File "/usr/lib/python3/dist-packages/sqlalchemy/engine/base.py", line 1099, in _execute_clauseelement
distilled_params,
File "/usr/lib/python3/dist-packages/sqlalchemy/engine/base.py", line 1240, in _execute_context
e, statement, parameters, cursor, context
File "/usr/lib/python3/dist-packages/sqlalchemy/engine/base.py", line 1458, in _handle_dbapi_exception
util.raise_from_cause(sqlalchemy_exception, exc_info)
File "/usr/lib/python3/dist-packages/sqlalchemy/util/compat.py", line 296, in raise_from_cause
reraise(type(exception), exception, tb=exc_tb, cause=cause)
File "/usr/lib/python3/dist-packages/sqlalchemy/util/compat.py", line 276, in reraise
raise value.with_traceback(tb)
File "/usr/lib/python3/dist-packages/sqlalchemy/engine/base.py", line 1236, in _execute_context
cursor, statement, parameters, context
File "/usr/lib/python3/dist-packages/sqlalchemy/engine/default.py", line 536, in do_execute
cursor.execute(statement, parameters)
File "/usr/lib/python3/dist-packages/MySQLdb/cursors.py", line 250, in execute
self.errorhandler(self, exc, value)
File "/usr/lib/python3/dist-packages/MySQLdb/connections.py", line 50, in defaulterrorhandler
raise errorvalue
File "/usr/lib/python3/dist-packages/MySQLdb/cursors.py", line 247, in execute
res = self._query(query)
File "/usr/lib/python3/dist-packages/MySQLdb/cursors.py", line 411, in _query
rowcount = self._do_query(q)
File "/usr/lib/python3/dist-packages/MySQLdb/cursors.py", line 374, in _do_query
db.query(q)
File "/usr/lib/python3/dist-packages/MySQLdb/connections.py", line 292, in query
_mysql.connection.query(self, query)
sqlalchemy.exc.ProgrammingError: (_mysql_exceptions.ProgrammingError) (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ') own_shared,\n (select count() cnt from blocks where uid=a.uid)' at line 1") [SQL: '\n select a.uid, a.size, count(a.) own_shared,\n (select count() cnt from blocks where uid=a.uid) shared\n from blocks a\n where a.version_uid=%s\n and a.uid is not NULL\n group by a.uid, a.size\n '] [parameters: ('be6dc186-d8f3-11ea-9d64-f0921c05f570',)] (Background on this error at: http://sqlalche.me/e/f405)
ERROR: [backy2.logging] Backy failed.

@andrewbogott
Copy link
Author

on a closer look, this code looks like it would fail in postgres too

andrewbogott pushed a commit to andrewbogott/backy2 that referenced this issue Aug 9, 2020
The particular syntax count(a.*) in this query doesn't parse
on mariadb (or, presumably, mysql).  Counting a.uid is equivalent;
we can be confident that there aren't any rows without uid
set because the query includes 'a.uid is not NULL'.

Addresses wamdam#71
@andrewbogott andrewbogott changed the title backy2 du w/mysql backend fails backy2 du fails w/query error Aug 16, 2020
@andrewbogott
Copy link
Author

I've confirmed that this issue is present with the (quickstart guide) sqlite backend as well.

wamdam added a commit that referenced this issue Jun 1, 2021
@wamdam
Copy link
Owner

wamdam commented Jun 1, 2021

Could you try again with the latest master?

@wamdam wamdam closed this as completed Sep 26, 2021
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