jaaql-middleware-python 5.3.3__py3-none-any.whl → 5.3.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- jaaql/constants.py +1 -1
- jaaql/db/db_interface.py +20 -3
- jaaql/db/db_pg_interface.py +15 -0
- jaaql/mvc/model.py +5 -0
- {jaaql_middleware_python-5.3.3.dist-info → jaaql_middleware_python-5.3.4.dist-info}/METADATA +1 -1
- {jaaql_middleware_python-5.3.3.dist-info → jaaql_middleware_python-5.3.4.dist-info}/RECORD +9 -9
- {jaaql_middleware_python-5.3.3.dist-info → jaaql_middleware_python-5.3.4.dist-info}/WHEEL +0 -0
- {jaaql_middleware_python-5.3.3.dist-info → jaaql_middleware_python-5.3.4.dist-info}/licenses/LICENSE.txt +0 -0
- {jaaql_middleware_python-5.3.3.dist-info → jaaql_middleware_python-5.3.4.dist-info}/top_level.txt +0 -0
jaaql/constants.py
CHANGED
jaaql/db/db_interface.py
CHANGED
|
@@ -77,6 +77,11 @@ class DBInterface(ABC):
|
|
|
77
77
|
logging.warning(exc, exc_info=False)
|
|
78
78
|
|
|
79
79
|
def __attempt_commit_rollback(self, conn, err):
|
|
80
|
+
# Returns the commit failure rather than swallowing it. A failed commit means the transaction
|
|
81
|
+
# did NOT persist, so the caller must not report success. Silently swallowing it turned lost
|
|
82
|
+
# writes into a misleading downstream error - e.g. create_account's CREATE ROLE lost on a
|
|
83
|
+
# connection killed by a \wipe dbms reboot, then "GRANT registered TO <role>" failing with
|
|
84
|
+
# "role does not exist" on the very next statement.
|
|
80
85
|
try:
|
|
81
86
|
if err is None:
|
|
82
87
|
self.commit(conn)
|
|
@@ -84,9 +89,11 @@ class DBInterface(ABC):
|
|
|
84
89
|
self.rollback(conn)
|
|
85
90
|
except Exception as ex:
|
|
86
91
|
if err is None:
|
|
87
|
-
self.log_warning(ex) #
|
|
92
|
+
self.log_warning(ex) # commit failed - the transaction did not persist
|
|
93
|
+
return ex
|
|
88
94
|
else:
|
|
89
95
|
self.log_critical(ex) # error rolling back. It is serious
|
|
96
|
+
return None
|
|
90
97
|
|
|
91
98
|
def __err_to_exception(self, err, echo):
|
|
92
99
|
if err is not None:
|
|
@@ -102,18 +109,28 @@ class DBInterface(ABC):
|
|
|
102
109
|
raise ex
|
|
103
110
|
|
|
104
111
|
def handle_error(self, conn, err, echo=ECHO__none):
|
|
105
|
-
self.__attempt_commit_rollback(conn, err)
|
|
112
|
+
commit_err = self.__attempt_commit_rollback(conn, err)
|
|
113
|
+
if err is None and commit_err is not None:
|
|
114
|
+
raise HttpStatusException("Commit failed, transaction not persisted: " + str(commit_err),
|
|
115
|
+
HTTPStatus.INTERNAL_SERVER_ERROR)
|
|
106
116
|
self.__err_to_exception(err, echo)
|
|
107
117
|
|
|
108
118
|
def put_conn_handle_error(self, conn, err, echo=ECHO__none, skip_rollback_commit: bool = False):
|
|
119
|
+
commit_err = None
|
|
109
120
|
if not skip_rollback_commit:
|
|
110
|
-
self.__attempt_commit_rollback(conn, err)
|
|
121
|
+
commit_err = self.__attempt_commit_rollback(conn, err)
|
|
111
122
|
|
|
112
123
|
try:
|
|
113
124
|
self.put_conn(conn)
|
|
114
125
|
except Exception as ex:
|
|
115
126
|
self.log_warning(ex)
|
|
116
127
|
|
|
128
|
+
# A failed commit persisted nothing; surface it (instead of the old silent swallow) so the
|
|
129
|
+
# caller does not treat lost writes as success and hit a misleading error further on.
|
|
130
|
+
if err is None and commit_err is not None:
|
|
131
|
+
raise HttpStatusException("Commit failed, transaction not persisted: " + str(commit_err),
|
|
132
|
+
HTTPStatus.INTERNAL_SERVER_ERROR)
|
|
133
|
+
|
|
117
134
|
self.__err_to_exception(err, echo)
|
|
118
135
|
|
|
119
136
|
@abstractmethod
|
jaaql/db/db_pg_interface.py
CHANGED
|
@@ -147,6 +147,21 @@ class DBPGInterface(DBInterface):
|
|
|
147
147
|
DBPGInterface.HOST_POOLS = {}
|
|
148
148
|
DBPGInterface.HOST_POOLS_QUEUES = {}
|
|
149
149
|
|
|
150
|
+
@staticmethod
|
|
151
|
+
def check_all_pools():
|
|
152
|
+
# Force a synchronous liveness check of every pooled connection, discarding and replacing any
|
|
153
|
+
# that are broken. clean() reboots Postgres, and background activity (the per-minute cron, the
|
|
154
|
+
# auth verifier) can re-open pools DURING the reboot/reinstall window, caching connections to
|
|
155
|
+
# the old postmaster. psycopg_pool only detects those lazily, so the first real request after
|
|
156
|
+
# the wipe (e.g. \register @dba) gets handed a dead connection whose commit then fails "the
|
|
157
|
+
# connection is lost". Calling this once Postgres is stable makes the refresh deterministic.
|
|
158
|
+
for _, user_pool_dict in DBPGInterface.HOST_POOLS.items():
|
|
159
|
+
for _, pool in user_pool_dict.items():
|
|
160
|
+
try:
|
|
161
|
+
pool.check()
|
|
162
|
+
except Exception:
|
|
163
|
+
pass
|
|
164
|
+
|
|
150
165
|
@staticmethod
|
|
151
166
|
def _process_returned_conn(username: str, db_name: str, conn, do_reset: bool):
|
|
152
167
|
if isinstance(conn, JaaqlPGConnection) and conn.jaaql_has_pending_auth():
|
jaaql/mvc/model.py
CHANGED
|
@@ -1457,6 +1457,11 @@ WHERE
|
|
|
1457
1457
|
self.vault.get_obj(VAULT_KEY__jaaql_db_password)
|
|
1458
1458
|
)
|
|
1459
1459
|
|
|
1460
|
+
# Postgres was just rebooted and reinstalled. Discard any connections opened against the old
|
|
1461
|
+
# postmaster during that window (by the cron/verifier/install) so the next request cannot be
|
|
1462
|
+
# handed a dead connection whose commit silently fails. Runs once per wipe - no per-request cost.
|
|
1463
|
+
DBPGInterface.check_all_pools()
|
|
1464
|
+
|
|
1460
1465
|
def execute_migrations(self, connection: DBInterface):
|
|
1461
1466
|
self.is_super_admin(connection)
|
|
1462
1467
|
|
{jaaql_middleware_python-5.3.3.dist-info → jaaql_middleware_python-5.3.4.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: jaaql-middleware-python
|
|
3
|
-
Version: 5.3.
|
|
3
|
+
Version: 5.3.4
|
|
4
4
|
Summary: The jaaql package, allowing for rapid development and deployment of RESTful HTTP applications
|
|
5
5
|
Home-page: https://github.com/JAAQL/JAAQL-middleware-python
|
|
6
6
|
Author: Software Quality Measurement and Improvement bv
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
jaaql/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
2
|
jaaql/config_constants.py,sha256=puoR6jfbXw8oXXEfbYNn2ysGwgiGTyuDjOj7F8acsTE,470
|
|
3
|
-
jaaql/constants.py,sha256=
|
|
3
|
+
jaaql/constants.py,sha256=a6cd4oyVBfPNG0U5BiAs1f27vXCfMKNaCKNywtWkBoE,7355
|
|
4
4
|
jaaql/generated_constants.py,sha256=pxmpTux7rrjJH6iqLb-R8RKJ4t0CeoGdnspjH5DiWgU,11327
|
|
5
5
|
jaaql/jaaql.py,sha256=bfiEW9A8PlZIVjDJd_LOhCLBL8flc_f7w0umR6EWbU4,6614
|
|
6
6
|
jaaql/patch.py,sha256=VE4B6jA492NCIxNIewbynh92jxVulmRFtB9hNEe6q94,149
|
|
@@ -9,8 +9,8 @@ jaaql/config/config-docker.ini,sha256=2UNtdwHQWZhANgxnrHvtxnDW0C0MuX042IZITMXNsZ
|
|
|
9
9
|
jaaql/config/config-test.ini,sha256=ap9OFqCCbYdWqmUKq0p9GD1IkM4CzeTXDV5gbQGQZoQ,283
|
|
10
10
|
jaaql/config/config.ini,sha256=o1orXNYRFgf09MKzZBQ3v0oMzWn7N6KwvX5YV0WJtns,321
|
|
11
11
|
jaaql/db/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
12
|
-
jaaql/db/db_interface.py,sha256=
|
|
13
|
-
jaaql/db/db_pg_interface.py,sha256=
|
|
12
|
+
jaaql/db/db_interface.py,sha256=oThoFb_9xoBBbYI5_Gedu0QGUuFFZJoGxcot9c4OOEM,8910
|
|
13
|
+
jaaql/db/db_pg_interface.py,sha256=IkmgLPPWwoUCuAjvv0TBZIqORlxsCZuTVfDrFEDIf5M,21985
|
|
14
14
|
jaaql/db/db_utils.py,sha256=xZCdtWT9semzLL-NAiwMFx_38Wv96BBv60pfPYNDnCc,7761
|
|
15
15
|
jaaql/db/db_utils_no_circ.py,sha256=WLhk6EwsnTdLGUAjq3RZBH3FzgwEumh45A24WWysWmQ,4666
|
|
16
16
|
jaaql/documentation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -38,7 +38,7 @@ jaaql/mvc/controller_interface.py,sha256=Wx8fA4lrqb_PPwkLNjJDxDloHB5JxmNt1Gv3SsD
|
|
|
38
38
|
jaaql/mvc/exception_queries.py,sha256=lF65cj9KgJgRvyzxDjPDM05rHFSHF0jy1V8B77H9Rvo,7899
|
|
39
39
|
jaaql/mvc/generated_queries.py,sha256=z1Jsyu-Y6D-Xd8LYvefzwv8C01NaBjHaHI7mcvv-WEk,72232
|
|
40
40
|
jaaql/mvc/handmade_queries.py,sha256=kyXZ7L_AoxfcPR4u3r5So8khlRD6_sGQ39JnSAHDsEA,938
|
|
41
|
-
jaaql/mvc/model.py,sha256=
|
|
41
|
+
jaaql/mvc/model.py,sha256=pPAu4GregD-XxVSCMjdqxhnTRoGJh6iqXqXF0yba4OA,133209
|
|
42
42
|
jaaql/mvc/model_interface.py,sha256=YgAjaAiIQL1UtIJYgvkl_C3r6PVo-8Z3MXtwzyIwKnc,257
|
|
43
43
|
jaaql/mvc/response.py,sha256=F4WvR9h1JcWF3Y6cj3n5HpVIqnwiMpNqfE8D29ZHbSE,860
|
|
44
44
|
jaaql/openapi/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -66,8 +66,8 @@ jaaql/utilities/options.py,sha256=75M7-oSeY4wmHGz3-su_c36yf_Csv9HxvTG7aRlGR0A,49
|
|
|
66
66
|
jaaql/utilities/utils.py,sha256=nVYVhuHtWSjdaJaXe9eC1Usja56NO-V9SoBIlcHAK8Q,5166
|
|
67
67
|
jaaql/utilities/utils_no_project_imports.py,sha256=YwcskR15dAqKdEiuF8zGx-tzwWkclSGil_zm_qZ8ylU,4626
|
|
68
68
|
jaaql/utilities/vault.py,sha256=DudyQNtMtaRLL71IGQX0AI16Tg1id98BHTCQPyUNkmE,2243
|
|
69
|
-
jaaql_middleware_python-5.3.
|
|
70
|
-
jaaql_middleware_python-5.3.
|
|
71
|
-
jaaql_middleware_python-5.3.
|
|
72
|
-
jaaql_middleware_python-5.3.
|
|
73
|
-
jaaql_middleware_python-5.3.
|
|
69
|
+
jaaql_middleware_python-5.3.4.dist-info/licenses/LICENSE.txt,sha256=wr50eN0TnkrCSuNwyiI81FLZqmrW3q0JqRlVVQIrGA0,18134
|
|
70
|
+
jaaql_middleware_python-5.3.4.dist-info/METADATA,sha256=tnj3S1kr3JxHG8p3t4CsGShXlcukdyIHrRPJJWEK7KQ,1976
|
|
71
|
+
jaaql_middleware_python-5.3.4.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
|
|
72
|
+
jaaql_middleware_python-5.3.4.dist-info/top_level.txt,sha256=k5aKVQy77bPyfyNHITvo5m3FqdSAiiXbjT5S9D9KzgU,6
|
|
73
|
+
jaaql_middleware_python-5.3.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
{jaaql_middleware_python-5.3.3.dist-info → jaaql_middleware_python-5.3.4.dist-info}/top_level.txt
RENAMED
|
File without changes
|