s4-dsdb: Reduce calls to the ldb layer by reloading less often
authorAndrew Bartlett <abartlet@samba.org>
Thu, 9 Aug 2012 00:21:38 +0000 (10:21 +1000)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 9 Aug 2012 02:32:18 +0000 (04:32 +0200)
We do not need to reload the partition list to get the global sequence
number, as that number is stored in the metadata.tdb, not the ldb files.

Andrew Bartlett

source4/dsdb/samdb/ldb_modules/partition.c
source4/dsdb/samdb/ldb_modules/partition_init.c

index d4f020fc5e2e7f5e4a999244832ea509cdeaf989..3533810deb4afb2957992f3ee7cae2fe66bf0ba6 100644 (file)
@@ -1154,14 +1154,6 @@ static int partition_sequence_number(struct ldb_module *module, struct ldb_reque
        struct dsdb_partition *p;
        int ret;
 
-       p = find_partition(data, NULL, req);
-       if (p != NULL) {
-               /* the caller specified what partition they want the
-                * sequence number operation on - just pass it on
-                */
-               return ldb_next_request(p->module, req);
-       }
-
        seq = talloc_get_type_abort(req->op.extended.data, struct ldb_seqnum_request);
        switch (seq->type) {
        case LDB_SEQ_NEXT:
@@ -1172,6 +1164,26 @@ static int partition_sequence_number(struct ldb_module *module, struct ldb_reque
                break;
 
        case LDB_SEQ_HIGHEST_SEQ:
+
+               /* 
+                * We can only query per-partition the individual
+                * partition sequence number, so we don't need to run
+                * this reload for every query of the next global seq
+                * number 
+                */
+               ret = partition_reload_if_required(module, data, req);
+               if (ret != LDB_SUCCESS) {
+                       return ret;
+               }
+               
+               p = find_partition(data, NULL, req);
+               if (p != NULL) {
+                       /* the caller specified what partition they want the
+                        * sequence number operation on - just pass it on
+                        */
+                       return ldb_next_request(p->module, req);
+               }
+
                ret = partition_metadata_sequence_number(module, &seq_number);
                if (ret != LDB_SUCCESS) {
                        return ret;
@@ -1221,12 +1233,6 @@ static int partition_extended(struct ldb_module *module, struct ldb_request *req
                ret = partition_metadata_inc_schema_sequence(module);
                return ldb_module_done(req, NULL, NULL, ret);
        }
-
-       /* see if we are still up-to-date */
-       ret = partition_reload_if_required(module, data, req);
-       if (ret != LDB_SUCCESS) {
-               return ret;
-       }
        
        if (strcmp(req->op.extended.oid, LDB_EXTENDED_SEQUENCE_NUMBER) == 0) {
                return partition_sequence_number(module, req);
index dc09e13feba25dc736470e9aab81ccc653bb0c55..a0770ccd6f902c2c8acdfe3c003989d9c21c50d9 100644 (file)
@@ -707,6 +707,12 @@ int partition_create(struct ldb_module *module, struct ldb_request *req)
                return LDB_ERR_UNWILLING_TO_PERFORM;
        }
 
+       /* see if we are still up-to-date */
+       ret = partition_reload_if_required(module, data, req);
+       if (ret != LDB_SUCCESS) {
+               return ret;
+       }
+
        for (i=0; data->partitions && data->partitions[i]; i++) {
                if (ldb_dn_compare(data->partitions[i]->ctrl->dn, dn) == 0) {
                        partition = data->partitions[i];