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

Bug when saving an opus #26

Open
buehlefs opened this issue Oct 5, 2020 · 1 comment
Open

Bug when saving an opus #26

buehlefs opened this issue Oct 5, 2020 · 1 comment
Labels

Comments

@buehlefs
Copy link
Collaborator

buehlefs commented Oct 5, 2020

Log with stacktrace of the bug:

The client side error message is not helpful for this bug. Maybe the Unique constraint on opus.original_name is too strict and should be dropped.

Click to see full log
sqlalchemy.exc.IntegrityError: (raised as a result of Query-invoked autoflush; consider using a session.no_autoflush block if this flush is occurring prematurely) (mysql.connector.errors.Inte
grityError) 1062 (23000): Duplicate entry '55' for key 'ix_opus_original_name' [SQL: 'UPDATE opus SET original_name=%(original_name)s, score_link=%(score_link)s, first_printed_at=%(first_prin
ted_at)s, first_printed_in=%(first_printed_in)s, composition_year=%(composition_year)s, composition_place=%(composition_place)s, first_played_at=%(first_played_at)s, first_played_in=%(first_p
layed_in)s, notes=%(notes)s WHERE opus.id = %(opus_id)s'] [parameters: {'original_name': '55', 'score_link': '', 'first_printed_at': '', 'first_printed_in': -1, 'composition_year': -1, 'compo
sition_place': '', 'first_played_at': '', 'first_played_in': -1, 'notes': '', 'opus_id': 13}] (Background on this error at: http://sqlalche.me/e/gkpj)
2020-10-05 08:24:52,640 [ERROR] [muse_for_music      ] Exception on /api/opuses/13/ [PUT] <app,                  log_exception, 1891; /var/venv/muse-for-music/lib/python3.6/site-packages/flas
k/app.py>
Traceback (most recent call last):
  File "/var/venv/muse-for-music/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1193, in _execute_context
    context)
  File "/var/venv/muse-for-music/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 507, in do_execute
    cursor.execute(statement, parameters)
  File "/var/venv/muse-for-music/lib/python3.6/site-packages/mysql/connector/cursor.py", line 566, in execute
    self._handle_result(self._connection.cmd_query(stmt))
  File "/var/venv/muse-for-music/lib/python3.6/site-packages/mysql/connector/connection.py", line 537, in cmd_query
    result = self._handle_result(self._send_cmd(ServerCmd.QUERY, query))
  File "/var/venv/muse-for-music/lib/python3.6/site-packages/mysql/connector/connection.py", line 436, in _handle_result
    raise errors.get_exception(packet)
mysql.connector.errors.IntegrityError: 1062 (23000): Duplicate entry '55' for key 'ix_opus_original_name'

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

