Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 150172 Details for
Bug 232050
Change format of DBVERSION and guardian files
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
cvs diffs
repl.diffs (text/plain), 16.88 KB, created by
Noriko Hosoi
on 2007-03-15 20:39:18 UTC
(
hide
)
Description:
cvs diffs
Filename:
MIME Type:
Creator:
Noriko Hosoi
Created:
2007-03-15 20:39:18 UTC
Size:
16.88 KB
patch
obsolete
>Index: repl_shared.h >=================================================================== >RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/replication/repl_shared.h,v >retrieving revision 1.6 >diff -t -w -U4 -r1.6 repl_shared.h >--- repl_shared.h 10 Nov 2006 23:45:17 -0000 1.6 >+++ repl_shared.h 15 Mar 2007 20:23:58 -0000 >@@ -127,13 +127,10 @@ > * also changed name from REPL_PLUGIN_VERSION to CHANGELOG_DB_VERSION since we use > * a different version for the plugin itself and this particular version is only > * used for the changelog database > */ >-/* >- * Changed version from 2.0 to 3.0 when we switched from libdb33 to libdb41 >- * noriko 20021203 >- */ >-#define CHANGELOG_DB_VERSION_PREV "3.0" >+/* the current CHANGELOG_DB_VERSION: DB_VERSION_MAJOR"."DB_VERSION_MINOR" */ >+/* this string is left for the backward compatibility */ > #define CHANGELOG_DB_VERSION "4.0" > extern char *repl_plugin_name; > extern char *windows_repl_plugin_name; > extern char *repl_plugin_name_cl; >Index: cl5_api.h >=================================================================== >RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/replication/cl5_api.h,v >retrieving revision 1.6 >diff -t -w -U4 -r1.6 cl5_api.h >--- cl5_api.h 10 Nov 2006 23:45:17 -0000 1.6 >+++ cl5_api.h 15 Mar 2007 20:23:58 -0000 >@@ -47,8 +47,12 @@ > > #include "repl5.h" > #include "repl5_prot_private.h" > >+#define BDB_IMPL "bdb" /* changelog type */ >+#define BDB_REPLPLUGIN "libreplication-plugin" /* This backend plugin */ >+ >+ > #define CL5_TYPE "Changelog5" /* changelog type */ > #define VERSION_SIZE 127 /* size of the buffer to hold changelog version */ > #define CL5_DEFAULT_CONFIG -1 /* value that indicates to changelog to use default */ > #define CL5_STR_IGNORE "-1" /* tels function to ignore this parameter */ >Index: cl5_api.c >=================================================================== >RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/replication/cl5_api.c,v >retrieving revision 1.13 >diff -t -w -U4 -r1.13 cl5_api.c >--- cl5_api.c 12 Feb 2007 21:13:07 -0000 1.13 >+++ cl5_api.c 15 Mar 2007 20:24:00 -0000 >@@ -61,10 +61,8 @@ > #include "db.h" > #include "cl5_clcache.h" /* To use the Changelog Cache */ > #include "repl5.h" /* for agmt_get_consumer_rid() */ > >-#define CL5_TYPE "Changelog5" /* changelog type */ >-#define VERSION_SIZE 127 /* size of the buffer to hold changelog version */ > #define GUARDIAN_FILE "guardian" /* name of the guardian file */ > #define VERSION_FILE "DBVERSION" /* name of the version file */ > #define MAX_TRIALS 50 /* number of retries on db operations */ > #define V_5 5 /* changelog entry version */ >@@ -286,9 +284,9 @@ > static void _cl5SetDefaultDBConfig (); > static void _cl5SetDBConfig (const CL5DBConfig *config); > static void _cl5InitDBEnv(DB_ENV *dbEnv); > static int _cl5CheckDBVersion (); >-static int _cl5ReadDBVersion (const char *dir, char *clVersion); >+static int _cl5ReadDBVersion (const char *dir, char *clVersion, int buflen); > static int _cl5WriteDBVersion (); > static int _cl5CheckGuardian (); > static int _cl5ReadGuardian (char *buff); > static int _cl5WriteGuardian (); >@@ -2213,8 +2211,54 @@ > } > return CL5_SUCCESS; > } > >+static int _cl5RemoveLogs () >+{ >+ int rc = CL5_DB_ERROR; >+ char filename1[MAXPATHLEN]; >+ PRDir *dirhandle = NULL; >+ dirhandle = PR_OpenDir(s_cl5Desc.dbDir); >+ if (NULL != dirhandle) { >+ PRDirEntry *direntry = NULL; >+ int pre = 0; >+ PRFileInfo info; >+ >+ while (NULL != (direntry = >+ PR_ReadDir(dirhandle, PR_SKIP_DOT | PR_SKIP_DOT_DOT))) >+ { >+ if (NULL == direntry->name) { >+ /* NSPR doesn't behave like the docs say it should */ >+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl, >+ "_cl5RemoveLogs: PR_ReadDir failed (%d): %s\n", >+ PR_GetError(),slapd_pr_strerror(PR_GetError())); >+ break; >+ } >+ PR_snprintf(filename1, MAXPATHLEN, >+ "%s/%s", s_cl5Desc.dbDir, direntry->name); >+ pre = PR_GetFileInfo(filename1, &info); >+ if (pre == PR_SUCCESS && PR_FILE_DIRECTORY == info.type) { >+ continue; >+ } >+ if (0 == strncmp(direntry->name, "log.", 4)) >+ { >+ slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl, >+ "Deleting log file: (%s)\n", filename1); >+ unlink(filename1); >+ } >+ rc = CL5_SUCCESS; >+ } >+ PR_CloseDir(dirhandle); >+ } >+ else if (PR_FILE_NOT_FOUND_ERROR != PR_GetError()) >+ { >+ slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl, >+ "_cl5RemoveLogs:: PR_OpenDir(%s) failed (%d): %s\n", >+ s_cl5Desc.dbDir, PR_GetError(),slapd_pr_strerror(PR_GetError())); >+ } >+ return rc; >+} >+ > static int _cl5AppInit (PRBool *didRecovery) > { > int rc; > unsigned int flags = DB_CREATE | DB_INIT_MPOOL | DB_THREAD; >@@ -2285,9 +2329,12 @@ > /* do recovery if necessary */ > if ((flags & DB_RECOVER) || (flags & DB_RECOVER_FATAL)) > { > if (CL5_OPEN_CLEAN_RECOVER == s_cl5Desc.dbOpenMode) >+ { > _cl5RemoveEnv(); >+ _cl5RemoveLogs(); >+ } > > rc = _cl5Recover (flags, dbEnv); > if (rc != CL5_SUCCESS) > { >@@ -3218,9 +3265,10 @@ > > /* upgrade from db33 to db41 > * 1. Run recovery on the database environment using the DB_ENV->open method > * 2. Remove any Berkeley DB environment using the DB_ENV->remove method >- * 3. extention .db3 -> .db4 ### koko kara !!! >+ * 3. Remove any Berkeley DB transaction log files >+ * 4. extention .db3 -> .db4 > */ > static int _cl5Upgrade3_4(char *fromVersion, char *toVersion) > { > PRDir *dir = NULL; >@@ -3238,8 +3286,9 @@ > slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl, > "_cl5Upgrade3_4: failed to open the db env\n"); > return rc; > } >+ s_cl5Desc.dbOpenMode = backup; > > dir = PR_OpenDir(s_cl5Desc.dbDir); > if (dir == NULL) > { >@@ -3316,8 +3365,50 @@ > } > return rc; > } > >+/* upgrade from db41 -> db42 -> db43 -> db44 -> db45 >+ * 1. Run recovery on the database environment using the DB_ENV->open method >+ * 2. Remove any Berkeley DB environment using the DB_ENV->remove method >+ * 3. Remove any Berkeley DB transaction log files >+ */ >+static int _cl5Upgrade4_4(char *fromVersion, char *toVersion) >+{ >+ PRDirEntry *entry = NULL; >+ DB *thisdb = NULL; >+ CL5OpenMode backup; >+ int rc = 0; >+ >+ backup = s_cl5Desc.dbOpenMode; >+ s_cl5Desc.dbOpenMode = CL5_OPEN_CLEAN_RECOVER; >+ /* CL5_OPEN_CLEAN_RECOVER does 1 and 2 */ >+ rc = _cl5AppInit (NULL); >+ if (rc != CL5_SUCCESS) >+ { >+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl, >+ "_cl5Upgrade4_4: failed to open the db env\n"); >+ return rc; >+ } >+ s_cl5Desc.dbOpenMode = backup; >+ >+ /* update the version file */ >+ _cl5WriteDBVersion (); >+ >+ /* update the guardian file */ >+ _cl5WriteGuardian (); >+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl, >+ "Upgrading from %s to %s is successfully done (%s)\n", >+ fromVersion, toVersion, s_cl5Desc.dbDir); >+ >+ if (s_cl5Desc.dbEnv) >+ { >+ DB_ENV *dbEnv = s_cl5Desc.dbEnv; >+ dbEnv->close(dbEnv, 0); >+ s_cl5Desc.dbEnv = NULL; >+ } >+ return rc; >+} >+ > static int _cl5CheckDBVersion () > { > char clVersion [VERSION_SIZE + 1]; > char dbVersion [VERSION_SIZE + 1]; >@@ -3332,49 +3423,88 @@ > } > } > else > { >- PR_snprintf (clVersion, VERSION_SIZE, "%s/%s/%s", CL5_TYPE, REPL_PLUGIN_NAME, >- CHANGELOG_DB_VERSION); >- rc = _cl5ReadDBVersion (s_cl5Desc.dbDir, dbVersion); >+ char *versionp = NULL; >+ char *versionendp = NULL; >+ char *dotp = NULL; >+ int dbmajor = 0; >+ int dbminor = 0; >+ >+ PR_snprintf (clVersion, VERSION_SIZE, "%s/%d.%d/%s", >+ BDB_IMPL, DB_VERSION_MAJOR, DB_VERSION_MINOR, BDB_REPLPLUGIN); >+ >+ rc = _cl5ReadDBVersion (s_cl5Desc.dbDir, dbVersion, sizeof(dbVersion)); > > if (rc != CL5_SUCCESS) > { > slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl, > "_cl5CheckDBVersion: invalid dbversion\n"); > rc = CL5_BAD_DBVERSION; >+ goto bailout; >+ } >+ versionendp = dbVersion + strlen(dbVersion); >+ /* get the version number */ >+ /* old DBVERSION string: CL5_TYPE/REPL_PLUGIN_NAME/#.# */ >+ if (PL_strncmp(dbVersion, CL5_TYPE, strlen(CL5_TYPE)) == 0) >+ { >+ versionp = strrchr(dbVersion, '/'); >+ } >+ /* new DBVERSION string: bdb/#.#/libreplication-plugin */ >+ else if (PL_strncmp(dbVersion, BDB_IMPL, strlen(BDB_IMPL)) == 0) >+ { >+ versionp = strchr(dbVersion, '/'); >+ } >+ if (NULL == versionp || versionp == versionendp) >+ { >+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl, >+ "_cl5CheckDBVersion: invalid dbversion: %s\n", dbVersion); >+ rc = CL5_BAD_DBVERSION; >+ goto bailout; >+ } >+ dotp = strchr(++versionp, '.'); >+ if (NULL != dotp) >+ { >+ *dotp = '\0'; >+ dbmajor = strtol(versionp, (char **)NULL, 10); >+ dbminor = strtol(++dotp, (char **)NULL, 10); >+ *dotp = '.'; > } >- else if (strcasecmp (clVersion, dbVersion) != 0) >+ else > { >- char prevClVersion [VERSION_SIZE + 1]; >- PR_snprintf (prevClVersion, VERSION_SIZE, "%s/%s/%s", >- CL5_TYPE, REPL_PLUGIN_NAME, CHANGELOG_DB_VERSION_PREV); >- if (strcasecmp (prevClVersion, dbVersion) == 0) >+ dbmajor = strtol(versionp, (char **)NULL, 10); >+ } >+ >+ if (dbmajor < DB_VERSION_MAJOR) > { > /* upgrade */ >- rc = _cl5Upgrade3_4(prevClVersion, clVersion); >+ rc = _cl5Upgrade3_4(dbVersion, clVersion); > if (rc != CL5_SUCCESS) > { > slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl, > "_cl5CheckDBVersion: upgrade %s -> %s failed\n", >- CHANGELOG_DB_VERSION_PREV, CHANGELOG_DB_VERSION); >+ dbVersion, clVersion); > rc = CL5_BAD_DBVERSION; > } > } >- else >+ else if (dbminor < DB_VERSION_MINOR) >+ { >+ /* minor upgrade */ >+ rc = _cl5Upgrade4_4(dbVersion, clVersion); >+ if (rc != CL5_SUCCESS) > { > slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl, >- "_cl5CheckDBVersion: invalid dbversion\n"); >+ "_cl5CheckDBVersion: upgrade %s -> %s failed\n", >+ dbVersion, clVersion); > rc = CL5_BAD_DBVERSION; > } > } >- > } >- >+bailout: > return rc; > } > >-static int _cl5ReadDBVersion (const char *dir, char *clVersion) >+static int _cl5ReadDBVersion (const char *dir, char *clVersion, int buflen) > { > int rc; > PRFileDesc *file; > char fName [MAXPATHLEN + 1]; >@@ -3415,9 +3545,9 @@ > if (tok) > { > if (clVersion) > { >- strcpy(clVersion, tok); >+ PL_strncpyz(clVersion, tok, buflen); > } > } > > rc = PR_Close (file); >@@ -3441,9 +3571,10 @@ > PRInt32 len, size; > > PR_snprintf (fName, MAXPATHLEN, "%s/%s", s_cl5Desc.dbDir, VERSION_FILE); > >- file = PR_Open (fName, PR_WRONLY | PR_CREATE_FILE, s_cl5Desc.dbConfig.fileMode); >+ file = PR_Open (fName, PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE, >+ s_cl5Desc.dbConfig.fileMode); > if (file == NULL) > { > slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl, > "_cl5WriteDBVersion: failed to open DBVERSION; NSPR error - %d\n", >@@ -3451,10 +3582,10 @@ > return CL5_SYSTEM_ERROR; > } > > /* write changelog version */ >- PR_snprintf (clVersion, VERSION_SIZE, "%s/%s/%s\n", CL5_TYPE, REPL_PLUGIN_NAME, >- CHANGELOG_DB_VERSION); >+ PR_snprintf (clVersion, VERSION_SIZE, "%s/%d.%d/%s\n", >+ BDB_IMPL, DB_VERSION_MAJOR, DB_VERSION_MINOR, BDB_REPLPLUGIN); > > len = strlen (clVersion); > size = slapi_write_buffer (file, clVersion, len); > if (size != len) >@@ -3491,18 +3622,29 @@ > return CL5_SUCCESS; > } > else > { >- PR_snprintf (plVersion, VERSION_SIZE, "%s/%s/%s", CL5_TYPE, REPL_PLUGIN_NAME, >- CHANGELOG_DB_VERSION); >+ PR_snprintf (plVersion, VERSION_SIZE, "%s/%d.%d/%s\n", >+ BDB_IMPL, DB_VERSION_MAJOR, DB_VERSION_MINOR, BDB_REPLPLUGIN); > rc = _cl5ReadGuardian (dbVersion); > > if (rc != CL5_SUCCESS || strcasecmp (plVersion, dbVersion) != 0) > { >+ PR_snprintf (plVersion, VERSION_SIZE, "%s/%s/%s", >+ CL5_TYPE, REPL_PLUGIN_NAME, CHANGELOG_DB_VERSION); >+ if (strcasecmp (plVersion, dbVersion) != 0) >+ { > slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl, >+ "_cl5CheckGuardian: found old style of guardian file: %s\n", >+ dbVersion); >+ } >+ else >+ { >+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl, > "_cl5CheckGuardian: missing or invalid guardian file\n"); > return (CL5_BAD_FORMAT); > } >+ } > > /* remove guardian file */ > rc = _cl5RemoveGuardian (); > if (rc != CL5_SUCCESS) >@@ -3533,10 +3675,10 @@ > PR_GetError()); > return CL5_SYSTEM_ERROR; > } > >- PR_snprintf (version, VERSION_SIZE, "%s/%s/%s\n", CL5_TYPE, REPL_PLUGIN_NAME, >- CHANGELOG_DB_VERSION); >+ PR_snprintf (version, VERSION_SIZE, "%s/%d.%d/%s\n", >+ BDB_IMPL, DB_VERSION_MAJOR, DB_VERSION_MINOR, BDB_REPLPLUGIN); > > len = strlen (version); > size = slapi_write_buffer (file, version, len); > if (size != len)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 232050
:
150009
|
150100
| 150172 |
150177
|
150178
|
150974