From cd908573c0cff3eebac919e8829af8fd73aad013 Mon Sep 17 00:00:00 2001 From: Thierry Bordaz Date: Feb 01 2019 14:42:54 +0000 Subject: Ticket 50177 - import task should not be deleted too rapidely after import finishes to be able to query the status Bug Description: scripts that create online import and export tasks do not define a Time To Life of the tasks. As a consequence the task entry is cleared 2min (default value) after task completion. This is too rapid and some admin scripts may miss the final task status. Fix Description: The fix is to keep the entry of completed online import and export tasks for 1 day. It also allows defines a default TTL to 1h (instead of 2min) https://pagure.io/389-ds-base/issue/50177 Reviewed by: Platforms tested: F27 Flag Day: no Doc impact: no --- diff --git a/ldap/admin/src/scripts/db2ldif.pl.in b/ldap/admin/src/scripts/db2ldif.pl.in index 0d220f0..f7d12b4 100644 --- a/ldap/admin/src/scripts/db2ldif.pl.in +++ b/ldap/admin/src/scripts/db2ldif.pl.in @@ -241,7 +241,8 @@ if ($decrypt_on_export != 0) { $nsexportdecrypt = "nsExportDecrypt: true\n"; } $nsprintkey = ""; if ($printkey == 0) { $nsprintkey = "nsPrintKey: false\n"; } $nsldiffile = "nsFilename: ${ldiffile}\n"; -$entry = "${dn}${misc}${cn}${nsinstance}${nsincluded}${nsexcluded}${nsreplica}${nsnobase64}${nsnowrap}${nsnoversion}${nsnouniqueid}${nsuseid2entry}${nsonefile}${nsexportdecrypt}${nsprintkey}${nsldiffile}"; +$ttl = "ttl: 86400"; +$entry = "${dn}${misc}${cn}${nsinstance}${nsincluded}${nsexcluded}${nsreplica}${nsnobase64}${nsnowrap}${nsnoversion}${nsnouniqueid}${nsuseid2entry}${nsonefile}${nsexportdecrypt}${nsprintkey}${nsldiffile}${ttl}"; print("Exporting to ldif file: ${ldiffile}\n"); $rc = DSUtil::ldapmod($entry, %info); diff --git a/ldap/admin/src/scripts/ldif2db.pl.in b/ldap/admin/src/scripts/ldif2db.pl.in index a5d834f..486dcd0 100644 --- a/ldap/admin/src/scripts/ldif2db.pl.in +++ b/ldap/admin/src/scripts/ldif2db.pl.in @@ -192,7 +192,8 @@ $nsmergechunksiz = "nsImportChunkSize: ${mergechunksiz}\n"; $nsgenuniqid = "nsUniqueIdGenerator: ${genuniqid}\n"; $nsuniqidname = ""; if ($uniqidname ne "") { $nsuniqidname = "nsUniqueIdGeneratorNamespace: ${uniqidname}\n"; } -$entry = "${dn}${misc}${cn}${nsinstance}${nsincluded}${nsexcluded}${nsldiffiles}${nsnoattrindexes}${nsimportencrypt}${nsmergechunksiz}${nsgenuniqid}${nsuniqidname}"; +$ttl = "ttl: 86400"; +$entry = "${dn}${misc}${cn}${nsinstance}${nsincluded}${nsexcluded}${nsldiffiles}${nsnoattrindexes}${nsimportencrypt}${nsmergechunksiz}${nsgenuniqid}${nsuniqidname}${ttl}"; $rc = DSUtil::ldapmod($entry, %info); diff --git a/ldap/servers/slapd/task.c b/ldap/servers/slapd/task.c index b145176..8741570 100644 --- a/ldap/servers/slapd/task.c +++ b/ldap/servers/slapd/task.c @@ -46,7 +46,7 @@ static int shutting_down = 0; #define TASK_PROGRESS_NAME "nsTaskCurrentItem" #define TASK_WORK_NAME "nsTaskTotalItems" -#define DEFAULT_TTL "120" /* seconds */ +#define DEFAULT_TTL "3600" /* seconds */ #define TASK_SYSCONFIG_FILE_ATTR "sysconfigfile" /* sysconfig reload task file attr */ #define TASK_SYSCONFIG_LOGCHANGES_ATTR "logchanges" #define TASK_TOMBSTONE_FIXUP "fixup tombstones task" @@ -381,8 +381,8 @@ slapi_task_status_changed(Slapi_Task *task) if (e == NULL) return; ttl = atoi(slapi_fetch_attr(e, "ttl", DEFAULT_TTL)); - if (ttl > 3600) - ttl = 3600; /* be reasonable. */ + if (ttl > (24*3600)) + ttl = (24*3600); /* be reasonable, allow to check task status not longer than one day */ expire = time(NULL) + ttl; task->task_flags |= SLAPI_TASK_DESTROYING; /* queue an event to destroy the state info */