summaryrefslogtreecommitdiff
path: root/tooz/drivers/pgsql.py
Commit message (Collapse)AuthorAgeFilesLines
* Replace md5 with oslo version2.8.0Ade Lee2020-10-291-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | md5 is not an approved algorithm in FIPS mode, and trying to instantiate a hashlib.md5() will fail when the system is running in FIPS mode. md5 is allowed when in a non-security context. There is a plan to add a keyword parameter (usedforsecurity) to hashlib.md5() to annotate whether or not the instance is being used in a security context. In the case where it is not, the instantiation of md5 will be allowed. See https://bugs.python.org/issue9216 for more details. Some downstream python versions already support this parameter. To support these versions, a new encapsulation of md5() has been added to oslo_utils. See https://review.opendev.org/#/c/750031/ This patch is to replace the instances of hashlib.md5() with this new encapsulation, adding an annotation indicating whether the usage is a security context or not. Reviewers need to pay particular attention as to whether the keyword parameter (usedforsecurity) is set correctly. Change-Id: Idbef0f0896753765372c8dfac8ab15e6be49922f Depends-On: https://review.opendev.org/#/c/760160
* Remove six libraryRiccardo Pittau2020-07-011-5/+1
| | | | | | | The tooz project doesn't support Python 2 anymore, using the six library should not be necessary. Change-Id: I9886cabcd13cbc615065ceb372efbf037dff1aeb
* More explicitly document driver connection stringsBen Nemec2018-12-171-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | If you're not intimately familiar with RFC 1808 it can be a bit tricky to write tooz connection strings. In addition, some drivers do not document the options that they recognize in a connection string. This can force a user to read the driver code in order to figure out how to configure tooz to use said driver, which should not be the case. This change more explicitly documents the format of the connection string, including which parts of an RFC 1808 URI it recognizes, and the options that can be passed. It also clarifies which parts of the connection string are optional (possibly because they have defaults) and which must always be included. Note that not every possible configuration is documented. For example, the postgres driver supports multiple methods of configuring the connection host and port. For consistency, I only documented the one that matches the other drivers. This should be sufficient to allow a user to write a working connection string. This change also wires the etcd3 and etcd3gw drivers into the doc index since they were missing before. Change-Id: I66e54433115f27fb54badc2173f8f6044c49aacb
* Merge "Mutualize executor code in a mixin class"Jenkins2017-06-241-1/+1
|\
| * Mutualize executor code in a mixin classJulien Danjou2017-06-211-1/+1
| | | | | | | | Change-Id: I364b0ca5a6361a818a084bbcb83c9e7855cb3583
* | pgsql: fix self._conn.close() being called without connectionJulien Danjou2017-06-221-1/+2
|/ | | | | | | If an error occurs on connection establishment, self._conn is None so it can't be closed. Change-Id: If6fce24cb27aa7090b5165ca4a895c846c40d2dd
* {my,pg}sql: close connections when out of retry1.57.2Julien Danjou2017-06-161-23/+22
| | | | | | | | | | The connection is supposedly closed when blocking is False and the lock is not acquired. Or when an exception happens in the locking code. But if blocking is e.g. 5 seconds, then RetryError is raised but without closing any connection at the end. This fixes that. Change-Id: I7b40e466fe5fc01ee3f8c012f765aafca9ce716a
* Merge "Fix psycopg2 connection argument"1.56.1Jenkins2017-05-091-1/+1
|\
| * Fix psycopg2 connection argumentJulien Danjou2017-05-081-1/+1
| | | | | | | | | | | | | | | | commit 6eea97c3efe6dee6c2c036a581354aaa9b8ef5fa modified the kwarg from "user" to "username" by mistake. Change-Id: Idfe8425d08c065ef19e8952e8fcb205779243a99 Closes-Bug: #1689211
* | sql: close connection for lock if not usedgord chung2017-04-271-18/+32
|/ | | | | | | | | each lock creates it's own connection and only gets released when garbage collection kicks in because of limitations change logic so if we don't have lock, we don't have connection. Change-Id: Ibf6eaf3ff3031424917e9fdb6920bf2fc1808b7c
* Add shared filelockzhangsong2017-03-211-1/+4
| | | | | | | | | | | Currently each driver in tooz only support exclusive lock, it is inefficient in some scenarios which only need shared lock. This patch adds shared lock in file driver. Change-Id: I55a528977e74b27da736f421d2eee28c7aae8aa3 Implements: blueprint support-shared-lock Co-Authored-By: Julien Danjou <julien@danjou.info>
* postgresql: only pass username and password if they are set1.50.0Julien Danjou2017-03-011-7/+8
| | | | | | | Passing None makes psycopg2 >= 2.7 use the string "None" as a role rather than nothing like it used to do. Change-Id: Idf575930ea363a7e7e613ebdca4595a9ca8f7389
* Stop making tooz.utils depending on tooz.coordinationJulien Danjou2017-01-011-6/+6
| | | | Change-Id: I5fdb1174ae1a2a84412f3b3159ad5835b2f7359f
* Move ToozError to root moduleJulien Danjou2016-12-071-1/+1
| | | | Change-Id: I73b1c5a37b75991f79d8a5fb383c605689503333
* Factorize member_id in the base coordinator classJulien Danjou2016-11-301-1/+1
| | | | | | | | Any coordinator that implements (and they all should) group membership needs a member_id field and copy it to self. Just do that by default for all driver at __init__ time. Change-Id: I66d82815afd4c6e9354212e5ab3fba17931c1bbc
* coordinator: add join_group_createJulien Danjou2016-11-241-1/+1
| | | | | | | This adds a method implement the common pattern of joining a group and creating it if it does not exist. Change-Id: Ie46e7c1d07599a20bd8c24e28e5936b9f47a8bf4
* Replace retrying with tenacityJulien Danjou2016-11-241-2/+2
| | | | | Change-Id: I1f4710ac0b7a3fd32cd3406254ecbd6b7ae1dfa2 Closes-Bug: #1635406
* Expose timeout capabilities and use them for testsJulien Danjou2016-06-091-0/+1
| | | | Change-Id: I5b6ee43e6a6b91859dacedb9791da74e247cd12b
* Using LOG.warning instead of LOG.warn1.38.0Gary Kotton2016-06-061-1/+1
| | | | | | | | Python 3 deprecated the logger.warn method, see: https://docs.python.org/3/library/logging.html#logging.warning so we prefer to use warning to avoid DeprecationWarning. Change-Id: Iac71d0c6d4209c236f4a4149eec0d08ec1682271
* pgsql: fix hostname parsingJulien Danjou2016-01-261-3/+3
| | | | | | | | | | The current PostgreSQL driver only look for the host option in URL, whereas it should also look for the hostname in the URL! This patch makes sure you can override URL values with options, but also read those URL values. Change-Id: I70a13c2f61bdd3a04fd2b0ed4cbf8b2ca96cfec6
* Merge "Add programatic introspection of drivers characteristic(s)"Jenkins2016-01-081-0/+10
|\
| * Add programatic introspection of drivers characteristic(s)Joshua Harlow2016-01-071-0/+10
| | | | | | | | Change-Id: Icf187db9ba7d076b1a0f3cc9343acb0eaa1862cb
* | utils: replace exception_message by exception_to_unicodeJulien Danjou2016-01-041-1/+3
|/ | | | | | This leverages directly oslo_utils.encodeutils. Change-Id: Id345f4c18cfe98e7359c8934b7148c97e2e1fd99
* Merge "pgsql: remove unused left-over code"Jenkins2015-12-021-2/+0
|\
| * pgsql: remove unused left-over codeJulien Danjou2015-11-261-2/+0
| | | | | | | | Change-Id: I93fe017c32ed2de7462f66dfc2e44aafea768834
* | {pg,my}sql: fix AttributeError on connection failureJulien Danjou2015-11-271-1/+1
|/ | | | | | | | | | If connection fails to be established, the acquired attribute does not exist and then you see warning such has: Exception AttributeError: "'MySQLLock' object has no attribute 'acquired'" in <bound method MySQLLock.__del__ of <tooz.drivers.mysql.MySQLLock object at 0x7f79479056d0>> Change-Id: Id61775483c91ba4127d9dd8cb56d6629a51d7081
* Ensure lock(s) acquire/release returns boolean valuesJoshua Harlow2015-06-191-0/+4
| | | | | | | | | Some of the returns were missing, so to ensure that the interface is consistent ensure that we always return true or false as needed, and add tests to ensure this keeps on being maintained. Change-Id: I877111c3a1d1d300881625c5900d4a825c5f1684
* Provide and use a options collapsing functionJoshua Harlow2015-05-041-4/+4
| | | | | | | | | | | | | | | | Instead of having each driver index the last value of each option, when all current drivers do not actually care about any of the other indexes we can just use and provide a option collapsing function that we by default apply to all the existing drivers options (to avoid needing to index by -1). This avoids a confusion point for new folks, and one that does not currently really provide any value (no driver in tree besides one option in the redis driver uses/consumes or understands multiple options in the first place). Change-Id: Ia2898d84fd0e54871b829f4a95786a33accc20b8
* Add + use helper to raise + chain exceptionsJoshua Harlow2015-04-141-2/+6
| | | | | | | | | | | Ensure that on python versions that can retain the exceptions associated chain/causes that we make an attempt to retain them, on versions of python that do not have this at least attempt to retain the chain (but we will not get the nice stack formatting that comes along with that). Change-Id: I7b46854c3969463009c39be28a3131d2d3179c82
* Merge "Beef up the docstrings on the various drivers"Jenkins2015-04-101-1/+9
|\
| * Beef up the docstrings on the various driversJoshua Harlow2015-04-081-1/+9
| | | | | | | | Change-Id: I1ca05629cc5f28c1248767bb18384a29801bece2
* | fix lock concurrency issues with certain driversMehdi Abaakouk2015-04-081-19/+36
|/ | | | | | | | | | | | | | | | | This change adds a test to ensure that lock acquired from different threads/processes work as expected. And fixes drivers when they won't. With file driver, when two threads acquire the lock, when the first one releases it, the second get a 'ValueError: I/O operation on closed file' because the first have closed the file after releasing the lock. Now, the file is open when the lock object is created and we let the GC to close it when we don't need it anymore With mysql, postgres, kazoo driver, multiple acquire inside the same backend session, doesn't work like a exclusive lock, so we track the status locally when we get the lock inside a process. Change-Id: Ic990a79c9baebe534409c1a433e21f4a2f9a7d6a
* Two locks acquired from one coord must worksMehdi Abaakouk2015-02-271-16/+26
| | | | | | | Multiple calls to get_coord(name) should returns a different lock object This is not true for all drivers. This change fixes that. Change-Id: Ie14f0f252cc54317867efb3b0490b90078fff32b
* Upgrade to hacking 0.10Julien Danjou2015-01-131-2/+0
| | | | Change-Id: I77f50a1a4a5b08bd71d549e62fd471ef445b4bd7
* Add driver autogenerated docsJoshua Harlow2014-12-091-0/+1
| | | | | | | | | Start to add/build a developer oriented doc that can be further refined to explain to developers how to use the different tooz drivers (and what the varying drivers capabilities are). Change-Id: I49f6bf5b397d6bc5426c074f6196c764c8938d23
* Translate psycopg2 errors/exceptions into tooz exceptionsJoshua Harlow2014-11-181-10/+73
| | | | | | | | | | | | | Instead of raising raw psycopg2 errors/exceptions from the postgresql driver we should make an attempt to translate those errors/exceptions into a equivalent tooz exception to make it so that users of tooz can handle the known driver failure modes in a sane manner (users expecting to user tooz as a pluggable abstraction will not be able to handle raw psycopg2 errors/exceptions, especially if those users are using different tooz backends at the same time). Change-Id: Ic95e5fa21bb25096a31b5c5e38aa0b14afa05d87
* Implement non-blocking locks with PostgreSQLJulien Danjou2014-11-061-6/+20
| | | | Change-Id: Id0f2f10bf9d284343c19ba395a90aea7b9233124
* Add a PostgreSQL driverJulien Danjou2014-11-061-0/+101
Change-Id: Id6a6ef4c1ec11c1f8cf5aa440c4f425213837ffc