summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2009-09-03 18:32:42 +1000
committerAndrew Tridgell <tridge@samba.org>2009-09-03 18:36:09 +1000
commit47f52e7a337f1f0e35c77f480146bbee3ac1d309 (patch)
treef3a715546bd7a2b1659af3e8d4ba9d7d4281f542 /source4
parent7dbe0797b1c98fc63af20af03c2b36cc04a7386e (diff)
downloadsamba-47f52e7a337f1f0e35c77f480146bbee3ac1d309.tar.gz
samba-47f52e7a337f1f0e35c77f480146bbee3ac1d309.tar.bz2
samba-47f52e7a337f1f0e35c77f480146bbee3ac1d309.zip
greatly simplify the transaction processing in the partition module
Now that ldb is calling prepare commit separately, the job of the partition module on transaction end is much simpler (and more robust!)
Diffstat (limited to 'source4')
-rw-r--r--source4/dsdb/samdb/ldb_modules/partition.c80
1 files changed, 29 insertions, 51 deletions
diff --git a/source4/dsdb/samdb/ldb_modules/partition.c b/source4/dsdb/samdb/ldb_modules/partition.c
index 515d437861..e8b55a4e4b 100644
--- a/source4/dsdb/samdb/ldb_modules/partition.c
+++ b/source4/dsdb/samdb/ldb_modules/partition.c
@@ -680,97 +680,74 @@ static int partition_start_trans(struct ldb_module *module)
return LDB_SUCCESS;
}
-/* end a transaction */
-static int partition_end_trans(struct ldb_module *module)
+/* prepare for a commit */
+static int partition_prepare_commit(struct ldb_module *module)
{
- int i, ret, final_ret;
+ int i;
struct partition_private_data *data = talloc_get_type(module->private_data,
struct partition_private_data);
- ret = ldb_next_end_trans(module);
- if (ret != LDB_SUCCESS) {
- return ret;
- }
- /* if the backend has a prepare_commit op then use that, to ensure
- that all partitions are committed safely together */
for (i=0; data && data->partitions && data->partitions[i]; i++) {
- struct ldb_module *next_end = data->partitions[i]->module;
struct ldb_module *next_prepare = data->partitions[i]->module;
- struct ldb_module *next_del = data->partitions[i]->module;
+ int ret;
PARTITION_FIND_OP_NOERROR(next_prepare, prepare_commit);
if (next_prepare == NULL) {
continue;
}
- PARTITION_FIND_OP(next_end, end_transaction);
- PARTITION_FIND_OP(next_del, del_transaction);
-
- if (next_end != next_prepare || next_del != next_end) {
- ldb_asprintf_errstring(ldb_module_get_ctx(module), "ERROR: Mismatch between prepare and commit ops in ldb module");
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
ret = next_prepare->ops->prepare_commit(next_prepare);
if (ret != LDB_SUCCESS) {
- /* if one fails, cancel all but this one */
- int j;
- for (j=0; data->partitions[j]; j++) {
- if (j == i) continue;
- next_del = data->partitions[j]->module;
- PARTITION_FIND_OP(next_del, del_transaction);
- next_del->ops->del_transaction(next_del);
- }
- ldb_next_del_trans(module);
return ret;
}
}
- /* Look at base DN */
- /* Figure out which partition it is under */
- /* Skip the lot if 'data' isn't here yet (initialisation) */
- final_ret = LDB_SUCCESS;
+ return ldb_next_prepare_commit(module);
+}
+
+/* end a transaction */
+static int partition_end_trans(struct ldb_module *module)
+{
+ int i;
+ struct partition_private_data *data = talloc_get_type(module->private_data,
+ struct partition_private_data);
for (i=0; data && data->partitions && data->partitions[i]; i++) {
- struct ldb_module *next = data->partitions[i]->module;
- PARTITION_FIND_OP(next, end_transaction);
+ struct ldb_module *next_end = data->partitions[i]->module;
+ int ret;
- ret = next->ops->end_transaction(next);
+ PARTITION_FIND_OP(next_end, end_transaction);
+
+ ret = next_end->ops->end_transaction(next_end);
if (ret != LDB_SUCCESS) {
- /* this should only be happening if we had a serious
- OS or hardware error */
- ldb_asprintf_errstring(ldb_module_get_ctx(module), "ERROR: partition commit error");
- final_ret = ret;
+ return ret;
}
}
- return final_ret;
+ return ldb_next_end_trans(module);
}
/* delete a transaction */
static int partition_del_trans(struct ldb_module *module)
{
- int i, ret, ret2 = LDB_SUCCESS;
+ int i, ret, final_ret = LDB_SUCCESS;
struct partition_private_data *data = talloc_get_type(module->private_data,
struct partition_private_data);
- ret = ldb_next_del_trans(module);
- if (ret != LDB_SUCCESS) {
- ret2 = ret;
- }
-
- /* Look at base DN */
- /* Figure out which partition it is under */
- /* Skip the lot if 'data' isn't here yet (initialistion) */
for (i=0; data && data->partitions && data->partitions[i]; i++) {
struct ldb_module *next = data->partitions[i]->module;
PARTITION_FIND_OP(next, del_transaction);
ret = next->ops->del_transaction(next);
if (ret != LDB_SUCCESS) {
- ret2 = ret;
+ final_ret = ret;
}
+ }
+
+ ret = ldb_next_del_trans(module);
+ if (ret != LDB_SUCCESS) {
+ final_ret = ret;
}
- return ret2;
+ return final_ret;
}
@@ -1394,6 +1371,7 @@ _PUBLIC_ const struct ldb_module_ops ldb_partition_module_ops = {
.rename = partition_rename,
.extended = partition_extended,
.start_transaction = partition_start_trans,
+ .prepare_commit = partition_prepare_commit,
.end_transaction = partition_end_trans,
.del_transaction = partition_del_trans,
};