summaryrefslogtreecommitdiff
path: root/source4/dsdb/repl/replicated_objects.c
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2016-05-04 17:01:15 +1200
committerAndrew Bartlett <abartlet@samba.org>2016-07-06 15:35:17 +0200
commit2a9060641757937ad764685ec35507629ce6283e (patch)
tree92291e0e8b6fd2f60f2710df5d3bdc7e6e0ef054 /source4/dsdb/repl/replicated_objects.c
parent5abcdd56ba4f1b61b9421c81caa491e70c4881c4 (diff)
downloadsamba-2a9060641757937ad764685ec35507629ce6283e.tar.gz
dsdb: Remove 120 second delay and USN from schema refresh check
We now refresh it once the schema changes, so that replication can proceed right away. We use the sequence number in the metadata.tdb. The previous commit added a cache for this value, protected by tdb_seqnum(). metadata.tdb is now opened at startup to provide this support. Note that while still supported, schemaUpdateNow is essentially rudundent: instead, to ensure we increment the sequence number correctly, we unify that check into repl_meta_data at the transaction close. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Diffstat (limited to 'source4/dsdb/repl/replicated_objects.c')
-rw-r--r--source4/dsdb/repl/replicated_objects.c80
1 files changed, 11 insertions, 69 deletions
diff --git a/source4/dsdb/repl/replicated_objects.c b/source4/dsdb/repl/replicated_objects.c
index 919dd46ca1f..88ba598ba6b 100644
--- a/source4/dsdb/repl/replicated_objects.c
+++ b/source4/dsdb/repl/replicated_objects.c
@@ -883,83 +883,25 @@ WERROR dsdb_replicated_objects_commit(struct ldb_context *ldb,
* a schema cache being refreshed from database.
*/
if (working_schema) {
- struct ldb_message *msg;
- struct ldb_request *req;
-
- /* Force a reload */
- working_schema->last_refresh = 0;
+ /* Reload the schema */
new_schema = dsdb_get_schema(ldb, tmp_ctx);
- /* TODO:
+ /* TODO:
* If dsdb_get_schema() fails, we just fall back
* to what we had. However, the database is probably
* unable to operate for other users from this
* point... */
- if (new_schema && used_global_schema) {
- dsdb_make_schema_global(ldb, new_schema);
- } else if (used_global_schema) {
- DEBUG(0,("Failed to re-load schema after commit of transaction\n"));
- dsdb_set_global_schema(ldb);
- TALLOC_FREE(tmp_ctx);
- return WERR_INTERNAL_ERROR;
- } else {
- DEBUG(0,("Failed to re-load schema after commit of transaction\n"));
+ if (new_schema == NULL || new_schema == working_schema) {
+ DEBUG(0,("Failed to re-load schema after commit of transaction (working: %p/%llu, new: %p/%llu)\n",
+ new_schema, (unsigned long long)new_schema->metadata_usn,
+ working_schema, (unsigned long long)working_schema->metadata_usn));
dsdb_reference_schema(ldb, cur_schema, false);
+ if (used_global_schema) {
+ dsdb_set_global_schema(ldb);
+ }
TALLOC_FREE(tmp_ctx);
return WERR_INTERNAL_ERROR;
- }
- msg = ldb_msg_new(tmp_ctx);
- if (msg == NULL) {
- TALLOC_FREE(tmp_ctx);
- return WERR_NOMEM;
- }
- msg->dn = ldb_dn_new(msg, ldb, "");
- if (msg->dn == NULL) {
- TALLOC_FREE(tmp_ctx);
- return WERR_NOMEM;
- }
-
- ret = ldb_msg_add_string(msg, "schemaUpdateNow", "1");
- if (ret != LDB_SUCCESS) {
- TALLOC_FREE(tmp_ctx);
- return WERR_INTERNAL_ERROR;
- }
-
- ret = ldb_build_mod_req(&req, ldb, objects,
- msg,
- NULL,
- NULL,
- ldb_op_default_callback,
- NULL);
-
- if (ret != LDB_SUCCESS) {
- TALLOC_FREE(tmp_ctx);
- return WERR_DS_DRA_INTERNAL_ERROR;
- }
-
- ret = ldb_transaction_start(ldb);
- if (ret != LDB_SUCCESS) {
- TALLOC_FREE(tmp_ctx);
- DEBUG(0, ("Autotransaction start failed\n"));
- return WERR_DS_DRA_INTERNAL_ERROR;
- }
-
- ret = ldb_request(ldb, req);
- if (ret == LDB_SUCCESS) {
- ret = ldb_wait(req->handle, LDB_WAIT_ALL);
- }
-
- if (ret == LDB_SUCCESS) {
- ret = ldb_transaction_commit(ldb);
- } else {
- DEBUG(0, ("Schema update now failed: %s\n",
- ldb_errstring(ldb)));
- ldb_transaction_cancel(ldb);
- }
-
- if (ret != LDB_SUCCESS) {
- DEBUG(0, ("Commit failed: %s\n", ldb_errstring(ldb)));
- TALLOC_FREE(tmp_ctx);
- return WERR_DS_INTERNAL_FAILURE;
+ } else if (used_global_schema) {
+ dsdb_make_schema_global(ldb, new_schema);
}
}