Revert "indexer: catch another mysql exception"
Revert "indexer: catch another mysql exception"

This reverts commit 23614016944b760025beb66faef4d3ce4a1862ad.

This fix is not the correct one. This kind of backtrace actually happens:

Traceback (most recent call last):
  File "gnocchi/tests/base.py", line 55, in skip_if_not_implemented
    return func(*args, **kwargs)
  File "gnocchi/tests/test_indexer.py", line 814, in test_list_resources_without_history
    details=True)
  File "/home/jenkins/workspace/gate-gnocchi-tox-db-py27-mysql-ubuntu-xenial/.tox/py27-mysql/local/lib/python2.7/site-packages/oslo_db/api.py", line 151, in wrapper
    ectxt.value = e.inner_exc
  File "/home/jenkins/workspace/gate-gnocchi-tox-db-py27-mysql-ubuntu-xenial/.tox/py27-mysql/local/lib/python2.7/site-packages/oslo_utils/excutils.py", line 220, in __exit__
    self.force_reraise()
  File "/home/jenkins/workspace/gate-gnocchi-tox-db-py27-mysql-ubuntu-xenial/.tox/py27-mysql/local/lib/python2.7/site-packages/oslo_utils/excutils.py", line 196, in force_reraise
    six.reraise(self.type_, self.value, self.tb)
  File "/home/jenkins/workspace/gate-gnocchi-tox-db-py27-mysql-ubuntu-xenial/.tox/py27-mysql/local/lib/python2.7/site-packages/oslo_db/api.py", line 139, in wrapper
    return f(*args, **kwargs)
  File "gnocchi/indexer/sqlalchemy.py", line 1050, in list_resources
    all_resources.extend(q.all())
  File "/home/jenkins/workspace/gate-gnocchi-tox-db-py27-mysql-ubuntu-xenial/.tox/py27-mysql/local/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 2638, in all
    return list(self)
  File "/home/jenkins/workspace/gate-gnocchi-tox-db-py27-mysql-ubuntu-xenial/.tox/py27-mysql/local/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 2790, in __iter__
    return self._execute_and_instances(context)
  File "/home/jenkins/workspace/gate-gnocchi-tox-db-py27-mysql-ubuntu-xenial/.tox/py27-mysql/local/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 2813, in _execute_and_instances
    result = conn.execute(querycontext.statement, self._params)
  File "/home/jenkins/workspace/gate-gnocchi-tox-db-py27-mysql-ubuntu-xenial/.tox/py27-mysql/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 945, in execute
    return meth(self, multiparams, params)
  File "/home/jenkins/workspace/gate-gnocchi-tox-db-py27-mysql-ubuntu-xenial/.tox/py27-mysql/local/lib/python2.7/site-packages/sqlalchemy/sql/elements.py", line 263, in _execute_on_connection
    return connection._execute_clauseelement(self, multiparams, params)
  File "/home/jenkins/workspace/gate-gnocchi-tox-db-py27-mysql-ubuntu-xenial/.tox/py27-mysql/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1053, in _execute_clauseelement
    compiled_sql, distilled_params
  File "/home/jenkins/workspace/gate-gnocchi-tox-db-py27-mysql-ubuntu-xenial/.tox/py27-mysql/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1189, in _execute_context
    context)
  File "/home/jenkins/workspace/gate-gnocchi-tox-db-py27-mysql-ubuntu-xenial/.tox/py27-mysql/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1389, in _handle_dbapi_exception
    util.raise_from_cause(newraise, exc_info)
  File "/home/jenkins/workspace/gate-gnocchi-tox-db-py27-mysql-ubuntu-xenial/.tox/py27-mysql/local/lib/python2.7/site-packages/sqlalchemy/util/compat.py", line 203, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb, cause=cause)
  File "/home/jenkins/workspace/gate-gnocchi-tox-db-py27-mysql-ubuntu-xenial/.tox/py27-mysql/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1182, in _execute_context
    context)
  File "/home/jenkins/workspace/gate-gnocchi-tox-db-py27-mysql-ubuntu-xenial/.tox/py27-mysql/local/lib/python2.7/site-packages/sqlalchemy/engine/default.py", line 470, in do_execute
    cursor.execute(statement, parameters)
  File "/home/jenkins/workspace/gate-gnocchi-tox-db-py27-mysql-ubuntu-xenial/.tox/py27-mysql/local/lib/python2.7/site-packages/pymysql/cursors.py", line 166, in execute
    result = self._query(query)
  File "/home/jenkins/workspace/gate-gnocchi-tox-db-py27-mysql-ubuntu-xenial/.tox/py27-mysql/local/lib/python2.7/site-packages/pymysql/cursors.py", line 322, in _query
    conn.query(q)
  File "/home/jenkins/workspace/gate-gnocchi-tox-db-py27-mysql-ubuntu-xenial/.tox/py27-mysql/local/lib/python2.7/site-packages/pymysql/connections.py", line 835, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
  File "/home/jenkins/workspace/gate-gnocchi-tox-db-py27-mysql-ubuntu-xenial/.tox/py27-mysql/local/lib/python2.7/site-packages/pymysql/connections.py", line 1019, in _read_query_result
    result.read()
  File "/home/jenkins/workspace/gate-gnocchi-tox-db-py27-mysql-ubuntu-xenial/.tox/py27-mysql/local/lib/python2.7/site-packages/pymysql/connections.py", line 1302, in read
    first_packet = self.connection._read_packet()
  File "/home/jenkins/workspace/gate-gnocchi-tox-db-py27-mysql-ubuntu-xenial/.tox/py27-mysql/local/lib/python2.7/site-packages/pymysql/connections.py", line 981, in _read_packet
    packet.check_error()
  File "/home/jenkins/workspace/gate-gnocchi-tox-db-py27-mysql-ubuntu-xenial/.tox/py27-mysql/local/lib/python2.7/site-packages/pymysql/connections.py", line 393, in check_error
    err.raise_mysql_exception(self._data)
  File "/home/jenkins/workspace/gate-gnocchi-tox-db-py27-mysql-ubuntu-xenial/.tox/py27-mysql/local/lib/python2.7/site-packages/pymysql/err.py", line 107, in raise_mysql_exception
    raise errorclass(errno, errval)