Traceback (most recent call last):
  File "/var/venv/muse-for-music/lib/python3.6/site-packages/flask/app.py", line 1949, in full_dispatch_request
    rv = self.dispatch_request()
  File "/var/venv/muse-for-music/lib/python3.6/site-packages/flask/app.py", line 1935, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/var/venv/muse-for-music/lib/python3.6/site-packages/flask_restplus/api.py", line 325, in wrapper
    resp = resource(*args, **kwargs)
  File "/var/venv/muse-for-music/lib/python3.6/site-packages/flask/views.py", line 89, in view
    return self.dispatch_request(*args, **kwargs)
  File "/var/venv/muse-for-music/lib/python3.6/site-packages/flask_restplus/resource.py", line 44, in dispatch_request
    resp = meth(*args, **kwargs)
  File "/var/venv/muse-for-music/lib/python3.6/site-packages/flask_jwt_extended/view_decorators.py", line 108, in wrapper
    return fn(*args, **kwargs)
  File "/usr/src/muse-for-music/muse_for_music/user_api/__init__.py", line 49, in wrapper
    return f(*args, **kwargs)
  File "/usr/src/muse-for-music/muse_for_music/api/data/opus.py", line 79, in put
    user = User.get_user_by_name(username)
  File "/usr/src/muse-for-music/muse_for_music/models/users.py", line 42, in get_user_by_name
    return cls.query.filter_by(username=username).first()
  File "/var/venv/muse-for-music/lib/python3.6/site-packages/sqlalchemy/orm/query.py", line 2825, in first
    ret = list(self[0:1])
  File "/var/venv/muse-for-music/lib/python3.6/site-packages/sqlalchemy/orm/query.py", line 2617, in __getitem__
    return list(res)
  File "/var/venv/muse-for-music/lib/python3.6/site-packages/sqlalchemy/orm/query.py", line 2924, in __iter__
    self.session._autoflush()
  File "/var/venv/muse-for-music/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 1444, in _autoflush
    util.raise_from_cause(e)
  File "/var/venv/muse-for-music/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 203, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb, cause=cause)
  File "/var/venv/muse-for-music/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 187, in reraise
    raise value
  File "/var/venv/muse-for-music/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 1434, in _autoflush
    self.flush()
  File "/var/venv/muse-for-music/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 2254, in flush
    self._flush(objects)  File "/var/venv/muse-for-music/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 2380, in _flush
    transaction.rollback(_capture_exception=True)
  File "/var/venv/muse-for-music/lib/python3.6/site-packages/sqlalchemy/util/langhelpers.py", line 66, in __exit__
    compat.reraise(exc_type, exc_value, exc_tb)
  File "/var/venv/muse-for-music/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 187, in reraise
    raise value
  File "/var/venv/muse-for-music/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 2344, in _flush
    flush_context.execute()
  File "/var/venv/muse-for-music/lib/python3.6/site-packages/sqlalchemy/orm/unitofwork.py", line 391, in execute
    rec.execute(self)
  File "/var/venv/muse-for-music/lib/python3.6/site-packages/sqlalchemy/orm/unitofwork.py", line 556, in execute
    uow
  File "/var/venv/muse-for-music/lib/python3.6/site-packages/sqlalchemy/orm/persistence.py", line 177, in save_obj
    mapper, table, update)
  File "/var/venv/muse-for-music/lib/python3.6/site-packages/sqlalchemy/orm/persistence.py", line 768, in _emit_update_statements
    execute(statement, multiparams)
  File "/var/venv/muse-for-music/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 948, in execute
    return meth(self, multiparams, params)
  File "/var/venv/muse-for-music/lib/python3.6/site-packages/sqlalchemy/sql/elements.py", line 269, in _execute_on_connection
    return connection._execute_clauseelement(self, multiparams, params)
  File "/var/venv/muse-for-music/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1060, in _execute_clauseelement
    compiled_sql, distilled_params
  File "/var/venv/muse-for-music/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1200, in _execute_context
    context)
  File "/var/venv/muse-for-music/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1413, in _handle_dbapi_exception
    exc_info
  File "/var/venv/muse-for-music/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 203, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb, cause=cause)
  File "/var/venv/muse-for-music/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 186, in reraise
    raise value.with_traceback(tb)
  File "/var/venv/muse-for-music/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1193, in _execute_context
    context)
  File "/var/venv/muse-for-music/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 507, in do_execute
    cursor.execute(statement, parameters)  File "/var/venv/muse-for-music/lib/python3.6/site-packages/mysql/connector/cursor.py", line 566, in execute
    self._handle_result(self._connection.cmd_query(stmt))
  File "/var/venv/muse-for-music/lib/python3.6/site-packages/mysql/connector/connection.py", line 537, in cmd_query
    result = self._handle_result(self._send_cmd(ServerCmd.QUERY, query))
  File "/var/venv/muse-for-music/lib/python3.6/site-packages/mysql/connector/connection.py", line 436, in _handle_result
    raise errors.get_exception(packet)
sqlalchemy.exc.IntegrityError: (raised as a result of Query-invoked autoflush; consider using a session.no_autoflush block if this flush is occurring prematurely) (mysql.connector.errors.IntegrityError) 1062 (23000): Duplicate entry '55' for key 'ix_opus_original_name' [SQL: 'UPDATE opus SET original_name=%(original_name)s WHERE opus.id = %(opus_id)s'] [parameters: {'original_name': '55', 'opus_id': 13}] (Background on this error at: http://sqlalche.me/e/gkpj)
@buehlefs buehlefs added the bug label Oct 5, 2020
@buehlefs
Copy link
Collaborator Author

buehlefs commented Oct 5, 2020

Solution for this bug: Drop the unique constraint for the original_name

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

No branches or pull requests

1 participant