From b682c589f4175888946798c7aaa2440684ff1c6b Mon Sep 17 00:00:00 2001 From: Ludwig Krispenz Date: Fri, 26 Jan 2018 15:34:32 +0100 Subject: [PATCH] do not write changlog RUV in online backup --- ldap/servers/plugins/replication/cl5_api.c | 178 ------------------------- ldap/servers/plugins/replication/cl5_api.h | 13 -- ldap/servers/plugins/replication/repl5_init.c | 9 +- ldap/servers/slapd/back-ldbm/archive.c | 2 - ldap/servers/slapd/pblock.c | 24 ---- ldap/servers/slapd/plugin.c | 6 +- ldap/servers/slapd/slapi-plugin.h | 2 - test/libslapd/pblock/pblock_accessors.txt | 2 - test/libslapd/pblock/pblock_accessors_freq.txt | 4 - 9 files changed, 4 insertions(+), 236 deletions(-) diff --git a/ldap/servers/plugins/replication/cl5_api.c b/ldap/servers/plugins/replication/cl5_api.c index 89ae995..35883f7 100644 --- a/ldap/servers/plugins/replication/cl5_api.c +++ b/ldap/servers/plugins/replication/cl5_api.c @@ -6306,184 +6306,6 @@ cl5DbDirIsEmpty(const char *dir) } /* - * Write RUVs into the changelog; - * implemented for backup to make sure the backed up changelog contains RUVs - * Return values: 0 -- success - * 1 -- failure - */ -int -cl5WriteRUV() -{ - int rc = 0; - Object *file_obj = NULL; - CL5DBFile *dbfile = NULL; - int closeit = 0; - int slapd_pid = 0; - - changelog5Config config; - - /* read changelog configuration */ - changelog5_read_config(&config); - if (config.dir == NULL) { - /* Changelog is not configured; Replication is not enabled. - * we don't have to update RUVs. - * bail out - return success */ - goto bail; - } - - slapd_pid = is_slapd_running(); - if (slapd_pid <= 0) { - /* I'm not a server, rather a utility. - * And the server is NOT running. - * RUVs should be in the changelog. - * we don't have to update RUVs. - * bail out - return success */ - goto bail; - } - - if (getpid() != slapd_pid) { - /* I'm not a server, rather a utility. - * And the server IS running. - * RUVs are not in the changelog and no easy way to retrieve them. - * bail out - return failure */ - slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name_cl, - "cl5WriteRUV - server (pid %d) is already running; bail.\n", - slapd_pid); - rc = 1; - goto bail; - } - - /* file is stored in the changelog directory and is named - * .ldif */ - if (CL5_STATE_OPEN != s_cl5Desc.dbState) { - rc = _cl5Open(config.dir, &config.dbconfig, CL5_OPEN_NORMAL); - if (rc != CL5_SUCCESS) { - slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name_cl, - "cl5WriteRUV - Failed to open changelog\n"); - goto bail; - } - s_cl5Desc.dbState = CL5_STATE_OPEN; /* force to change the state */ - closeit = 1; /* It had not been opened; close it */ - } - - file_obj = objset_first_obj(s_cl5Desc.dbFiles); - while (file_obj) { - dbfile = (CL5DBFile *)object_get_data(file_obj); - if (dbfile) { - _cl5WriteEntryCount(dbfile); - _cl5WriteRUV(dbfile, PR_TRUE); - _cl5WriteRUV(dbfile, PR_FALSE); - } - file_obj = objset_next_obj(s_cl5Desc.dbFiles, file_obj); - } -bail: - if (closeit && (CL5_STATE_OPEN == s_cl5Desc.dbState)) { - _cl5Close(); - s_cl5Desc.dbState = CL5_STATE_CLOSED; /* force to change the state */ - } - changelog5_config_done(&config); - return rc; -} - -/* - * Delete RUVs from the changelog; - * implemented for backup to clean up RUVs - * Return values: 0 -- success - * 1 -- failure - */ -int -cl5DeleteRUV() -{ - int rc = 0; - Object *file_obj = NULL; - CL5DBFile *dbfile = NULL; - int slapd_pid = 0; - int closeit = 0; - - changelog5Config config; - - /* read changelog configuration */ - changelog5_read_config(&config); - if (config.dir == NULL) { - /* Changelog is not configured; Replication is not enabled. - * we don't have to update RUVs. - * bail out - return success */ - goto bail; - } - - slapd_pid = is_slapd_running(); - if (slapd_pid <= 0) { - /* I'm not a server, rather a utility. - * And the server is NOT running. - * RUVs should be in the changelog. - * we don't have to update RUVs. - * bail out - return success */ - goto bail; - } - - if (getpid() != slapd_pid) { - /* I'm not a server, rather a utility. - * And the server IS running. - * RUVs are not in the changelog. - * bail out - return success */ - slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name_cl, - "cl5DeleteRUV - server (pid %d) is already running; bail.\n", - slapd_pid); - goto bail; - } - - /* file is stored in the changelog directory and is named - * .ldif */ - if (CL5_STATE_OPEN != s_cl5Desc.dbState) { - rc = _cl5Open(config.dir, &config.dbconfig, CL5_OPEN_NORMAL); - if (rc != CL5_SUCCESS) { - slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name_cl, - "cl5DeleteRUV - Failed to open changelog\n"); - goto bail; - } - s_cl5Desc.dbState = CL5_STATE_OPEN; /* force to change the state */ - closeit = 1; /* It had been opened; no need to close */ - } - - file_obj = objset_first_obj(s_cl5Desc.dbFiles); - while (file_obj) { - dbfile = (CL5DBFile *)object_get_data(file_obj); - - /* _cl5GetEntryCount deletes entry count after reading it */ - rc = _cl5GetEntryCount(dbfile); - if (rc != CL5_SUCCESS) { - slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name_cl, - "cl5DeleteRUV - Failed to get/delete entry count\n"); - goto bail; - } - /* _cl5ReadRUV deletes RUV after reading it */ - rc = _cl5ReadRUV(dbfile->replGen, file_obj, PR_TRUE); - if (rc != CL5_SUCCESS) { - slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name_cl, - "cl5DeleteRUV - Failed to read/delete purge RUV\n"); - goto bail; - } - rc = _cl5ReadRUV(dbfile->replGen, file_obj, PR_FALSE); - if (rc != CL5_SUCCESS) { - slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name_cl, - "cl5DeleteRUV - Failed to read/delete upper bound RUV\n"); - goto bail; - } - file_obj = objset_next_obj(s_cl5Desc.dbFiles, file_obj); - } -bail: - if (file_obj) { - object_release(file_obj); - } - if (closeit && (CL5_STATE_OPEN == s_cl5Desc.dbState)) { - _cl5Close(); - s_cl5Desc.dbState = CL5_STATE_CLOSED; /* force to change the state */ - } - changelog5_config_done(&config); - return rc; -} - -/* * Clean the in memory RUV, at shutdown we will write the update to the db */ void diff --git a/ldap/servers/plugins/replication/cl5_api.h b/ldap/servers/plugins/replication/cl5_api.h index 419dc2d..af06e41 100644 --- a/ldap/servers/plugins/replication/cl5_api.h +++ b/ldap/servers/plugins/replication/cl5_api.h @@ -435,19 +435,6 @@ int cl5_diskspace_is_available(void); */ int cl5DbDirIsEmpty(const char *dir); -/* Name: cl5WriteRUV - Description: Write RUVs into changelog db's. Called before backup. - Parameters: none - Return: TRUE -*/ -int cl5WriteRUV(void); - -/* Name: cl5DeleteRUV - Description: Read and delete RUVs from changelog db's. Called after backup. - Parameters: none - Return: TRUE -*/ -int cl5DeleteRUV(void); void cl5CleanRUV(ReplicaId rid); void cl5NotifyCleanup(int rid); void trigger_cl_purging(cleanruv_purge_data *purge_data); diff --git a/ldap/servers/plugins/replication/repl5_init.c b/ldap/servers/plugins/replication/repl5_init.c index 5badd7c..81c09b7 100644 --- a/ldap/servers/plugins/replication/repl5_init.c +++ b/ldap/servers/plugins/replication/repl5_init.c @@ -338,8 +338,7 @@ multimaster_bepreop_init(Slapi_PBlock *pb) if (slapi_pblock_set(pb, SLAPI_PLUGIN_VERSION, SLAPI_PLUGIN_VERSION_01) != 0 || slapi_pblock_set(pb, SLAPI_PLUGIN_DESCRIPTION, (void *)&multimasterbepreopdesc) != 0 || - slapi_pblock_set(pb, SLAPI_PLUGIN_BE_PRE_CLOSE_FN, (void *)cl5Close) != 0 || - slapi_pblock_set(pb, SLAPI_PLUGIN_BE_PRE_BACKUP_FN, (void *)cl5WriteRUV) != 0) { + slapi_pblock_set(pb, SLAPI_PLUGIN_BE_PRE_CLOSE_FN, (void *)cl5Close) != 0 ) { slapi_log_err(SLAPI_LOG_PLUGIN, repl_plugin_name, "multimaster_bepreop_init - Failed\n"); rc = -1; } @@ -387,8 +386,7 @@ multimaster_bepostop_init(Slapi_PBlock *pb) slapi_pblock_set(pb, SLAPI_PLUGIN_DESCRIPTION, (void *)&multimasterbepostopdesc) != 0 || slapi_pblock_set(pb, SLAPI_PLUGIN_BE_POST_MODRDN_FN, (void *)multimaster_bepostop_modrdn) != 0 || slapi_pblock_set(pb, SLAPI_PLUGIN_BE_POST_DELETE_FN, (void *)multimaster_bepostop_delete) != 0 || - slapi_pblock_set(pb, SLAPI_PLUGIN_BE_POST_OPEN_FN, (void *)changelog5_init) != 0 || - slapi_pblock_set(pb, SLAPI_PLUGIN_BE_POST_BACKUP_FN, (void *)cl5DeleteRUV) != 0) { + slapi_pblock_set(pb, SLAPI_PLUGIN_BE_POST_OPEN_FN, (void *)changelog5_init) != 0 ) { slapi_log_err(SLAPI_LOG_PLUGIN, repl_plugin_name, "multimaster_bepostop_init - Failed\n"); rc = -1; } @@ -408,8 +406,7 @@ multimaster_betxn_bepostop_init(Slapi_PBlock *pb) if (slapi_pblock_set(pb, SLAPI_PLUGIN_VERSION, SLAPI_PLUGIN_VERSION_01) || slapi_pblock_set(pb, SLAPI_PLUGIN_DESCRIPTION, (void *)&multimasterbepostopdesc) || - slapi_pblock_set(pb, SLAPI_PLUGIN_BE_POST_OPEN_FN, (void *)changelog5_init) || - slapi_pblock_set(pb, SLAPI_PLUGIN_BE_POST_BACKUP_FN, (void *)cl5DeleteRUV)) { + slapi_pblock_set(pb, SLAPI_PLUGIN_BE_POST_OPEN_FN, (void *)changelog5_init) ) { slapi_log_err(SLAPI_LOG_PLUGIN, repl_plugin_name, "multimaster_betxn_bepostop_init - Failed\n"); rc = -1; } diff --git a/ldap/servers/slapd/back-ldbm/archive.c b/ldap/servers/slapd/back-ldbm/archive.c index 4a9ce3d..8392a0e 100644 --- a/ldap/servers/slapd/back-ldbm/archive.c +++ b/ldap/servers/slapd/back-ldbm/archive.c @@ -410,7 +410,6 @@ ldbm_back_ldbm2archive(Slapi_PBlock *pb) } } - return_value = plugin_call_plugins(pb, SLAPI_PLUGIN_BE_PRE_BACKUP_FN); if (return_value) { slapi_log_err(SLAPI_LOG_BACKLDBM, "ldbm_back_ldbm2archive", "pre-backup-plugin failed (%d).\n", return_value); @@ -426,7 +425,6 @@ ldbm_back_ldbm2archive(Slapi_PBlock *pb) /* tell it to archive */ return_value = dblayer_backup(li, directory, task); - return_value = plugin_call_plugins(pb, SLAPI_PLUGIN_BE_POST_BACKUP_FN); if (return_value) { slapi_log_err(SLAPI_LOG_BACKLDBM, "ldbm_back_ldbm2archive", "post-backup-plugin failed (%d).\n", return_value); diff --git a/ldap/servers/slapd/pblock.c b/ldap/servers/slapd/pblock.c index 4514c3c..23dccc1 100644 --- a/ldap/servers/slapd/pblock.c +++ b/ldap/servers/slapd/pblock.c @@ -1232,12 +1232,6 @@ slapi_pblock_get(Slapi_PBlock *pblock, int arg, void *value) } (*(IFP *)value) = pblock->pb_plugin->plg_bepreclose; break; - case SLAPI_PLUGIN_BE_PRE_BACKUP_FN: - if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_BEPREOPERATION) { - return (-1); - } - (*(IFP *)value) = pblock->pb_plugin->plg_beprebackup; - break; /* backend postoperation plugin */ case SLAPI_PLUGIN_BE_POST_MODIFY_FN: @@ -1270,12 +1264,6 @@ slapi_pblock_get(Slapi_PBlock *pblock, int arg, void *value) } (*(IFP *)value) = pblock->pb_plugin->plg_bepostopen; break; - case SLAPI_PLUGIN_BE_POST_BACKUP_FN: - if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_BEPOSTOPERATION) { - return (-1); - } - (*(IFP *)value) = pblock->pb_plugin->plg_bepostbackup; - break; /* internal preoperation plugin */ case SLAPI_PLUGIN_INTERNAL_PRE_MODIFY_FN: @@ -3127,12 +3115,6 @@ slapi_pblock_set(Slapi_PBlock *pblock, int arg, void *value) } pblock->pb_plugin->plg_bepreclose = (IFP)value; break; - case SLAPI_PLUGIN_BE_PRE_BACKUP_FN: - if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_BEPREOPERATION) { - return (-1); - } - pblock->pb_plugin->plg_beprebackup = (IFP)value; - break; /* backend postoperation plugin */ case SLAPI_PLUGIN_BE_POST_MODIFY_FN: @@ -3165,12 +3147,6 @@ slapi_pblock_set(Slapi_PBlock *pblock, int arg, void *value) } pblock->pb_plugin->plg_bepostopen = (IFP)value; break; - case SLAPI_PLUGIN_BE_POST_BACKUP_FN: - if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_BEPOSTOPERATION) { - return (-1); - } - pblock->pb_plugin->plg_bepostbackup = (IFP)value; - break; /* internal preoperation plugin */ case SLAPI_PLUGIN_INTERNAL_PRE_MODIFY_FN: diff --git a/ldap/servers/slapd/plugin.c b/ldap/servers/slapd/plugin.c index 2db3c7f..a9566f5 100644 --- a/ldap/servers/slapd/plugin.c +++ b/ldap/servers/slapd/plugin.c @@ -378,7 +378,6 @@ plugin_call_plugins(Slapi_PBlock *pb, int whichfunction) case SLAPI_PLUGIN_BE_PRE_ADD_FN: case SLAPI_PLUGIN_BE_PRE_DELETE_FN: case SLAPI_PLUGIN_BE_PRE_CLOSE_FN: - case SLAPI_PLUGIN_BE_PRE_BACKUP_FN: plugin_list_number = PLUGIN_LIST_BEPREOPERATION; do_op = 1; /* always allow backend callbacks (even during startup) */ break; @@ -387,7 +386,6 @@ plugin_call_plugins(Slapi_PBlock *pb, int whichfunction) case SLAPI_PLUGIN_BE_POST_ADD_FN: case SLAPI_PLUGIN_BE_POST_DELETE_FN: case SLAPI_PLUGIN_BE_POST_OPEN_FN: - case SLAPI_PLUGIN_BE_POST_BACKUP_FN: plugin_list_number = PLUGIN_LIST_BEPOSTOPERATION; do_op = 1; /* always allow backend callbacks (even during startup) */ break; @@ -3619,9 +3617,7 @@ plugin_invoke_plugin_pb(struct slapdplugin *plugin, int operation, Slapi_PBlock operation == SLAPI_PLUGIN_CLOSE_FN || operation == SLAPI_PLUGIN_CLEANUP_FN || operation == SLAPI_PLUGIN_BE_PRE_CLOSE_FN || - operation == SLAPI_PLUGIN_BE_POST_OPEN_FN || - operation == SLAPI_PLUGIN_BE_PRE_BACKUP_FN || - operation == SLAPI_PLUGIN_BE_POST_BACKUP_FN) + operation == SLAPI_PLUGIN_BE_POST_OPEN_FN ) return PR_TRUE; slapi_pblock_get(pb, SLAPI_OPERATION, &pb_op); diff --git a/ldap/servers/slapd/slapi-plugin.h b/ldap/servers/slapd/slapi-plugin.h index 4566202..fe9b865 100644 --- a/ldap/servers/slapd/slapi-plugin.h +++ b/ldap/servers/slapd/slapi-plugin.h @@ -7071,7 +7071,6 @@ typedef struct slapi_plugindesc #define SLAPI_PLUGIN_BE_PRE_MODRDN_FN 452 #define SLAPI_PLUGIN_BE_PRE_DELETE_FN 453 #define SLAPI_PLUGIN_BE_PRE_CLOSE_FN 454 -#define SLAPI_PLUGIN_BE_PRE_BACKUP_FN 455 /* preoperation plugin to the backend - just after transaction creation */ #define SLAPI_PLUGIN_BE_TXN_PRE_ADD_FN 460 @@ -7108,7 +7107,6 @@ typedef struct slapi_plugindesc #define SLAPI_PLUGIN_BE_POST_MODRDN_FN 552 #define SLAPI_PLUGIN_BE_POST_DELETE_FN 553 #define SLAPI_PLUGIN_BE_POST_OPEN_FN 554 -#define SLAPI_PLUGIN_BE_POST_BACKUP_FN 555 /* postoperation plugin to the backend - just before transaction commit */ #define SLAPI_PLUGIN_BE_TXN_POST_ADD_FN 560 diff --git a/test/libslapd/pblock/pblock_accessors.txt b/test/libslapd/pblock/pblock_accessors.txt index 93e4864..facb3cb 100644 --- a/test/libslapd/pblock/pblock_accessors.txt +++ b/test/libslapd/pblock/pblock_accessors.txt @@ -109,13 +109,11 @@ SLAPI_PLUGIN_ACL_SYNTAX_CHECK SLAPI_PLUGIN_ARGC SLAPI_PLUGIN_ARGV SLAPI_PLUGIN_BE_POST_ADD_FN -SLAPI_PLUGIN_BE_POST_BACKUP_FN SLAPI_PLUGIN_BE_POST_DELETE_FN SLAPI_PLUGIN_BE_POST_MODIFY_FN SLAPI_PLUGIN_BE_POST_MODRDN_FN SLAPI_PLUGIN_BE_POST_OPEN_FN SLAPI_PLUGIN_BE_PRE_ADD_FN -SLAPI_PLUGIN_BE_PRE_BACKUP_FN SLAPI_PLUGIN_BE_PRE_CLOSE_FN SLAPI_PLUGIN_BE_PRE_DELETE_FN SLAPI_PLUGIN_BE_PRE_MODIFY_FN diff --git a/test/libslapd/pblock/pblock_accessors_freq.txt b/test/libslapd/pblock/pblock_accessors_freq.txt index e332d9b..6b405c2 100644 --- a/test/libslapd/pblock/pblock_accessors_freq.txt +++ b/test/libslapd/pblock/pblock_accessors_freq.txt @@ -220,8 +220,6 @@ SLAPI_PLUGIN_ARGV 21 SLAPI_PLUGIN_BE_POST_ADD_FN 12 -SLAPI_PLUGIN_BE_POST_BACKUP_FN -12 SLAPI_PLUGIN_BE_POST_DELETE_FN 13 SLAPI_PLUGIN_BE_POST_MODIFY_FN @@ -232,8 +230,6 @@ SLAPI_PLUGIN_BE_POST_OPEN_FN 12 SLAPI_PLUGIN_BE_PRE_ADD_FN 14 -SLAPI_PLUGIN_BE_PRE_BACKUP_FN -11 SLAPI_PLUGIN_BE_PRE_CLOSE_FN 11 SLAPI_PLUGIN_BE_PRE_DELETE_FN -- 2.9.5