@@ -18,8 +18,12 @@ The following can be imported from ``django_mysql.locks``.
18
18
This class implements a user lock and acts as either a context manager
19
19
(recommended), or a plain object with ``acquire `` and ``release `` methods
20
20
similar to ``threading.Lock ``. These call the MySQL functions ``GET_LOCK ``,
21
- ``RELEASE_LOCK ``, and ``IS_USED_LOCK `` to manage it. It is *not * re-entrant
22
- so don't write code that gains/releases the same lock more than once.
21
+ ``RELEASE_LOCK ``, and ``IS_USED_LOCK `` to manage it.
22
+
23
+ The lock is only re-entrant (acquirable multiple times) on MariaDB 10.0+.
24
+
25
+ MySQL before 5.7, and MariaDB before 10.0, only allowed one lock per
26
+ connection. On those versions and later, you can hold multiple locks.
23
27
24
28
Basic usage:
25
29
@@ -46,18 +50,6 @@ The following can be imported from ``django_mysql.locks``.
46
50
set to ``STATEMENT ``. Most environments have ``binlog_format `` set to
47
51
``MIXED `` because it can be more performant, but do check.
48
52
49
- .. warning ::
50
-
51
- It's not very well documented, but you can only hold one lock per
52
- database connection at a time. Acquiring a lock releases any other lock
53
- you were holding.
54
-
55
- Since there is no MySQL function to tell you if you are currently
56
- holding a lock, this class does not check that you only acquire one
57
- lock. It has been a `more than 10 year feature request
58
- <http://bugs.mysql.com/bug.php?id=1118> `_ to hold more than one lock
59
- per connection, and has been finally announced in MySQL 5.7.5.
60
-
61
53
.. attribute :: name
62
54
63
55
This is a required argument.
@@ -68,8 +60,10 @@ The following can be imported from ``django_mysql.locks``.
68
60
a full stop, in case multiple apps are using different databases on the
69
61
same server.
70
62
71
- Whilst not documented, the length limit is somewhere between 1 and 10
72
- million characters, so most sane uses should be fine.
63
+ MySQL 5.7+ enforces a maximum length on the total name (including the
64
+ DB prefix that Django-MySQL adds) of 64 characters. MariaDB doesn't
65
+ enforce any limit. The practical limit on MySQL <5.6 or MariaDB is
66
+ maybe 1 million characters or more, so most sane uses should be fine.
73
67
74
68
.. attribute :: acquire_timeout=10.0
75
69
0 commit comments