oslo_db.exception.DBError: (pymysql.err.InternalError) (1412, u'Table definition has changed, please retry transaction') [SQL: u'SELECT resource.creator AS resource_creator, resource.started_at AS resource_started_at, resource.revision_start AS resource_revision_start, resource.ended_at AS resource_ended_at, resource.user_id AS resource_user_id, resource.project_id AS resource_project_id, resource.original_resource_id AS resource_original_resource_id, rt_19d8ff7b16a44b85b5f274521cf609f2.id AS rt_19d8ff7b16a44b85b5f274521cf609f2_id, resource.id AS resource_id, resource.type AS resource_type, rt_19d8ff7b16a44b85b5f274521cf609f2.col1 AS rt_19d8ff7b16a44b85b5f274521cf609f2_col1, archive_policy_1.name AS archive_policy_1_name, archive_policy_1.back_window AS archive_policy_1_back_window, archive_policy_1.definition AS archive_policy_1_definition, archive_policy_1.aggregation_methods AS archive_policy_1_aggregation_methods, metric_1.id AS metric_1_id, metric_1.archive_policy_name AS metric_1_archive_policy_name, metric_1.creator AS metric_1_creator, metric_1.resource_id AS metric_1_resource_id, metric_1.name AS metric_1_name, metric_1.unit AS metric_1_unit, metric_1.status AS metric_1_status \nFROM resource INNER JOIN rt_19d8ff7b16a44b85b5f274521cf609f2 ON resource.id = rt_19d8ff7b16a44b85b5f274521cf609f2.id LEFT OUTER JOIN metric AS metric_1 ON resource.id = metric_1.resource_id AND metric_1.status = %(status_1)s LEFT OUTER JOIN archive_policy AS archive_policy_1 ON archive_policy_1.name = metric_1.archive_policy_name \nWHERE rt_19d8ff7b16a44b85b5f274521cf609f2.id IN (%(id_1)s)'] [parameters: {u'id_1': bytearray(b'hG\xd3J\xeadOM\xackb\x9fKb\xe4s'), u'status_1': 'active'}]

which is not a ProgrammingError and which means we need a global decorator to
catch it.

Change-Id: I65fdfba31c0c282e23190ceb3daadbaa2a0c0dbf

gnocchixyz/gnocchi,gnocchixyz/gnocchi,sileht/gnocchi,leandroreox/gnocchi,sileht/gnocchi,leandroreox/gnocchi