sqlalchemy backend concurrency conflict

Bug #1662441 reported by wangxiyuan
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
zaqar
Invalid
Undecided
Unassigned

Bug Description

Now, when use sqlalchemy backend, the tables in db are created by the first API call.

So before the tables are created, if there are some API calls at the same time, the sql will raise an error, say that the table has already existed.

LOG:

2017-02-07 02:30:51.975 685 DEBUG zaqar.common.decorators [(None,) - - - - -] Queue item PUT: {"project_id": "ce9142070e6c4e24bb72d71538fcd808", "queue_name": "Queues-Test-730891586"} wrapper /opt/stack/new/zaqar/zaqar/common/decorators.py:49
2017-02-07 02:30:51.979 685 DEBUG zaqar.common.decorators [(None,) - - - - -] Queue item PUT: {"project_id": "1ab4c6a3b43e486188799bc7bf561aee", "queue_name": "tempest-test-416030871"} wrapper /opt/stack/new/zaqar/zaqar/common/decorators.py:49
2017-02-07 02:30:51.998 685 DEBUG zaqar.common.decorators [(None,) - - - - -] Queues item PUT: {"project_id": "70ca574bfc8546f596a9ed907a075af0", "queue_name": "tempest-Queues-Test-2003718952"} wrapper /opt/stack/new/zaqar/zaqar/common/decorators.py:49
2017-02-07 02:30:51.999 685 DEBUG zaqar.common.decorators [(None,) - - - - -] Messages collection POST: {"project_id": "63c782f774d647b1899dcedc595e66e0", "queue_name": "Queues-Test-73604307"} wrapper /opt/stack/new/zaqar/zaqar/common/decorators.py:49
2017-02-07 02:30:51.999 685 DEBUG oslo_policy._cache_handler [(None,) - - - - -] Reloading cached file /etc/zaqar/policy.json read_cached_file /usr/local/lib/python2.7/dist-packages/oslo_policy/_cache_handler.py:40
2017-02-07 02:30:52.004 685 DEBUG oslo_policy._cache_handler [(None,) - - - - -] Reloading cached file /etc/zaqar/policy.json read_cached_file /usr/local/lib/python2.7/dist-packages/oslo_policy/_cache_handler.py:40
2017-02-07 02:30:52.008 685 DEBUG oslo_policy.policy [(None,) - - - - -] Reloaded policy file: /etc/zaqar/policy.json _load_policy_file /usr/local/lib/python2.7/dist-packages/oslo_policy/policy.py:666
2017-02-07 02:30:52.008 685 DEBUG oslo_policy.policy [(None,) - - - - -] Reloaded policy file: /etc/zaqar/policy.json _load_policy_file /usr/local/lib/python2.7/dist-packages/oslo_policy/policy.py:666
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues [(None,) - - - - -] (pymysql.err.InternalError) (1050, u"Table 'Pools' already exists") [SQL: u'\nCREATE TABLE `Pools` (\n\tname VARCHAR(64) NOT NULL, \n\t`group` VARCHAR(64), \n\turi VARCHAR(255) NOT NULL, \n\tweight INTEGER NOT NULL, \n\toptions TEXT, \n\tPRIMARY KEY (name), \n\tFOREIGN KEY(`group`) REFERENCES `PoolGroup` (name) ON DELETE CASCADE, \n\tUNIQUE (uri)\n)\n\n']
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues Traceback (most recent call last):
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues File "/opt/stack/new/zaqar/zaqar/transport/wsgi/v2_0/queues.py", line 93, in on_put
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues project=project_id)
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues File "/opt/stack/new/zaqar/zaqar/common/pipeline.py", line 97, in consumer
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues tmp = target(*args, **kwargs)
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues File "/opt/stack/new/zaqar/zaqar/storage/base.py", line 370, in create
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues return self._create(name, metadata, project)
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues File "/opt/stack/new/zaqar/zaqar/storage/pooling.py", line 214, in _create
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues self._pool_catalog.register(name, project=project, flavor=flavor)
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues File "/opt/stack/new/zaqar/zaqar/storage/pooling.py", line 521, in register
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues if not self._catalogue_ctrl.exists(project, queue):
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues File "/opt/stack/new/zaqar/zaqar/storage/sqlalchemy/catalogue.py", line 62, in exists
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues return self.get(project, queue) is not None
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues File "/opt/stack/new/zaqar/zaqar/storage/sqlalchemy/catalogue.py", line 53, in get
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues entry = self.driver.run(stmt).fetchone()
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues File "/opt/stack/new/zaqar/zaqar/storage/sqlalchemy/driver.py", line 84, in run
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues return self.connection.execute(*args, **kwargs)
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues File "/opt/stack/new/zaqar/zaqar/common/decorators.py", line 175, in getter
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues setattr(self, attr_name, fn(self))
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues File "/opt/stack/new/zaqar/zaqar/storage/sqlalchemy/driver.py", line 79, in connection
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues session = scoped_session(sessionmaker(bind=self.engine,
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues File "/opt/stack/new/zaqar/zaqar/common/decorators.py", line 175, in getter
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues setattr(self, attr_name, fn(self))
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues File "/opt/stack/new/zaqar/zaqar/storage/sqlalchemy/driver.py", line 64, in engine
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues tables.metadata.create_all(engine, checkfirst=True)
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/schema.py", line 3762, in create_all
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues tables=tables)
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1856, in _run_visitor
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues conn._run_visitor(visitorcallable, element, **kwargs)
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1481, in _run_visitor
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues **kwargs).traverse_single(element)
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/visitors.py", line 121, in traverse_single
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues return meth(obj, **kw)
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/ddl.py", line 730, in visit_metadata
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues _is_metadata_operation=True)
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/visitors.py", line 121, in traverse_single
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues return meth(obj, **kw)
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/ddl.py", line 764, in visit_table
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues include_foreign_key_constraints=include_foreign_key_constraints
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 914, in execute
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues return meth(self, multiparams, params)
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/ddl.py", line 68, in _execute_on_connection
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues return connection._execute_ddl(self, multiparams, params)
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 968, in _execute_ddl
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues compiled
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1146, in _execute_context
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues context)
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1341, in _handle_dbapi_exception
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues exc_info
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/util/compat.py", line 203, in raise_from_cause
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues reraise(type(exception), exception, tb=exc_tb, cause=cause)
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1139, in _execute_context
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues context)
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/default.py", line 450, in do_execute
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues cursor.execute(statement, parameters)
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues File "/usr/local/lib/python2.7/dist-packages/pymysql/cursors.py", line 166, in execute
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues result = self._query(query)
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues File "/usr/local/lib/python2.7/dist-packages/pymysql/cursors.py", line 322, in _query
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues conn.query(q)
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues File "/usr/local/lib/python2.7/dist-packages/pymysql/connections.py", line 835, in query
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues self._affected_rows = self._read_query_result(unbuffered=unbuffered)
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues File "/usr/local/lib/python2.7/dist-packages/pymysql/connections.py", line 1019, in _read_query_result
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues result.read()
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues File "/usr/local/lib/python2.7/dist-packages/pymysql/connections.py", line 1302, in read
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues first_packet = self.connection._read_packet()
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues File "/usr/local/lib/python2.7/dist-packages/pymysql/connections.py", line 981, in _read_packet
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues packet.check_error()
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues File "/usr/local/lib/python2.7/dist-packages/pymysql/connections.py", line 393, in check_error
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues err.raise_mysql_exception(self._data)
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues File "/usr/local/lib/python2.7/dist-packages/pymysql/err.py", line 107, in raise_mysql_exception
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues raise errorclass(errno, errval)
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues InternalError: (pymysql.err.InternalError) (1050, u"Table 'Pools' already exists") [SQL: u'\nCREATE TABLE `Pools` (\n\tname VARCHAR(64) NOT NULL, \n\t`group` VARCHAR(64), \n\turi VARCHAR(255) NOT NULL, \n\tweight INTEGER NOT NULL, \n\toptions TEXT, \n\tPRIMARY KEY (name), \n\tFOREIGN KEY(`group`) REFERENCES `PoolGroup` (name) ON DELETE CASCADE, \n\tUNIQUE (uri)\n)\n\n']
2017-02-07 02:30:52.100 685 ERROR zaqar.transport.wsgi.v2_0.queues
[pid: 685|app: 0|req: 4/1] 10.24.190.216 () {34 vars in 690 bytes} [Tue Feb 7 02:30:51 2017] PUT /v2/queues/tempest-Queues-Test-2003718952 => generated 135 bytes in 268 msecs (HTTP/1.1 503) 5 headers in 154 bytes (1 switches on core 2)
2017-02-07 02:30:52.116 685 ERROR zaqar.transport.wsgi.driver [(None,) - - - - -] (pymysql.err.InternalError) (1050, u"Table 'Pools' already exists") [SQL: u'\nCREATE TABLE `Pools` (\n\tname VARCHAR(64) NOT NULL, \n\t`group` VARCHAR(64), \n\turi VARCHAR(255) NOT NULL, \n\tweight INTEGER NOT NULL, \n\toptions TEXT, \n\tPRIMARY KEY (name), \n\tFOREIGN KEY(`group`) REFERENCES `PoolGroup` (name) ON DELETE CASCADE, \n\tUNIQUE (uri)\n)\n\n']

wangxiyuan (wangxiyuan)
description: updated
description: updated
Revision history for this message
wangxiyuan (wangxiyuan) wrote :
Changed in zaqar:
status: New → Fix Committed
wangxiyuan (wangxiyuan)
Changed in zaqar:
status: Fix Committed → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.