summaryrefslogtreecommitdiffstats
path: root/openstack/common/db
Commit message (Collapse)AuthorAgeFilesLines
* Don't use mixture of cfg.Opt() deprecated argsMark McLoughlin2013-06-251-24/+22
| | | | | | No need to make this any more ugly than it needs to be :) Change-Id: Ib7ef13bb5f04e1780565de805eb81413d7b21274
* Ensure that DB configuration is backward compatibleGary Kotton2013-06-221-0/+17
| | | | | | Fixes bug 1193557 Change-Id: I483099b205c71d66cf97522307d8265abe83a488
* Enable hacking H404 test.Dina Belova2013-06-111-14/+14
| | | | | | H404 - multi line docstring should start with a summary. Change-Id: I2099e1ee81ff9657f7a07401b8e8f3327d03bdbd
* Enable user to configure pool_timeoutGary Kotton2013-06-111-3/+20
| | | | | | | | | | Fixes bug 1160442 In addition to this there are the following changes: 1. The set_default method can configure the QueuePool parameters 2. The max_pool_size is defaulted to the QueuePool default Change-Id: Ie99f7fc4edba68127c4af508290d8074d7094be9
* Changed processing unique constraint name.Victor Sergeyev2013-06-071-2/+2
| | | | | | | | | | | | | Mr. Devananda found that dollar sign can be used as special symbol in various programming langugages and proposed to use `0` instead of `$`. So unique constraint name convention was changed from "uniq_t$c1$c2$c3" to "uniq_t0c10c20c3" where `0` it is delimiter, `t` it is table name and columns `c1`, `c2`, `c3` are in UniqueConstraint. Function `_raise_if_duplicate_entry_error()` modified respectively to new unique constraint name convention. Change-Id: I88208dc03b55bbbc709b18580048c008004c9fda
* Enable H306 hacking check.Dina Belova2013-06-041-1/+1
| | | | | | H306 - imports not in alphabetical order. Change-Id: Iaa93bcafed562833318ac86241ad36662c2d8ca6
* Merge "Add a slave db handle for the SQLAlchemy backend."Jenkins2013-06-031-10/+64
|\
| * Add a slave db handle for the SQLAlchemy backend.Michael Wilson2013-06-031-10/+64
| | | | | | | | | | | | | | | | | | | | | | Adds an option for a slave DB connection for scaling purposes. Read queries can be sent here to spread out db load a bit. This patch adds a new configuration option: slave_connection. Implements: blueprint db-slave-handle Change-Id: I5cc5e0696e3fcd8609ee6b5466b0377ca52b8b58 DocImpact
* | Merge "Enable hacking H403 test"Jenkins2013-05-301-1/+2
|\ \ | |/ |/|
| * Enable hacking H403 testSergey Lukjanov2013-05-301-1/+2
| | | | | | | | | | | | H403 multi line docstring end on new line Change-Id: I33249651026b54ef346214965e909835288bb14e
* | Merge "Changed processing unique constraint name."Jenkins2013-05-281-3/+4
|\ \ | |/ |/|
| * Changed processing unique constraint name.Victor Sergeyev2013-05-281-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Function `_raise_if_duplicate_entry_error()` modified respectively to new unique constraint name convention. We found that current constraint name convention allows us create constraints with duplicate names. It happens if we will add constraints in different tables with same column names (for example, `name`, `deleted`). In this case we can not create new constraint due to mysql limitation (it requires unique constraint name for database) To solve this issue unique constraint name convention was changed from "uniq_c1_x_c2_x_c3" to "uniq_t$c1$c2$c3" where `t` it is table name and columns `c1`, `c2`, `c3` are in UniqueConstraint. Function `_raise_if_duplicate_entry_error()` parse error from database and provides us correct column names in error message. So now we receive correct error message from function. Change-Id: I4a507deba97c499fcd9738d980e36ca0f9454b71 Fixes: bug 1182054
* | Specify database group instead of DEFAULTDavanum Srinivas2013-05-202-37/+66
|/ | | | | | | | | | | | At the request of Quantum folks, Let us switch from DEFAULT to database for the database related options. This will help with migration etc. DocImpact Fixes LP# 1171837 Change-Id: If602a6a7cc0f2a202632dd14574fea60dce4b589
* Line wrapper becomes to long when expanded.Monty Taylor2013-05-111-2/+3
| | | | | | Projects with long names, such as ceilometer, trip up on this line. Change-Id: I51ff3f0250018215ae240f90cec6051b56aab434
* Merge "Convert unicode for python3 portability"Jenkins2013-05-071-1/+2
|\
| * Convert unicode for python3 portabilityChuck Short2013-05-061-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | From http://docs.python.org/3.1/whatsnew/3.0.html: "Python 3.0 uses the concepts of text and (binary) data instead of Unicode strings and 8-bit strings." Use six.text_type to Type for representing (Unicode) textual data. This is unicode() in Python 2 and str in Python 3. Change-Id: I3da268a714a34a8e626a2590f01b86e414dc3411 Signed-off-by: Chuck Short <chuck.short@canonical.com>
* | Use range rather than xrangeChuck Short2013-05-011-2/+2
|/ | | | | | | | Use range rather than xrange to improve python3 compatibiltiy. Change-Id: I5a4434bbd2e5d509f84c3aa668eea8e46262816f Signed-off-by: Chuck Short <chuck.short@canonical.com>
* Add support to clear DBGary Kotton2013-04-251-0/+11
| | | | | | | | | Fixes bug 1171740 The method cleanup() can be called when a test is complete, for example in the tearDown method. Change-Id: Id30bcb0d7ef167f6cb3b1bdea06f6421e1234a86
* Add enforcement for foreign key contraints with sqliteGary Kotton2013-04-221-5/+22
| | | | | | | | | Fixes bug 1171732 When creating an engine the called can indicate whether or not to enforce the constraints for sqlite. Change-Id: I1d5820376f60388c084afea500f807cd25541800
* Improve Python 3.x compatibilityDirk Mueller2013-04-221-6/+6
| | | | | | | Mechanical translation of deprecated constructs to 3.x compatible variants. Change-Id: I4988d0ac656903e0d0320aaa8361d4eeb774a0f9
* Removes metadata from ModelBaseZhongyue Luo2013-04-201-1/+0
| | | | | | | | Next step is adding metadata to nova.db.sqlalchemy.models.NovaBase Fixes bug #1119699 Change-Id: I306a061e0b17660f612a111067ac618342f4ee99
* Merge "Removes created_at, updated_at from ModelBase"Jenkins2013-04-201-2/+5
|\
| * Removes created_at, updated_at from ModelBaseZhongyue Luo2013-04-111-2/+5
| | | | | | | | | | | | | | | | | | Created a 'TimestampMixin' class. Next step is to update Nova which is the only project using oslo.db Fixes bug #1119702 Change-Id: I1ffcc09a2971e6e6102da7ecb855a2837a159baf
* | Fixes private functions privateZhongyue Luo2013-04-101-21/+21
|/ | | | | | | | | | | | | | | | | | Fixed functions below to private APIs. raise_if_duplicate_entry_error() raise_if_deadlock_error() wrap_db_error() synchronous_switch_listener() add_regexp_listener() greenthread_yield() ping_listener() is_db_connection_error() patch_mysqldb_with_stacktrace_comments() Fixes bug #1119709 Change-Id: I61f700cdbae0126a8b89f6895e4332d695191dd0
* Mark sql_connection with secret flagMichael J Fork2013-03-271-1/+2
| | | | | | | | | sql_connection contains the password in some setups and marking as secret prevents accidental logging fixes bug 1160680 Change-Id: Ib2d00219ea40a010c62e6a29045309f030e6de28
* Fix Copyright Headers - Rename LLC to FoundationDavanum Srinivas2013-03-111-1/+1
| | | | | | One code change, rest are in headers Change-Id: I73f59681358629e1ad74e49d3d3ca13fcb5c2eb1
* Fixes import order nitsZhongyue Luo2013-02-261-1/+1
| | | | Change-Id: I6085bb4a0b990985c8f7a013c89b7d5acafdf312
* Clean up sqlalchemy exception codeChris Behrens2013-02-222-30/+87
| | | | | | | | | | | Moves DB exceptions that can be shared between DB implementations into their own module. Adds DBDeadlock() exception wrapping. Nova has its own code for determining Deadlock and it's better to consolidate it with DBDuplicateKey checking. Change-Id: I108bd0da2a14d62e460a997b1472f0b65bfc9b95
* Move DB thread pooling to DB API loaderChris Behrens2013-02-182-35/+101
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes bug 1128605 The dbpool code in sqlalchemy session is the wrong place to implement thread pooling as it wraps each individual SQL call to run in its own thread. When combined with SQL server locking, all threads can be eaten waiting on locks with none available to run a 'COMMIT'. The correct place to do thread pooling is around each DB API call. This patch removes dbpool from sqlalchemy and creates a common DB API loader for all openstack projects which implements the following configuration options: db_backend: Full path to DB API backend module (or a known short name if a project chooses to implement a mapping) dbapi_use_tpool: True or False whether to use thread pooling around all DB API calls. DB backend modules must implement a 'get_backend()' method. Example usage for nova/db/api.py would be: """ from nova.openstack.common.db import api as db_api _KNOWN_BACKENDS = {'sqlalchemy': 'nova.db.sqlalchemy.api'} IMPL = db_api.DBAPI(backend_mapping=_KNOWN_BACKENDS) """ NOTE: Enabling thread pooling will be broken until this issue is resolved in eventlet _OR_ until we modify our eventlet.monkey_patch() calls to include 'thread=False': https://bitbucket.org/eventlet/eventlet/issue/137/ Change-Id: Idf14563ea07cf8ccf2a77b3f53659d8528927fc7
* Use oslo-config-2013.1b3Mark McLoughlin2013-02-171-1/+1
| | | | | | | | | | | | | | | The cfg API is now available via the oslo-config library, so switch to it and remove the copied-and-pasted version. Add the 2013.1b3 tarball to tools/pip-requires - this will be changed to 'oslo-config>=2013.1' when oslo-config is published to pypi. This will happen in time for grizzly final. Remove the 'deps = pep8==1.3.3' and 'deps = pyflakes' from tox.ini as it means all the other deps get installed with easy_install which can't install oslo-config from the URL. Change-Id: I4815aeb8a9341a31a250e920157f15ee15cfc5bc
* Use importutils.try_import() for MySQLdbMark McLoughlin2013-02-071-6/+4
| | | | | | This is a common pattern we've adopted elsewhere, so use it here too. Change-Id: I2e0947b4857005b478e796e9c9a7c05ea1f0d926
* Minor tweak to make update.py happyMark McLoughlin2013-02-071-1/+1
| | | | | | | Fairly lame to do this instead of just fixing update.py, but we seem to do it this way everywhere else, so ... Change-Id: Ie1cebcfec57c6138b9b726d7d3bc6e0ea456f146
* Remove openstack.common.db.commonMark McLoughlin2013-02-073-58/+28
| | | | | | | | | | | | Since this only contains exceptions that are either used in session.py or utils.py (not both), it seems sensible to move them into the modules where they are used. Also, remove the use of the Invalid base exception class since we don't seem to be making use of the base class anywhere by catching it rather than the more specialized exceptions. Change-Id: Ib05bb2e0a9494e1dc60c60b8eee0e76b5d2ee555
* Provide creating real unique constraints for columnsBoris Pavlovic2013-02-072-4/+4
| | | | | | | | | | | | | | | | | | | | | | Main issue is that we can't create unique constraint for columns, because we are using soft deletion of entries (set `deleted` column to True). The main idea is to use `deleted` columns to create unique constraint for columns. For example (`col1`, `deleted`). To make (`col1`, `deleted`) unique after entry deletion, we should assign the value of `id` to `deleted` column. Change type of `deleted` column from Boolean to table.id.type for all tables. Change models.soft_delete() method to assign table.id instead of True to `deleted` column. Change query.soft_delete() method to assign literal_column("id") instead of True blueprint db-unique-keys Change-Id: Ie1f67f49a5d085e6371efb63fc23a1c8b25d9464
* Fix missing wrap_db_error for Session.execute() methodBoris Pavlovic2013-02-071-0/+4
| | | | | | | | | | | | | We should add wrap_db_error for Session.execute() method, because Query.update() method will call Session.execute() and it is not inside Session.flush(), so exceptions from Query.update() wouldn't be wrapped. Add test for Session.flush() wrapper Add test for Session.execute() wrapper Fixes bug 1107890 Change-Id: I96894e502f9f279999b61a1e66469e34a07a022d
* Fix eventlet/mysql db pooling codeBrian Elliott2013-02-071-3/+17
| | | | | | | | | | | | | Eventlet versions >= 0.10 return a tuple from db_pool.ConnectionPool().create(), not a scalar. Also, set the FOUND_ROWS client flag, which sqlalchemy appears to require to sanity check the number of rows touch. bug 1097992 Change-Id: I64e798660c506fcd13947a232cb7832db0318360
* Add missing DBDuplicateEntryMark McLoughlin2013-02-071-0/+7
| | | | | | | The session.py part of nova's 8835866 was imported, but not the newly added exception. Change-Id: I0d79a8536f0c8f14cb062dc61c5fce100b63fd64
* Be explicit about set_default() parametersMark McLoughlin2013-02-051-2/+4
| | | | | | | | We probably only want to support people using set_defaults() for a limited set of config options, so explicitly list those as parameters to the method. This is what we do for rpc and log options too. Change-Id: I3bfc5355e82eec17480b9547662e847dc0d74138
* Remove duplicate DB optionsMark McLoughlin2013-02-051-6/+0
| | | | | | | | | sql_dbpool_enable and sql_connection_trace are declared twice. Looks like this was a merge conflict when sql_dbpool_enable changed from int to bool. Change-Id: I553c5beea916e0ee296648342324fd53167c073a
* Eliminate gratuitous DB difference vs NovaMark McLoughlin2013-02-051-3/+2
| | | | | | | | | | Looks like this was an abritrary cleanup done as part of the import. It conflicts with a more recent change in Nova. We can move to using try_import() once we've killed the Nova copy of this code. Change-Id: I5c67d3fbd846a262feb724e26b14447a76561ae6
* Import sqlalchemy session/models/utilsEric Windisch2013-02-056-0/+944
Bring in session, base model, utilities, and tests for sqlalchemy from Nova. Add sqlalchemy to pip-requires and and python-mysql to test-requires. Partially implements blueprint common-db Change-Id: I3e0065cdac87e10c4e0742d66c293c72bb3acbb2