From f03438c682d978901a08b400773694d53584643f Mon Sep 17 00:00:00 2001
From: Moe Jette <jette1@llnl.gov>
Date: Wed, 17 Sep 2003 00:39:00 +0000
Subject: [PATCH] Backup controller clears its record of active jobs before
 assuming control. Without doing so, its internal record of jobs from its last
 period of activity are resurrected.

---
 src/slurmctld/backup.c        | 2 ++
 src/slurmctld/job_mgr.c       | 4 +++-
 src/slurmctld/node_mgr.c      | 4 +++-
 src/slurmctld/partition_mgr.c | 5 ++++-
 4 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/slurmctld/backup.c b/src/slurmctld/backup.c
index 8dd8bef7227..cc2eebe512f 100644
--- a/src/slurmctld/backup.c
+++ b/src/slurmctld/backup.c
@@ -125,6 +125,8 @@ void run_backup(void)
 	pthread_kill(slurmctld_config.thread_id_sig, SIGTERM);
 	pthread_join(slurmctld_config.thread_id_sig, NULL);
 
+	/* clear old state and read new state */
+	job_fini();
 	if (read_slurm_conf(1))	/* Recover all state */
 		fatal("Unable to recover slurm state");
 	slurmctld_config.shutdown_time = (time_t) 0;
diff --git a/src/slurmctld/job_mgr.c b/src/slurmctld/job_mgr.c
index d6d2d2adaaa..143d1afd0fe 100644
--- a/src/slurmctld/job_mgr.c
+++ b/src/slurmctld/job_mgr.c
@@ -3115,8 +3115,10 @@ bool job_epilog_complete(uint32_t job_id, char *node_name,
 /* job_fini - free all memory associated with job records */
 void job_fini (void) 
 {
-	if (job_list)
+	if (job_list) {
 		list_destroy(job_list);
+		job_list = NULL;
+	}
 	xfree(job_hash);
 	xfree(job_hash_over);
 }
diff --git a/src/slurmctld/node_mgr.c b/src/slurmctld/node_mgr.c
index d27efb20935..48e6731e39c 100644
--- a/src/slurmctld/node_mgr.c
+++ b/src/slurmctld/node_mgr.c
@@ -1541,8 +1541,10 @@ void make_node_idle(struct node_record *node_ptr,
 /* node_fini - free all memory associated with node records */
 void node_fini(void)
 {
-	if (config_list)
+	if (config_list) {
 		list_destroy(config_list);
+		config_list = NULL;
+	}
 	xfree(node_record_table_ptr);
 	xfree(node_hash_table);
 }
diff --git a/src/slurmctld/partition_mgr.c b/src/slurmctld/partition_mgr.c
index 5bc4e3c2082..052a4e69618 100644
--- a/src/slurmctld/partition_mgr.c
+++ b/src/slurmctld/partition_mgr.c
@@ -923,6 +923,9 @@ static int _uid_list_size(uid_t * uid_list_ptr)
 /* part_fini - free all memory associated with partition records */
 void part_fini (void) 
 {
-	if (part_list)
+	if (part_list) {
 		list_destroy(part_list);
+		part_list = NULL;
+	}
+	default_part_loc = (struct part_record *) NULL;
 }
-- 
GitLab