From 94b279a8629c3422e35eb62cecb916308504a4c2 Mon Sep 17 00:00:00 2001 From: motodiary Date: Tue, 21 May 2024 15:02:14 +0800 Subject: [PATCH] add SQLRowCount exception handling --- 0022-add-SQLRowCount-exception-handling.patch | 134 ++++++++++++++++++ slurm.spec | 6 +- 2 files changed, 139 insertions(+), 1 deletion(-) create mode 100644 0022-add-SQLRowCount-exception-handling.patch diff --git a/0022-add-SQLRowCount-exception-handling.patch b/0022-add-SQLRowCount-exception-handling.patch new file mode 100644 index 0000000..779c372 --- /dev/null +++ b/0022-add-SQLRowCount-exception-handling.patch @@ -0,0 +1,134 @@ +From e80c81b0adc9ae110a231c18e22a1193daaf8c8d Mon Sep 17 00:00:00 2001 +From: motodiary +Date: Tue, 21 May 2024 14:59:27 +0800 +Subject: [PATCH] add SQLRowCount exception handling + +--- + src/database/pgsql_common.c | 11 ++++++-- + .../pgsql/accounting_storage_pgsql.c | 27 ++++++++++--------- + .../accounting_storage/pgsql/as_pgsql_job.c | 7 ++--- + 3 files changed, 27 insertions(+), 18 deletions(-) + +diff --git a/src/database/pgsql_common.c b/src/database/pgsql_common.c +index 49d4191..cf5b78b 100755 +--- a/src/database/pgsql_common.c ++++ b/src/database/pgsql_common.c +@@ -1171,8 +1171,15 @@ extern pgsql_res_t* pgsql_db_query_ret(pgsql_conn_t *pgsql_conn, + } + + SQLNumResultCols(result->stmt, &result->sNumCols); +- SQLRowCount(result->stmt, &result->sNumRows); +- if (result->sNumRows) { ++ SQLRETURN rc = SQLRowCount(result->stmt, &result->sNumRows); ++ if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) { ++ SQLCHAR state[PGSQL_STATE_LEN + 1]; ++ PGSQL_HANDLE_ERROR("SQLRowCount", rc, SQL_HANDLE_STMT, result->stmt, state); ++ pgsql_free_result(&result); ++ goto fini; ++ } ++ ++ if (result->sNumRows > 0) { + result->rows = (pgsql_row*)malloc(result->sNumRows * sizeof(pgsql_row)); + if(result->rows == NULL) { + pgsql_free_result(&result); +diff --git a/src/plugins/accounting_storage/pgsql/accounting_storage_pgsql.c b/src/plugins/accounting_storage/pgsql/accounting_storage_pgsql.c +index 34a5159..1bcb2df 100755 +--- a/src/plugins/accounting_storage/pgsql/accounting_storage_pgsql.c ++++ b/src/plugins/accounting_storage/pgsql/accounting_storage_pgsql.c +@@ -781,8 +781,9 @@ static int _as_pgsql_acct_check_tables(pgsql_conn_t *pgsql_conn) + ending = xstrdup_printf(", primary key (id)); CREATE UNIQUE INDEX IF NOT EXISTS %s_udx ON %s " + "(\"type\", \"name\");", tres_table, tres_table); + xstrfmtcat(ending, "CREATE SEQUENCE IF NOT EXISTS %s_id_seq MINVALUE 1001 START WITH 1001;" ++ "ALTER SEQUENCE %s_id_seq RESTART WITH 1001;" + "ALTER TABLE %s ALTER COLUMN id SET DEFAULT nextval('%s_id_seq'::regclass);", +- tres_table, tres_table, tres_table); ++ tres_table, tres_table, tres_table, tres_table); + + if (pgsql_db_create_table(pgsql_conn, tres_table, tres_table_fields, ending) + == SLURM_ERROR) { +@@ -1209,30 +1210,30 @@ extern int create_cluster_tables(pgsql_conn_t *pgsql_conn, char *cluster_name) + { "account", "text", "" }, + { "admin_comment", "text", "" }, + { "array_task_str", "text", "" }, +- { "array_max_tasks", "integer", "default 0|not null" }, +- { "array_task_pending", "integer", "default 0|not null" }, ++ { "array_max_tasks", "bigint", "default 0|not null" }, ++ { "array_task_pending", "bigint", "default 0|not null" }, + { "batch_script", "text", "" }, + { "constraints", "text", "default ''" }, + { "container", "text", "" }, +- { "cpus_req", "integer", "not null" }, +- { "derived_ec", "integer", "default 0|not null" }, ++ { "cpus_req", "bigint", "not null" }, ++ { "derived_ec", "bigint", "default 0|not null" }, + { "derived_es", "text", "" }, + { "env_vars", "text", "" }, + { "exit_code", "integer", "default 0|not null" }, + { "flags", "integer", "default 0|not null" }, + { "job_name", "varchar", "not null" }, + { "id_assoc", "integer", "not null" }, +- { "id_array_job", "integer", "default 0|not null" }, +- { "id_array_task", "integer", "default 4294967294|not null" }, ++ { "id_array_job", "bigint", "default 0|not null" }, ++ { "id_array_task", "bigint", "default 4294967294|not null" }, + { "id_block", "varchar", "" }, +- { "id_job", "integer", "not null" }, ++ { "id_job", "bigint", "not null" }, + { "id_qos", "integer", "default 0|not null" }, +- { "id_resv", "integer", "not null" }, +- { "id_wckey", "integer", "not null" }, ++ { "id_resv", "bigint", "not null" }, ++ { "id_wckey", "integer", "default 0|not null" }, + { "id_user", "integer", "not null" }, + { "id_group", "integer", "not null" }, +- { "het_job_id", "integer", "not null" }, +- { "het_job_offset", "integer", "not null" }, ++ { "het_job_id", "bigint", "not null" }, ++ { "het_job_offset", "bigint", "not null" }, + { "kill_requid", "integer", "default -1|not null" }, + { "state_reason_prev", "integer", "not null" }, + { "mcs_label", "varchar", "default ''" }, +@@ -1243,7 +1244,7 @@ extern int create_cluster_tables(pgsql_conn_t *pgsql_conn, char *cluster_name) + { "partition", "varchar", "not null" }, + { "priority", "integer", "not null" }, + { "state", "integer", "not null" }, +- { "timelimit", "integer", "default 0|not null" }, ++ { "timelimit", "bigint", "default 0|not null" }, + { "time_submit", "bigint", "default 0|not null" }, + { "time_eligible", "bigint", "default 0|not null" }, + { "time_start", "bigint", "default 0|not null" }, +diff --git a/src/plugins/accounting_storage/pgsql/as_pgsql_job.c b/src/plugins/accounting_storage/pgsql/as_pgsql_job.c +index 7d734e0..038d667 100755 +--- a/src/plugins/accounting_storage/pgsql/as_pgsql_job.c ++++ b/src/plugins/accounting_storage/pgsql/as_pgsql_job.c +@@ -275,7 +275,7 @@ static uint32_t _get_wckeyid(pgsql_conn_t *pgsql_conn, char **name, + FREE_NULL_LIST(wckey_list); + } + xfree(user); +- /* info("got wckeyid of %d", wckey_rec.id); */ ++ debug4("got wckeyid of %d", wckey_rec.id); + wckeyid = wckey_rec.id; + } + no_wckeyid: +@@ -587,7 +587,7 @@ no_rollup_change: + "time_submit=%ld, time_eligible=%ld, " + "time_start=%ld, mod_time=floor(extract(epoch from now())), " + "job_name='%s', track_steps=%u, id_qos=%u, " +- "state=GREATEST(state, %u), priority=%u, " ++ "state=GREATEST(%s_%s.state, %u), priority=%u, " + "cpus_req=%u, nodes_alloc=%u, " + "mem_req=%"PRIu64", id_array_job=%u, id_array_task=%u, " + "het_job_id=%u, het_job_offset=%u, flags=%u, " +@@ -597,7 +597,8 @@ no_rollup_change: + job_ptr->group_id, nodes, + job_ptr->resv_id, job_ptr->time_limit, + submit_time, begin_time, start_time, +- jname, track_steps, job_ptr->qos_id, job_state, ++ jname, track_steps, job_ptr->qos_id, ++ pgsql_conn->cluster_name, job_table, job_state, + job_ptr->priority, job_ptr->details->min_cpus, + job_ptr->total_nodes, + job_ptr->details->pn_min_memory, +-- +2.33.0 + diff --git a/slurm.spec b/slurm.spec index 114f6a5..1cd9e96 100644 --- a/slurm.spec +++ b/slurm.spec @@ -1,6 +1,6 @@ Name: slurm Version: 21.08.8 -%define rel 24 +%define rel 25 Release: %{rel}%{?dist} Summary: Slurm Workload Manager @@ -37,6 +37,7 @@ Patch18: 0018-update-get_parent_limits-stored-procedure.patch Patch19: 0019-Adjusting-some-SQL-statements.patch Patch20: 0020-replace-UNIX_TIMESTAMP-in-sql.patch Patch21: 0021-fix-user-and-partition-field-in-sql.patch +Patch22: 0022-add-SQLRowCount-exception-handling.patch # build options .rpmmacros options change to default action # ==================== ==================== ======================== @@ -729,6 +730,9 @@ rm -rf %{buildroot} %systemd_postun_with_restart slurmdbd.service %changelog +* Tue May 21 2024 Xing Liu - 21.08.8-25 +- add SQLRowCount exception handling + * Tue May 21 2024 Xing Liu - 21.08.8-24 - fix 'user' and 'partition' field in sql -- Gitee