|
|
4bc6090 |
From 9c7e9d51309cb8daa900a3e37c56267477aa666d Mon Sep 17 00:00:00 2001
|
|
|
4bc6090 |
From: Rich Megginson <rmeggins@redhat.com>
|
|
|
4bc6090 |
Date: Wed, 28 Mar 2012 16:11:20 -0600
|
|
|
4bc6090 |
Subject: [PATCH] Ticket #331 - transaction errors with db 4.3 and db 4.2
|
|
|
4bc6090 |
|
|
|
4bc6090 |
https://fedorahosted.org/389/ticket/331
|
|
|
4bc6090 |
Resolves: Ticket #331
|
|
|
4bc6090 |
Bug Description: transaction errors with db 4.3 and db 4.2
|
|
|
4bc6090 |
Reviewed by: nhosoi (Thanks!)
|
|
|
4bc6090 |
Branch: master
|
|
|
4bc6090 |
Fix Description:
|
|
|
4bc6090 |
we are enabling transactions everywhere - since we are opening databases
|
|
|
4bc6090 |
with DB_AUTO_COMMIT we must either open and pass a valid txn handle to
|
|
|
4bc6090 |
all operations that modify the database (put, del) or we must pass the
|
|
|
4bc6090 |
DB_AUTO_COMMIT flag to those operations.
|
|
|
4bc6090 |
Platforms tested: RHEL6 x86_64, RHEL5 i386
|
|
|
4bc6090 |
Flag Day: no
|
|
|
4bc6090 |
Doc impact: no
|
|
|
4bc6090 |
---
|
|
|
4bc6090 |
ldap/servers/plugins/replication/cl5_api.c | 22 +++++++++++++++-------
|
|
|
4bc6090 |
1 files changed, 15 insertions(+), 7 deletions(-)
|
|
|
4bc6090 |
|
|
|
4bc6090 |
diff --git a/ldap/servers/plugins/replication/cl5_api.c b/ldap/servers/plugins/replication/cl5_api.c
|
|
|
4bc6090 |
index 3c02d41..2b57f91 100644
|
|
|
4bc6090 |
--- a/ldap/servers/plugins/replication/cl5_api.c
|
|
|
4bc6090 |
+++ b/ldap/servers/plugins/replication/cl5_api.c
|
|
|
4bc6090 |
@@ -95,7 +95,15 @@
|
|
|
4bc6090 |
#if 1000*DB_VERSION_MAJOR + 100*DB_VERSION_MINOR >= 4100
|
|
|
4bc6090 |
#define USE_DB_TXN 1 /* use transactions */
|
|
|
4bc6090 |
#define DEFAULT_DB_ENV_OP_FLAGS DB_AUTO_COMMIT
|
|
|
4bc6090 |
-#define DEFAULT_DB_OP_FLAGS 0
|
|
|
4bc6090 |
+#if 1000*DB_VERSION_MAJOR + 100*DB_VERSION_MINOR <= 4300
|
|
|
4bc6090 |
+/* we are enabling transactions everywhere - since we are opening databases
|
|
|
4bc6090 |
+ with DB_AUTO_COMMIT we must either open and pass a valid txn handle to
|
|
|
4bc6090 |
+ all operations that modify the database (put, del) or we must pass the
|
|
|
4bc6090 |
+ DB_AUTO_COMMIT flag to those operations */
|
|
|
4bc6090 |
+#define DEFAULT_DB_OP_FLAGS(txn) (txn ? 0 : DB_AUTO_COMMIT)
|
|
|
4bc6090 |
+#else
|
|
|
4bc6090 |
+#define DEFAULT_DB_OP_FLAGS(txn) 0
|
|
|
4bc6090 |
+#endif
|
|
|
4bc6090 |
#define DB_OPEN(oflags, db, txnid, file, database, type, flags, mode, rval) \
|
|
|
4bc6090 |
{ \
|
|
|
4bc6090 |
if (((oflags) & DB_INIT_TXN) && ((oflags) & DB_INIT_LOG)) \
|
|
|
4bc6090 |
@@ -108,7 +116,7 @@
|
|
|
4bc6090 |
} \
|
|
|
4bc6090 |
}
|
|
|
4bc6090 |
#else /* older then db 41 */
|
|
|
4bc6090 |
-#define DEFAULT_DB_OP_FLAGS 0
|
|
|
4bc6090 |
+#define DEFAULT_DB_OP_FLAGS(txn) 0
|
|
|
4bc6090 |
#define DB_OPEN(oflags, db, txnid, file, database, type, flags, mode, rval) \
|
|
|
4bc6090 |
(rval) = (db)->open((db), (file), (database), (type), (flags), (mode))
|
|
|
4bc6090 |
#endif
|
|
|
4bc6090 |
@@ -3676,7 +3684,7 @@ static int _cl5ReadRUV (const char *replGen, Object *obj, PRBool purge)
|
|
|
4bc6090 |
|
|
|
4bc6090 |
/* delete the entry; it is re-added when file
|
|
|
4bc6090 |
is successfully closed */
|
|
|
4bc6090 |
- file->db->del (file->db, NULL, &key, DEFAULT_DB_OP_FLAGS);
|
|
|
4bc6090 |
+ file->db->del (file->db, NULL, &key, DEFAULT_DB_OP_FLAGS(NULL));
|
|
|
4bc6090 |
|
|
|
4bc6090 |
rc = CL5_SUCCESS;
|
|
|
4bc6090 |
goto done;
|
|
|
4bc6090 |
@@ -3747,7 +3755,7 @@ static int _cl5WriteRUV (CL5DBFile *file, PRBool purge)
|
|
|
4bc6090 |
return CL5_DB_ERROR;
|
|
|
4bc6090 |
}
|
|
|
4bc6090 |
#endif
|
|
|
4bc6090 |
- rc = file->db->put(file->db, txnid, &key, &data, DEFAULT_DB_OP_FLAGS);
|
|
|
4bc6090 |
+ rc = file->db->put(file->db, txnid, &key, &data, DEFAULT_DB_OP_FLAGS(txnid));
|
|
|
4bc6090 |
|
|
|
4bc6090 |
slapi_ch_free (&(data.data));
|
|
|
4bc6090 |
if ( rc == 0 )
|
|
|
4bc6090 |
@@ -4039,7 +4047,7 @@ static int _cl5GetEntryCount (CL5DBFile *file)
|
|
|
4bc6090 |
|
|
|
4bc6090 |
/* delete the entry. the entry is re-added when file
|
|
|
4bc6090 |
is successfully closed */
|
|
|
4bc6090 |
- file->db->del (file->db, NULL, &key, DEFAULT_DB_OP_FLAGS);
|
|
|
4bc6090 |
+ file->db->del (file->db, NULL, &key, DEFAULT_DB_OP_FLAGS(NULL));
|
|
|
4bc6090 |
slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl,
|
|
|
4bc6090 |
"_cl5GetEntryCount: %d changes for replica %s\n",
|
|
|
4bc6090 |
file->entryCount, file->replName);
|
|
|
4bc6090 |
@@ -4103,7 +4111,7 @@ static int _cl5WriteEntryCount (CL5DBFile *file)
|
|
|
4bc6090 |
return CL5_DB_ERROR;
|
|
|
4bc6090 |
}
|
|
|
4bc6090 |
#endif
|
|
|
4bc6090 |
- rc = file->db->put(file->db, txnid, &key, &data, DEFAULT_DB_OP_FLAGS);
|
|
|
4bc6090 |
+ rc = file->db->put(file->db, txnid, &key, &data, DEFAULT_DB_OP_FLAGS(txnid));
|
|
|
4bc6090 |
if (rc == 0)
|
|
|
4bc6090 |
{
|
|
|
4bc6090 |
#if 1000*DB_VERSION_MAJOR + 100*DB_VERSION_MINOR < 4100
|
|
|
4bc6090 |
@@ -4599,7 +4607,7 @@ static int _cl5WriteOperationTxn(const char *replName, const char *replGen,
|
|
|
4bc6090 |
{
|
|
|
4bc6090 |
PR_WaitSemaphore(file->sema);
|
|
|
4bc6090 |
}
|
|
|
4bc6090 |
- rc = file->db->put(file->db, txnid, &key, data, DEFAULT_DB_OP_FLAGS);
|
|
|
4bc6090 |
+ rc = file->db->put(file->db, txnid, &key, data, DEFAULT_DB_OP_FLAGS(txnid));
|
|
|
4bc6090 |
if ( file->sema )
|
|
|
4bc6090 |
{
|
|
|
4bc6090 |
PR_PostSemaphore(file->sema);
|
|
|
4bc6090 |
--
|
|
|
4bc6090 |
1.7.1
|
|
|
4bc6090 |
|