Skip to content
Snippets Groups Projects
Commit 12794fb0 authored by Danny Auble's avatar Danny Auble
Browse files

MYSQL - Add dynamic_offset in the database to force range for auto

increment ids for the tres_table.

Bug 4553

Turns out auto_increment=# doesn't work in MySQL at the time of writing
but does work correctly in MariaDB >=10.2.4+

See bug for more information.
parent 022fa1f8
No related branches found
No related tags found
No related merge requests found
......@@ -18,6 +18,8 @@ documents those changes that are of interest to users and administrators.
-- Add support in salloc/srun --bb option for "access_mode" in addition to
"access" for consistency with DW options.
-- Fix potential deadlock in _run_prog() in power save code.
-- MYSQL - Add dynamic_offset in the database to force range for auto
increment ids for the tres_table.
* Changes in Slurm 17.02.9
==========================
......
......@@ -846,19 +846,25 @@ static int _as_mysql_acct_check_tables(mysql_conn_t *mysql_conn)
it now. We also add MEM here, the others tres
are site specific and could vary. None but CPU
matter on order though. CPU always has to be 1.
TRES_OFFSET is needed since there's no way to force
the number of first automatic id in MySQL. auto_increment
value is lost on mysqld restart. Bug 4553.
*/
query = xstrdup_printf(
"insert into %s (creation_time, id, type) values "
"(%ld, %d, 'cpu'), "
"(%ld, %d, 'mem'), "
"(%ld, %d, 'energy'), "
"(%ld, %d, 'node') "
"on duplicate key update deleted=0, type=VALUES(type);",
"insert into %s (creation_time, id, deleted, type) values "
"(%ld, %d, 0, 'cpu'), "
"(%ld, %d, 0, 'mem'), "
"(%ld, %d, 0, 'energy'), "
"(%ld, %d, 0, 'node') "
"(%ld, %d, 1, 'dynamic_offset') "
"on duplicate key update deleted=VALUES(deleted), type=VALUES(type);",
tres_table,
now, TRES_CPU,
now, TRES_MEM,
now, TRES_ENERGY,
now, TRES_NODE);
now, TRES_NODE,
now, TRES_OFFSET);
if (debug_flags & DEBUG_FLAG_DB_QOS)
DB_DEBUG(mysql_conn->conn, "%s", query);
rc = mysql_db_query(mysql_conn, query);
......
......@@ -57,6 +57,20 @@
#define debug4 slurm_debug4
#define debug5 slurm_debug5
/*
* Allow up to 999 static TRES
* NOTE: If this changes for some reason you will also need to update the 1001
* in accounting_storage_mysql.c...
*
* if (mysql_db_create_table(mysql_conn, tres_table,
* tres_table_fields,
* ", primary key (id), "
* "unique index (type(20), name(20))) "
* "auto_increment=1001")
*
*/
#define TRES_OFFSET 1000
#include "src/common/assoc_mgr.h"
#include "src/common/macros.h"
#include "src/common/slurmdbd_defs.h"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment