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

Make it so MySQL can deal with potential duplicate entries in the job table

which will be changing it's unique index in a following commit.
parent e12b03bd
No related branches found
No related tags found
No related merge requests found
...@@ -272,12 +272,11 @@ static int _mysql_make_table_current(mysql_conn_t *mysql_conn, char *table_name, ...@@ -272,12 +272,11 @@ static int _mysql_make_table_current(mysql_conn_t *mysql_conn, char *table_name,
itr = list_iterator_create(columns); itr = list_iterator_create(columns);
/* In MySQL 5.7.4 we lost the ability to run 'alter ignore'. This was /* In MySQL 5.7.4 we lost the ability to run 'alter ignore'. This was
* needed when converting old tables to new schemas. If people convert * needed when converting old tables to new schemas. We found a back
* in the future from an older version of Slurm that needed the ignore * door for this with set session old_alter_table=1 which we use below.
* to work they will have to downgrade mysql to <= 5.7.3 to make things * This seems to work just fine and we get what we are looking for.
* work correctly or manually edit the database to get things to work.
*/ */
query = xstrdup_printf("alter table %s", table_name); query = xstrdup_printf("alter IGNORE table %s", table_name);
correct_query = xstrdup(query); correct_query = xstrdup(query);
START_TIMER; START_TIMER;
while (fields[i].name) { while (fields[i].name) {
...@@ -459,6 +458,7 @@ static int _mysql_make_table_current(mysql_conn_t *mysql_conn, char *table_name, ...@@ -459,6 +458,7 @@ static int _mysql_make_table_current(mysql_conn_t *mysql_conn, char *table_name,
query[strlen(query)-1] = ';'; query[strlen(query)-1] = ';';
correct_query[strlen(correct_query)-1] = ';'; correct_query[strlen(correct_query)-1] = ';';
//info("%d query\n%s", __LINE__, query); //info("%d query\n%s", __LINE__, query);
/* see if we have already done this definition */ /* see if we have already done this definition */
...@@ -503,10 +503,15 @@ static int _mysql_make_table_current(mysql_conn_t *mysql_conn, char *table_name, ...@@ -503,10 +503,15 @@ static int _mysql_make_table_current(mysql_conn_t *mysql_conn, char *table_name,
debug4("Table %s doesn't exist, adding", table_name); debug4("Table %s doesn't exist, adding", table_name);
else else
debug("Table %s has changed. Updating...", table_name); debug("Table %s has changed. Updating...", table_name);
if (mysql_db_query(mysql_conn, query)) { query2 = xstrdup_printf("set session old_alter_table=1;"
xfree(query); "%s set session old_alter_table=0;",
query);
xfree(query);
if (mysql_db_query(mysql_conn, query2)) {
xfree(query2);
return SLURM_ERROR; return SLURM_ERROR;
} }
xfree(query2);
quoted = slurm_add_slash_to_quotes(correct_query); quoted = slurm_add_slash_to_quotes(correct_query);
query2 = xstrdup_printf("insert into %s (creation_time, " query2 = xstrdup_printf("insert into %s (creation_time, "
"mod_time, table_name, definition) " "mod_time, table_name, definition) "
......
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