if (ldb_module_flags(ldb_module_get_ctx(module)) & LDB_FLG_ENABLE_TRACING) {
ldb_debug(ldb_module_get_ctx(module), LDB_DEBUG_TRACE, "partition_start_trans() -> (metadata partition)");
}
+
+ /* This order must match that in prepare_commit() */
ret = ldb_next_start_trans(module);
if (ret != LDB_SUCCESS) {
return ret;
return ret;
}
- ret = partition_metadata_start_trans(module);
- if (ret != LDB_SUCCESS) {
- ldb_next_del_trans(module);
- return ret;
- }
-
for (i=0; data && data->partitions && data->partitions[i]; i++) {
if ((module && ldb_module_flags(ldb_module_get_ctx(module)) & LDB_FLG_ENABLE_TRACING)) {
ldb_debug(ldb_module_get_ctx(module), LDB_DEBUG_TRACE, "partition_start_trans() -> %s",
}
}
+ /*
+ * Because in prepare_commit this must come last, to ensure
+ * lock ordering we have to do this last here also
+ */
+ ret = partition_metadata_start_trans(module);
+ if (ret != LDB_SUCCESS) {
+ /* Back it out, if it fails on one */
+ for (i--; i >= 0; i--) {
+ ldb_next_del_trans(data->partitions[i]->module);
+ }
+ ldb_next_del_trans(module);
+ return ret;
+ }
+
data->in_transaction++;
return LDB_SUCCESS;
struct partition_private_data);
int ret;
+ ret = ldb_next_prepare_commit(module);
+ if (ret != LDB_SUCCESS) {
+ return ret;
+ }
+
for (i=0; data && data->partitions && data->partitions[i]; i++) {
if ((module && ldb_module_flags(ldb_module_get_ctx(module)) & LDB_FLG_ENABLE_TRACING)) {
ldb_debug(ldb_module_get_ctx(module), LDB_DEBUG_TRACE, "partition_prepare_commit() -> %s",
ldb_debug(ldb_module_get_ctx(module), LDB_DEBUG_TRACE, "partition_prepare_commit() -> (metadata partition)");
}
- ret = ldb_next_prepare_commit(module);
- if (ret != LDB_SUCCESS) {
- return ret;
- }
-
/* metadata prepare commit must come last, as other partitions could modify
* the database inside the prepare commit method of a module */
return partition_metadata_prepare_commit(module);