summaryrefslogtreecommitdiff
path: root/source4/dsdb
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2016-07-06 11:38:28 +1200
committerAndrew Bartlett <abartlet@samba.org>2016-07-06 15:35:17 +0200
commit5abcdd56ba4f1b61b9421c81caa491e70c4881c4 (patch)
tree987bcefb3864f44291d19a43b8b94e59decbf173 /source4/dsdb
parentbad502fd86185dc15d58c753baacd4cb3d03c733 (diff)
downloadsamba-5abcdd56ba4f1b61b9421c81caa491e70c4881c4.tar.gz
dsdb: Remove use of schema USN in samldb_add_handle_msDS_IntId
This is not a frequent enough operation to warrent a cache, and the USN will be removed from the schema code shortly Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Diffstat (limited to 'source4/dsdb')
-rw-r--r--source4/dsdb/samdb/ldb_modules/repl_meta_data.c18
-rw-r--r--source4/dsdb/samdb/ldb_modules/samldb.c66
-rw-r--r--source4/dsdb/samdb/samdb.h1
3 files changed, 21 insertions, 64 deletions
diff --git a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c
index b551e34e1e3..0c94b2aa6b8 100644
--- a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c
+++ b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c
@@ -832,7 +832,6 @@ static int replmd_add_fix_la(struct ldb_module *module, struct ldb_message_eleme
*/
static int replmd_add(struct ldb_module *module, struct ldb_request *req)
{
- struct samldb_msds_intid_persistant *msds_intid_struct;
struct ldb_context *ldb;
struct ldb_control *control;
struct replmd_replicated_request *ac;
@@ -1149,14 +1148,6 @@ static int replmd_add(struct ldb_module *module, struct ldb_request *req)
if (control) {
control->critical = 0;
}
- if (ldb_dn_compare_base(replmd_private->schema_dn, req->op.add.message->dn) != 0) {
-
- /* Update the usn in the SAMLDB_MSDS_INTID_OPAQUE opaque */
- msds_intid_struct = (struct samldb_msds_intid_persistant *) ldb_get_opaque(ldb, SAMLDB_MSDS_INTID_OPAQUE);
- if (msds_intid_struct) {
- msds_intid_struct->usn = ac->seq_num;
- }
- }
/* go on with the call chain */
return ldb_next_request(module, down_req);
}
@@ -2519,7 +2510,6 @@ static int replmd_modify_handle_linked_attribs(struct ldb_module *module,
static int replmd_modify(struct ldb_module *module, struct ldb_request *req)
{
- struct samldb_msds_intid_persistant *msds_intid_struct;
struct ldb_context *ldb;
struct replmd_replicated_request *ac;
struct ldb_request *down_req;
@@ -2674,14 +2664,6 @@ static int replmd_modify(struct ldb_module *module, struct ldb_request *req)
}
}
- if (!ldb_dn_compare_base(replmd_private->schema_dn, msg->dn)) {
- /* Update the usn in the SAMLDB_MSDS_INTID_OPAQUE opaque */
- msds_intid_struct = (struct samldb_msds_intid_persistant *) ldb_get_opaque(ldb, SAMLDB_MSDS_INTID_OPAQUE);
- if (msds_intid_struct) {
- msds_intid_struct->usn = ac->seq_num;
- }
- }
-
/* go on with the call chain */
return ldb_next_request(module, down_req);
}
diff --git a/source4/dsdb/samdb/ldb_modules/samldb.c b/source4/dsdb/samdb/ldb_modules/samldb.c
index 811262427fa..cc101a6ea4d 100644
--- a/source4/dsdb/samdb/ldb_modules/samldb.c
+++ b/source4/dsdb/samdb/ldb_modules/samldb.c
@@ -576,7 +576,6 @@ static int samldb_add_handle_msDS_IntId(struct samldb_ctx *ac)
msds_intid = generate_random() % 0X3FFFFFFF;
msds_intid += 0x80000000;
msds_intid_struct->msds_intid = msds_intid;
- msds_intid_struct->usn = schema->loaded_usn;
DEBUG(2, ("No samldb_msds_intid_persistant struct, allocating a new one\n"));
} else {
msds_intid = msds_intid_struct->msds_intid;
@@ -584,22 +583,22 @@ static int samldb_add_handle_msDS_IntId(struct samldb_ctx *ac)
/* probe id values until unique one is found */
do {
- uint64_t current_usn;
msds_intid++;
if (msds_intid > 0xBFFFFFFF) {
msds_intid = 0x80000001;
}
/*
- * Alternative strategy to a costly (even indexed search) to the
- * database.
- * We search in the schema if we have already this intid (using dsdb_attribute_by_attributeID_id because
- * in the range 0x80000000 0xBFFFFFFFF, attributeID is a DSDB_ATTID_TYPE_INTID).
+ * We search in the schema if we have already this
+ * intid (using dsdb_attribute_by_attributeID_id
+ * because in the range 0x80000000 0xBFFFFFFFF,
+ * attributeID is a DSDB_ATTID_TYPE_INTID).
+ *
* If so generate another random value.
- * If not check if the highest USN in the database for the schema partition is the
- * one that we know.
- * If so it means that's only this ldb context that is touching the schema in the database.
- * If not it means that's someone else has modified the database while we are doing our changes too
- * (this case should be very bery rare) in order to be sure do the search in the database.
+ *
+ * We have to check the DB in case someone else has
+ * modified the database while we are doing our
+ * changes too (this case should be very bery rare) in
+ * order to be sure.
*/
if (dsdb_attribute_by_attributeID_id(schema, msds_intid)) {
msds_intid = generate_random() % 0X3FFFFFFF;
@@ -607,45 +606,22 @@ static int samldb_add_handle_msDS_IntId(struct samldb_ctx *ac)
continue;
}
- ret = dsdb_module_load_partition_usn(ac->module, schema_dn,
- &current_usn, NULL, NULL);
+
+ ret = dsdb_module_search(ac->module, ac,
+ &ldb_res,
+ schema_dn, LDB_SCOPE_ONELEVEL, NULL,
+ DSDB_FLAG_NEXT_MODULE,
+ ac->req,
+ "(msDS-IntId=%d)", msds_intid);
if (ret != LDB_SUCCESS) {
ldb_debug_set(ldb, LDB_DEBUG_ERROR,
- __location__": Searching for schema USN failed: %s\n",
+ __location__": Searching for msDS-IntId=%d failed - %s\n",
+ msds_intid,
ldb_errstring(ldb));
return ldb_operr(ldb);
}
-
- /* current_usn can be lesser than msds_intid_struct-> if there is
- * uncommited changes.
- */
- if (current_usn > msds_intid_struct->usn) {
- /* oups something has changed, someone/something
- * else is modifying or has modified the schema
- * we'd better check this intid is the database directly
- */
-
- DEBUG(2, ("Schema has changed, searching the database for the unicity of %d\n",
- msds_intid));
-
- ret = dsdb_module_search(ac->module, ac,
- &ldb_res,
- schema_dn, LDB_SCOPE_ONELEVEL, NULL,
- DSDB_FLAG_NEXT_MODULE,
- ac->req,
- "(msDS-IntId=%d)", msds_intid);
- if (ret != LDB_SUCCESS) {
- ldb_debug_set(ldb, LDB_DEBUG_ERROR,
- __location__": Searching for msDS-IntId=%d failed - %s\n",
- msds_intid,
- ldb_errstring(ldb));
- return ldb_operr(ldb);
- }
- id_exists = (ldb_res->count > 0);
- talloc_free(ldb_res);
- } else {
- id_exists = 0;
- }
+ id_exists = (ldb_res->count > 0);
+ talloc_free(ldb_res);
} while(id_exists);
msds_intid_struct->msds_intid = msds_intid;
diff --git a/source4/dsdb/samdb/samdb.h b/source4/dsdb/samdb/samdb.h
index 20a55fecb75..12971dd6d93 100644
--- a/source4/dsdb/samdb/samdb.h
+++ b/source4/dsdb/samdb/samdb.h
@@ -257,7 +257,6 @@ struct dsdb_openldap_dereference_result_control {
struct samldb_msds_intid_persistant {
uint32_t msds_intid;
- uint64_t usn;
};
#define SAMLDB_MSDS_INTID_OPAQUE "SAMLDB_MSDS_INTID_OPAQUE"