From fd31281caf264643e6b3df96057ca72b95ccf326 Mon Sep 17 00:00:00 2001 From: zaihuaji Date: Fri, 12 Dec 2025 18:00:29 -0600 Subject: [PATCH 1/2] stop db connections for error count exceeding limit --- pyproject.toml | 2 +- src/rda_python_common/PgDBI.py | 2 ++ src/rda_python_common/pg_dbi.py | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 5fa4413..9063b52 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "rda_python_common" -version = "2.0.10" +version = "2.0.11" authors = [ { name="Zaihua Ji", email="zji@ucar.edu" }, ] diff --git a/src/rda_python_common/PgDBI.py b/src/rda_python_common/PgDBI.py index ca02492..0bb7bf7 100644 --- a/src/rda_python_common/PgDBI.py +++ b/src/rda_python_common/PgDBI.py @@ -468,6 +468,8 @@ def check_dberror(pgerr, pgcnt, sqlstr, ary, logact = PGDBI['ERRLOG']): if logact&PgLOG.DOLOCK and pgcode and re.match(r'^55\w\w\w$', pgcode): logact &= ~PgLOG.EXITLG # no exit for lock error + elif pgcnt > PgLOG.PGLOG['DBRETRY']: + logact |= PgLOG.EXITLG # exit for error count exceeds limit return qelog(dberror, 0, sqlstr, ary, pgcnt, logact) # diff --git a/src/rda_python_common/pg_dbi.py b/src/rda_python_common/pg_dbi.py index ccec395..4080e97 100644 --- a/src/rda_python_common/pg_dbi.py +++ b/src/rda_python_common/pg_dbi.py @@ -366,6 +366,8 @@ def check_dberror(self, pgerr, pgcnt, sqlstr, ary, logact = None): return self.SUCCESS if logact&self.DOLOCK and pgcode and re.match(r'^55\w\w\w$', pgcode): logact &= ~self.EXITLG # no exit for lock error + elif pgcnt > self.PGLOG['DBRETRY']: + logact |= self.EXITLG # exit for error count exceeds limit return self.qelog(dberror, 0, sqlstr, ary, pgcnt, logact) # return hash reference to postgresql batch mode command and output file name From 542a9b19a1978a2188de16e565eba23780fee1ce Mon Sep 17 00:00:00 2001 From: zaihuaji Date: Tue, 16 Dec 2025 21:05:46 -0600 Subject: [PATCH 2/2] return rstat --- pyproject.toml | 2 +- src/rda_python_common/pg_opt.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 9063b52..cc99795 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "rda_python_common" -version = "2.0.11" +version = "2.0.12" authors = [ { name="Zaihua Ji", email="zji@ucar.edu" }, ] diff --git a/src/rda_python_common/pg_opt.py b/src/rda_python_common/pg_opt.py index e606a4a..d001a34 100644 --- a/src/rda_python_common/pg_opt.py +++ b/src/rda_python_common/pg_opt.py @@ -1435,7 +1435,7 @@ def send_request_email_notice(self, pgrqst, errmsg, fcount, rstat, readyfile = N rf.write(ebuf) rf.close() self.set_local_mode(readyfile, 1, self.PGLOG['FILEMODE']) - return rstat + return rstat # cache partition process error to existing email buffer def cache_partition_email_error(self, ridx, errmsg):