oslo.db tries to delete non-existent databases before tests

Bug #1341906 reported by Angus Lees
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
oslo-incubator
Fix Released
Low
Angus Lees

Bug Description

1. The database name is a random string, so shouldn't already exist.
2. If it *does* already exist, we quite likely want to throw an error
   rather than just delete it.
3. "drop database if exists non_existant_database" throws an error with
   mysqlconnector and a noisy-but-harmless warning with others.

(We can fix the mysqlconnector error in (3), but it is minor compared to (1) and (2))

For reference, the error from (3) with mysqlconnector:
running=${PYTHON:-python} -m oslo.db.sqlalchemy.provision create 8
Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File
  "<tox env>/oslo/db/sqlalchemy/provision.py",
  line 153, in <module>
    main()
  File
  "<tox env>/oslo/db/sqlalchemy/provision.py",
  line 146, in main
    print(create_database(engine))
  File
  "<tox env>/oslo/db/sqlalchemy/provision.py",
  line 75, in create_database
    _execute_sql(engine, sqls, driver)
  File
  "<tox env>/oslo/db/sqlalchemy/provision.py",
  line 52, in _execute_sql
    conn.execute(s)
  File
  "<tox env>/sqlalchemy/engine/base.py",
  line 719, in execute
    return self._execute_text(object, multiparams, params)
  File
  "<tox env>/sqlalchemy/engine/base.py",
  line 868, in _execute_text
    statement, parameters
  File
  "<tox env>/sqlalchemy/engine/base.py",
  line 954, in _execute_context
    context)
  File
  "<tox env>/sqlalchemy/engine/base.py",
  line 1116, in _handle_dbapi_exception
    exc_info
  File
  "<tox env>/sqlalchemy/util/compat.py",
  line 189, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb)
  File
  "<tox env>/sqlalchemy/engine/base.py",
  line 947, in _execute_context
    context)
  File
  "<tox env>/sqlalchemy/engine/default.py",
  line 435, in do_execute
    cursor.execute(statement, parameters)
  File
  "<tox env>/mysql/connector/cursor.py",
  line 491, in execute
    self._handle_result(self._connection.cmd_query(stmt))
  File
  "<tox env>/mysql/connector/cursor.py",
  line 419, in _handle_result
    self._handle_noresultset(result)
  File
  "<tox env>/mysql/connector/cursor.py",
  line 389, in _handle_noresultset
    self._warnings = self._fetch_warnings()
  File
  "<tox env>/mysql/connector/cursor.py",
  line 709, in _fetch_warnings
    raise errors.get_mysql_exception(res[0][1], res[0][2])
sqlalchemy.exc.DatabaseError: (DatabaseError) 1008: Can't drop database
'vgddrfgfsm'; database doesn't exist 'drop database if exists
vgddrfgfsm;' {}

Tags: db
Changed in oslo:
assignee: nobody → Angus Lees (gus)
status: New → In Progress
Changed in oslo:
importance: Undecided → Low
status: In Progress → Triaged
Changed in oslo:
status: Triaged → In Progress
tags: added: db
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to oslo.db (master)

Reviewed: https://review.openstack.org/104430
Committed: https://git.openstack.org/cgit/openstack/oslo.db/commit/?id=f817555c10809f9708ea8d0a1343cd0a5f709804
Submitter: Jenkins
Branch: master

commit f817555c10809f9708ea8d0a1343cd0a5f709804
Author: Angus Lees <email address hidden>
Date: Wed Jul 2 18:23:19 2014 +1000

    Don't drop pre-existing database before tests

    1. The database name is a random string, so shouldn't already exist.
    2. If it *does* already exist, we quite likely want to throw an error
       rather than just delete it.
    3. "drop database if exists non_existant_database" throws an error with
       mysqlconnector and a noisy-but-harmless warning with others.

    (We could fix (3), if it was important)

    For consistency, this also makes drop_database raise an error if the
    database doesn't exist (or has been already deleted).

    Closes-Bug: #1341906
    Change-Id: I0c4a460088ffb7eb79cbf8594d2ff37fd70cf157

Changed in oslo:
status: In Progress → Fix Committed
Changed in oslo:
milestone: none → juno-2
status: Fix Committed → Fix Released
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.