diff --git a/NEWS b/NEWS
index 9008e33f35090d7476a287028d954a2f36864448..6b070e6c1cc7afe7222bf3dda70d160a7ac603b9 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,11 @@
 This file describes changes in recent versions of SLURM. It primarily
 documents those changes that are of interest to users and admins. 
 
+* Changes in SLURM 0.5.0-pre20
+==============================
+ -- Fix race condition in job accouting plugin, could hang slurmd
+ -- Report SlurmUser id over 16 bits as an error (fix on v0.6)
+
 * Changes in SLURM 0.5.0-pre19
 ==============================
  -- Fix memory management bug in federation driver
diff --git a/src/plugins/jobacct/log/jobacct_log.c b/src/plugins/jobacct/log/jobacct_log.c
index 6d8e2f9839afc5c82638f38465ae6811abdf3a98..ef8cb2ba05d63967910153b6fd09af95440a9814 100644
--- a/src/plugins/jobacct/log/jobacct_log.c
+++ b/src/plugins/jobacct/log/jobacct_log.c
@@ -738,6 +738,7 @@ int slurmd_jobacct_task_exit(slurmd_job_t *job, pid_t pid, int status, struct ru
 	if (prec_frequency) {	/* if dynamic monitoring */
 		slurm_mutex_lock(&precTable_lock); /* let watcher finish loop */
 		pthread_cancel(_watch_tasks_thread_id); 
+		pthread_join(_watch_tasks_thread_id,NULL);
 		slurm_mutex_unlock(&precTable_lock);
 		jrec->max_psize			= max_psize;
 		jrec->max_vsize			= max_vsize;
@@ -1585,10 +1586,15 @@ static int _unpack_jobrec(_jrec_t *outrec, _jrec_t *inrec) {
 
 static void *_watch_tasks(void *arg) {
 
+	int	tmp;
+
 	while(1) {	/* Do this until slurm_jobacct_task_exit() stops us */
 		sleep(prec_frequency);
+		pthread_testcancel();
 		slurm_mutex_lock(&precTable_lock);
+		pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &tmp);
 		_get_process_data();	/* Update the data */ 
 		slurm_mutex_unlock(&precTable_lock);
+		pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &tmp);
 	} 
 }