[SCM] Samba Shared Repository - branch master updated

Andrew Bartlett abartlet at samba.org
Thu Jul 4 11:26:02 UTC 2019


The branch, master has been updated
       via  eaebd8759b9 WHATSNEW: add news the sad passing of python2 support
       via  ad127bce4d7 WHATSNEW: add news about Samba AD at 100,000 scale
       via  f837cd023cf WHATSNEW: ldb_batch mode and join performance
       via  7a0a2fab0c9 domain join: set ldb "transaction_index_cache_size" option
       via  4335f4b4e41 domain join: enable ldb batch mode
       via  86d480ade25 ldb: Release ldb 2.0.5
       via  6226ab3b610 ldb: Rework index_transaction_cache_size to allow caller to specify a larger size
       via  f87472c9e3d ldb ldb_key_value: test ldb batch
       via  652258768ae ldb key_value: Add batch_mode option
       via  7d17dbd10eb s4 samdb: pass ldb options to ldb_module_connect_backend
       via  32f2e390e47 ldb: Add new internal helper function ldb_options_get()
       via  f5832457065 ldb: Fix dependency on ldb_key_value_sub_txn_{mdb_}test
      from  e513bab9617 ldb: Try to explain the confusing overload of the LDB_FLG_MOD_* enumeration and other flags

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit eaebd8759b945e76b7b6d37867d811d3a541650c
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Thu Jul 4 17:43:35 2019 +1200

    WHATSNEW: add news the sad passing of python2 support
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    
    Autobuild-User(master): Andrew Bartlett <abartlet at samba.org>
    Autobuild-Date(master): Thu Jul  4 11:25:07 UTC 2019 on sn-devel-184

commit ad127bce4d7b11cdf36a6c2606ea468875768f11
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Thu Jul 4 17:43:20 2019 +1200

    WHATSNEW: add news about Samba AD at 100,000 scale
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>

commit f837cd023cf1b88b1677d80e273557cfdd554e38
Author: Gary Lockyer <gary at catalyst.net.nz>
Date:   Thu Jul 4 10:00:03 2019 +1200

    WHATSNEW: ldb_batch mode and join performance
    
    Document the join performance improvement, and the ldb "batch_mode"
    option.
    
    Signed-off-by: Gary Lockyer <gary at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 7a0a2fab0c98cf3bef9d4ba4308405aa695fedd0
Author: Gary Lockyer <gary at catalyst.net.nz>
Date:   Wed Jul 3 16:41:59 2019 +1200

    domain join: set ldb "transaction_index_cache_size" option
    
    Set the "transaction_index_cache_size" on a join to improve
    performance. These setting reduced a join to a 100k user domain from
    105 minutes to 44 minutes.
    
    Signed-off-by: Gary Lockyer <gary at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 4335f4b4e411d5c58bd0bd873115cb6c670a789c
Author: Gary Lockyer <gary at catalyst.net.nz>
Date:   Tue Jul 2 12:31:52 2019 +1200

    domain join: enable ldb batch mode
    
    Enable ldb "batch_mode" transactions duting a join to improve
    performance.
    
    Signed-off-by: Gary Lockyer <gary at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 86d480ade25953a175b0837667ce5efb8b7e65df
Author: Gary Lockyer <gary at catalyst.net.nz>
Date:   Thu Jul 4 14:37:31 2019 +1200

    ldb: Release ldb 2.0.5
    
    * add ldb_options_get
      add a function to get the options passed in ldb connect.
    
    * add "batch_mode" option.
      This options stops sub transactions being started for key value
      operations.  It is intended to improve the performance in batch
      operations.  As it bypasses the protections on operations if an
      operation fails, the entire transaction will be aborted by a commit.
    
    Signed-off-by: Gary Lockyer <gary at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 6226ab3b61091af176abbb40e21deebe2529ceb0
Author: Gary Lockyer <gary at catalyst.net.nz>
Date:   Thu Jul 4 16:49:29 2019 +1200

    ldb: Rework index_transaction_cache_size to allow caller to specify a larger size
    
    The previous code would override the caller with the DB size
    estimate rather than allowing the caller to force the bigger size.
    
    Signed-off-by: Gary Lockyer <gary at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit f87472c9e3d70f856eff9b0324cb48d9aed580b3
Author: Gary Lockyer <gary at catalyst.net.nz>
Date:   Tue Jul 2 16:42:44 2019 +1200

    ldb ldb_key_value: test ldb batch
    
    Test the the ldb "batch_mode" option sets batch mode operation.
    
    Signed-off-by: Gary Lockyer <gary at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 652258768ae82f62a5b64464ca52252a7796fbdc
Author: Gary Lockyer <gary at catalyst.net.nz>
Date:   Tue Jul 2 12:30:44 2019 +1200

    ldb key_value: Add batch_mode option
    
    When performing a join the overhead of the sub transactions protecting
    key value operations becomes significant.  This commit adds a new
    "batch_mode" option that disables the sub transactions around key value
    operations.
    
    The operation level index cache is also disabled, which means the
    overall transaction level index cache can become inconsistent if an
    operation fails. To protect against this and other possible on disk
    inconsistencies, if any operation fails during a batch_mode
    transaction the commit will fail and transaction will be rolled back.
    
    Signed-off-by: Gary Lockyer <gary at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 7d17dbd10eb203bd48183fd3527165f244bbf4c4
Author: Gary Lockyer <gary at catalyst.net.nz>
Date:   Thu Jul 4 14:22:29 2019 +1200

    s4 samdb: pass ldb options to ldb_module_connect_backend
    
    Pass the ldb options into ldb_module_connect_backend, to ensure ldb
    options such as "batch mode" and "transaction index cache size" get passed
    through to the backend modules.
    
    Signed-off-by: Gary Lockyer <gary at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 32f2e390e473f01c693d3140d30e20850e87b4c0
Author: Gary Lockyer <gary at catalyst.net.nz>
Date:   Thu Jul 4 16:44:21 2019 +1200

    ldb: Add new internal helper function ldb_options_get()
    
    This is needed for modules to access the ldb->options array, as this in in ldb_private.h
    
    Signed-off-by: Gary Lockyer <gary at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit f58324570655fd9bc08a1ba3923782fb27183917
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Thu Jul 4 14:52:27 2019 +1200

    ldb: Fix dependency on ldb_key_value_sub_txn_{mdb_}test
    
    ldb_tdb can be a module, but the test is actually looking for ltdb_err_map() in
    ldb_tdb_err_map.
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>

-----------------------------------------------------------------------

Summary of changes:
 WHATSNEW.txt                                       | 108 +++++++++++++++++++--
 lib/ldb/ABI/{ldb-2.0.4.sigs => ldb-2.0.5.sigs}     |   1 +
 ...yldb-util-1.1.10.sigs => pyldb-util-2.0.5.sigs} |   0
 lib/ldb/common/ldb_options.c                       |   5 +
 lib/ldb/include/ldb_module.h                       |   7 ++
 lib/ldb/ldb_key_value/ldb_kv.c                     |  63 ++++++++++++
 lib/ldb/ldb_key_value/ldb_kv.h                     |  13 +++
 lib/ldb/ldb_key_value/ldb_kv_index.c               |  16 ++-
 lib/ldb/tests/python/api.py                        |  57 +++++++++++
 lib/ldb/wscript                                    |   6 +-
 python/samba/join.py                               |   4 +-
 python/samba/provision/__init__.py                 |  27 ++++--
 source4/dsdb/samdb/ldb_modules/partition_init.c    |   5 +-
 13 files changed, 281 insertions(+), 31 deletions(-)
 copy lib/ldb/ABI/{ldb-2.0.4.sigs => ldb-2.0.5.sigs} (99%)
 copy lib/ldb/ABI/{pyldb-util-1.1.10.sigs => pyldb-util-2.0.5.sigs} (100%)


Changeset truncated at 500 lines:

diff --git a/WHATSNEW.txt b/WHATSNEW.txt
index 3d6cbbe8dee..cf65bd04ebb 100644
--- a/WHATSNEW.txt
+++ b/WHATSNEW.txt
@@ -49,12 +49,6 @@ where:
 
 The version of the JSON Authentication messages has been changed to 1.2 from 1.1
 
-Reindex performance improvements
---------------------------------
-
-The performance of samba-tool dbcheck --reindex has been improved, especially
-for large domains.
-
 LDAP referrals
 --------------
 
@@ -82,25 +76,100 @@ Log lines are of the form:
     durations are in microseconds.
 
 Default schema updated to 2012_R2
--------------------------
+---------------------------------
 
 Default AD schema changed from 2008_R2 to 2012_R2.  2012_R2 functional level
 is not yet available.  Older schemas can be used by provisioning with the
 '--base-schema' argument.  Existing installations can be updated with the
 samba-tool command "domain schemaupgrade".
 
+Samba's replication code has also been improved to handle replication
+with the 2012 schema (the core of this replication fix has also been
+backported to 4.9.11 and will be in a 4.10.x release).
+
+
+100,000 USER and LARGER Samba AD DOMAINS
+========================================
+
+Extensive efforts have been made to optimise Samba for use in
+organisations (for example) targeting 100,000 users, plus 120,000
+computer objects, as well as large number of group memberships.
+
+Many of the specific efforts are detailed below, but the net results
+is to remove barriers to significantly larger Samba deployments
+compared to previous releases.
+
+Reindex performance improvements
+--------------------------------
+
+The performance of samba-tool dbcheck --reindex has been improved,
+especially for large domains.
+
+join performance improvements
+-----------------------------
+
+The performance of samba-tool domain join has been improved,
+especially for large domains.
+
+LDAP Server memory improvements
+-------------------------------
+
+The LDAP server has improved memory efficiency, ensuring that large
+LDAP responses (for example a search for all objects) is not copied
+multiple times into memory.
+
 Setting lmdb map size
 ---------------------
 
-It is now possible to set the lmdb map size (The maximum permitted size for
-the database).  "samba-tool" now accepts the "--backend-store-size"
-i.e. --backend-store-size=4Gb.  If not specified it defaults to 8Gb.
+It is now possible to set the lmdb map size (The maximum permitted
+size for the database).  "samba-tool" now accepts the
+"--backend-store-size" i.e. --backend-store-size=4Gb.  If not
+specified it defaults to 8Gb.
+
 This option is avaiable for the following sub commands:
  * domain provision
  * domain join
  * domain dcpromo
  * drs clone-dc-database
 
+LDB "batch_mode"
+----------------
+
+To improve performance during batch operations i.e. joins, ldb now
+accepts a "batch_mode" option.  However to prevent any index or
+database inconsistencies if an operation fails, the entire transaction
+will be aborted at commit.
+
+New LDB pack format
+-------------------
+
+On first use (startup of 'samba' or the first transaction write)
+Samba's sam.ldb will be updated to a new more efficient pack format.
+This will take a few moments.
+
+New LDB <= and >= index mode to improve replication performance
+---------------------------------------------------------------
+
+As well as a new pack format, Samba's sam.ldb uses a new index format
+allowing Samba to efficiently select objects changed since the last
+replication cycle.  This in turn improves performance during
+replication of large domains.
+
+Improvements to ldb search performance
+--------------------------------------
+
+Search performance on large LDB databases has been improved by
+reducing memory allocations made on each object.
+
+Improvements to subtree rename performance
+------------------------------------------
+
+Improvements have been made to Samba's handling of subtree renames,
+for example of containers and organisational units, however large
+renames are still not recommended.
+
+
+
 REMOVED FEATURES
 ================
 
@@ -120,6 +189,25 @@ The subdommain role has been removed from the join command.  This option did
 not work and has no tests.
 
 
+Python2 support
+---------------
+
+Samba 4.11 will not have any runtime support for Python 2.
+
+If you are building Samba using the '--disable-python' option
+(i.e. you're excluding all the run-time Python support), then this
+will continue to work on a system that supports either python2 or
+python3.
+
+To build Samba with python2 you *must* set the 'PYTHON' environment
+variable for both the 'configure' and 'make' steps, i.e.
+   'PYTHON=python2 ./configure'
+   'PYTHON=python2 make'
+This will override the python3 default.
+
+Except for this specific build-time use of python2, Samba now requires
+Python 3.4 as a minimum.
+
 smb.conf changes
 ================
 
diff --git a/lib/ldb/ABI/ldb-2.0.4.sigs b/lib/ldb/ABI/ldb-2.0.5.sigs
similarity index 99%
copy from lib/ldb/ABI/ldb-2.0.4.sigs
copy to lib/ldb/ABI/ldb-2.0.5.sigs
index 446804bd95e..5049dc64ce1 100644
--- a/lib/ldb/ABI/ldb-2.0.4.sigs
+++ b/lib/ldb/ABI/ldb-2.0.5.sigs
@@ -198,6 +198,7 @@ ldb_next_start_trans: int (struct ldb_module *)
 ldb_op_default_callback: int (struct ldb_request *, struct ldb_reply *)
 ldb_options_copy: const char **(TALLOC_CTX *, const char **)
 ldb_options_find: const char *(struct ldb_context *, const char **, const char *)
+ldb_options_get: const char **(struct ldb_context *)
 ldb_pack_data: int (struct ldb_context *, const struct ldb_message *, struct ldb_val *, uint32_t)
 ldb_parse_control_from_string: struct ldb_control *(struct ldb_context *, TALLOC_CTX *, const char *)
 ldb_parse_control_strings: struct ldb_control **(struct ldb_context *, TALLOC_CTX *, const char **)
diff --git a/lib/ldb/ABI/pyldb-util-1.1.10.sigs b/lib/ldb/ABI/pyldb-util-2.0.5.sigs
similarity index 100%
copy from lib/ldb/ABI/pyldb-util-1.1.10.sigs
copy to lib/ldb/ABI/pyldb-util-2.0.5.sigs
diff --git a/lib/ldb/common/ldb_options.c b/lib/ldb/common/ldb_options.c
index 0aa80f75159..ee8c7283ada 100644
--- a/lib/ldb/common/ldb_options.c
+++ b/lib/ldb/common/ldb_options.c
@@ -100,3 +100,8 @@ const char **ldb_options_copy(TALLOC_CTX *ctx, const char *options[])
 	}
 	return copy;
 }
+
+const char **ldb_options_get(struct ldb_context *ldb)
+{
+	return ldb->options;
+}
diff --git a/lib/ldb/include/ldb_module.h b/lib/ldb/include/ldb_module.h
index 7f8b57dfeec..ab3d25c5c6e 100644
--- a/lib/ldb/include/ldb_module.h
+++ b/lib/ldb/include/ldb_module.h
@@ -582,4 +582,11 @@ int ldb_unpack_get_format(const struct ldb_val *data,
  */
 void ldb_handle_use_global_event_context(struct ldb_handle *handle);
 
+/**
+ * Get the options passed to ldb_connect.
+ *
+ * This allows the options to be inspected by elements in the module stack
+ *
+ */
+const char **ldb_options_get(struct ldb_context *ldb);
 #endif
diff --git a/lib/ldb/ldb_key_value/ldb_kv.c b/lib/ldb/ldb_key_value/ldb_kv.c
index 56316eb8975..f768fb5e1e4 100644
--- a/lib/ldb/ldb_key_value/ldb_kv.c
+++ b/lib/ldb/ldb_key_value/ldb_kv.c
@@ -471,11 +471,16 @@ static bool ldb_kv_single_valued(const struct ldb_schema_attribute *a,
 
 /*
  * Starts a sub transaction if they are supported by the backend
+ * and the ldb connection has not been opened in batch mode.
  */
 static int ldb_kv_sub_transaction_start(struct ldb_kv_private *ldb_kv)
 {
 	int ret = LDB_SUCCESS;
 
+	if (ldb_kv->batch_mode) {
+		return ret;
+	}
+
 	ret = ldb_kv->kv_ops->begin_nested_write(ldb_kv);
 	if (ret == LDB_SUCCESS) {
 		ret = ldb_kv_index_sub_transaction_start(ldb_kv);
@@ -485,11 +490,16 @@ static int ldb_kv_sub_transaction_start(struct ldb_kv_private *ldb_kv)
 
 /*
  * Commits a sub transaction if they are supported by the backend
+ * and the ldb connection has not been opened in batch mode.
  */
 static int ldb_kv_sub_transaction_commit(struct ldb_kv_private *ldb_kv)
 {
 	int ret = LDB_SUCCESS;
 
+	if (ldb_kv->batch_mode) {
+		return ret;
+	}
+
 	ret = ldb_kv_index_sub_transaction_commit(ldb_kv);
 	if (ret != LDB_SUCCESS) {
 		return ret;
@@ -500,11 +510,16 @@ static int ldb_kv_sub_transaction_commit(struct ldb_kv_private *ldb_kv)
 
 /*
  * Cancels a sub transaction if they are supported by the backend
+ * and the ldb connection has not been opened in batch mode.
  */
 static int ldb_kv_sub_transaction_cancel(struct ldb_kv_private *ldb_kv)
 {
 	int ret = LDB_SUCCESS;
 
+	if (ldb_kv->batch_mode) {
+		return ret;
+	}
+
 	ret = ldb_kv_index_sub_transaction_cancel(ldb_kv);
 	if (ret != LDB_SUCCESS) {
 		struct ldb_context *ldb = ldb_module_get_ctx(ldb_kv->module);
@@ -691,6 +706,7 @@ static int ldb_kv_add(struct ldb_kv_context *ctx)
 				__location__
 				": Unable to roll back sub transaction");
 		}
+		ldb_kv->operation_failed = true;
 		return ret;
 	}
 	ret = ldb_kv_sub_transaction_commit(ldb_kv);
@@ -816,6 +832,9 @@ static int ldb_kv_delete(struct ldb_kv_context *ctx)
 				__location__
 				": Unable to roll back sub transaction");
 		}
+		if (ret != LDB_ERR_NO_SUCH_OBJECT) {
+			ldb_kv->operation_failed = true;
+		}
 		return ret;
 	}
 	ret = ldb_kv_sub_transaction_commit(ldb_kv);
@@ -1380,6 +1399,9 @@ static int ldb_kv_modify(struct ldb_kv_context *ctx)
 				__location__
 				": Unable to roll back sub transaction");
 		}
+		if (ret != LDB_ERR_NO_SUCH_OBJECT) {
+			ldb_kv->operation_failed = true;
+		}
 		return ret;
 	}
 	ret = ldb_kv_sub_transaction_commit(ldb_kv);
@@ -1545,6 +1567,7 @@ static int ldb_kv_rename(struct ldb_kv_context *ctx)
 				": Unable to roll back sub transaction");
 		}
 		talloc_free(msg);
+		ldb_kv->operation_failed = true;
 		return ret;
 	}
 	ret = ldb_kv_sub_transaction_commit(ldb_kv);
@@ -1585,6 +1608,7 @@ static int ldb_kv_start_trans(struct ldb_module *module)
 		ldb_kv->index_transaction_cache_size);
 
 	ldb_kv->reindex_failed = false;
+	ldb_kv->operation_failed = false;
 
 	return LDB_SUCCESS;
 }
@@ -1681,6 +1705,32 @@ static int ldb_kv_end_trans(struct ldb_module *module)
 	struct ldb_kv_private *ldb_kv =
 	    talloc_get_type(data, struct ldb_kv_private);
 
+	/*
+	 * If in batch mode and there has been an operation failure
+	 * rollback the transaction rather than committing it to avoid
+	 * any possible corruption
+	 */
+	if (ldb_kv->batch_mode && ldb_kv->operation_failed) {
+		ret = ldb_kv_del_trans( module);
+		if (ret != LDB_SUCCESS) {
+			ldb_debug_set(ldb_module_get_ctx(module),
+				      LDB_DEBUG_FATAL,
+				      "An operation failed during a batch mode "
+				      "transaction. The transaction could not"
+				      "be rolled back, ldb_kv_del_trans "
+				      "returned (%s, %s)",
+				      ldb_kv->kv_ops->errorstr(ldb_kv),
+				      ldb_strerror(ret));
+		} else {
+			ldb_debug_set(ldb_module_get_ctx(module),
+				      LDB_DEBUG_FATAL,
+				      "An operation failed during a batch mode "
+				      "transaction, the transaction was "
+				      "rolled back");
+		}
+		return LDB_ERR_OPERATIONS_ERROR;
+	}
+
 	if (!ldb_kv->prepared_commit) {
 		ret = ldb_kv_prepare_commit(module);
 		if (ret != LDB_SUCCESS) {
@@ -2226,6 +2276,19 @@ int ldb_kv_init_store(struct ldb_kv_private *ldb_kv,
 			}
 		}
 	}
+	/*
+	 * Set batch mode operation.
+	 * This disables the nested sub transactions, and increases the
+	 * chance of index corruption.  If using this mode the transaction
+	 * commit will be aborted if any operation fails.
+	 */
+	{
+		const char *batch_mode = ldb_options_find(
+			ldb, options, "batch_mode");
+		if (batch_mode != NULL) {
+			ldb_kv->batch_mode = true;
+		}
+	}
 
 	return LDB_SUCCESS;
 }
diff --git a/lib/ldb/ldb_key_value/ldb_kv.h b/lib/ldb/ldb_key_value/ldb_kv.h
index 7ebda13692e..e627644ba34 100644
--- a/lib/ldb/ldb_key_value/ldb_kv.h
+++ b/lib/ldb/ldb_key_value/ldb_kv.h
@@ -98,6 +98,19 @@ struct ldb_kv_private {
 	 * the contents of this cache are copied to idxptr
 	 */
 	struct ldb_kv_idxptr *nested_idx_ptr;
+	/*
+	 * If batch mode is set the sub transactions and index caching
+	 * wrapping individual operations is disabled.
+	 * This is to improve the performance of large batch operations
+	 * i.e. domain joins.
+	 */
+	bool batch_mode;
+	/*
+	 * Has an operation failed, if true and we're in batch_mode
+	 * the transaction commit will fail.
+	 */
+	bool operation_failed;
+
 	bool prepared_commit;
 	int read_lock_count;
 
diff --git a/lib/ldb/ldb_key_value/ldb_kv_index.c b/lib/ldb/ldb_key_value/ldb_kv_index.c
index 4d2ad3b677b..ef275b28013 100644
--- a/lib/ldb/ldb_key_value/ldb_kv_index.c
+++ b/lib/ldb/ldb_key_value/ldb_kv_index.c
@@ -3650,12 +3650,18 @@ int ldb_kv_reindex(struct ldb_module *module)
 	}
 
 	/*
-	 * Calculate the size of the index cache that we'll need for
-	 * the re-index
+	 * Calculate the size of the index cache needed for
+	 * the re-index. If specified always use the
+	 * ldb_kv->index_transaction_cache_size otherwise use the maximum
+	 * of the size estimate or the DEFAULT_INDEX_CACHE_SIZE
 	 */
-	index_cache_size = ldb_kv->kv_ops->get_size(ldb_kv);
-	if (index_cache_size < DEFAULT_INDEX_CACHE_SIZE) {
-		index_cache_size = DEFAULT_INDEX_CACHE_SIZE;
+	if (ldb_kv->index_transaction_cache_size > 0) {
+		index_cache_size = ldb_kv->index_transaction_cache_size;
+	} else {
+		index_cache_size = ldb_kv->kv_ops->get_size(ldb_kv);
+		if (index_cache_size < DEFAULT_INDEX_CACHE_SIZE) {
+			index_cache_size = DEFAULT_INDEX_CACHE_SIZE;
+		}
 	}
 
 	/*
diff --git a/lib/ldb/tests/python/api.py b/lib/ldb/tests/python/api.py
index 933906ce07b..4d55566a4ac 100755
--- a/lib/ldb/tests/python/api.py
+++ b/lib/ldb/tests/python/api.py
@@ -2164,6 +2164,63 @@ class GUIDBadIndexTestsLmdb(BadIndexTests):
         super(GUIDBadIndexTestsLmdb, self).tearDown()
 
 
+class BatchModeTests(LdbBaseTest):
+
+    def setUp(self):
+        super(BatchModeTests, self).setUp()
+        self.testdir = tempdir()
+        self.filename = os.path.join(self.testdir, "test.ldb")
+        self.ldb = ldb.Ldb(self.url(),
+                           flags=self.flags(),
+                           options=["batch_mode:1"])
+        if hasattr(self, 'IDXGUID'):
+            self.ldb.add({"dn": "@INDEXLIST",
+                          "@IDXATTR": [b"x", b"y", b"ou"],
+                          "@IDXGUID": [b"objectUUID"],
+                          "@IDX_DN_GUID": [b"GUID"]})
+        else:
+            self.ldb.add({"dn": "@INDEXLIST",
+                          "@IDXATTR": [b"x", b"y", b"ou"]})
+
+    def test_modify_transaction(self):
+        self.ldb.add({"dn": "x=y,dc=samba,dc=org",
+                      "objectUUID": b"0123456789abcde1",
+                      "y": "2",
+                      "z": "2"})
+
+        res = self.ldb.search(expression="(y=2)",
+                              base="dc=samba,dc=org")
+        self.assertEqual(len(res), 1)
+
+        self.ldb.add({"dn": "@ATTRIBUTES",
+                      "y": "UNIQUE_INDEX"})
+
+        self.ldb.transaction_start()
+
+        m = ldb.Message()
+        m.dn = ldb.Dn(self.ldb, "x=y,dc=samba,dc=org")
+        m["0"] = ldb.MessageElement([], ldb.FLAG_MOD_DELETE, "y")
+        m["1"] = ldb.MessageElement([], ldb.FLAG_MOD_DELETE, "not-here")
+
+        try:
+            self.ldb.modify(m)
+            self.fail()
+
+        except ldb.LdbError as err:
+            enum = err.args[0]
+            self.assertEqual(enum, ldb.ERR_NO_SUCH_ATTRIBUTE)
+
+        try:
+            self.ldb.transaction_commit()
+            self.fail("Commit should have failed as we were in batch mode")
+        except ldb.LdbError as err:
+            enum = err.args[0]
+            self.assertEqual(enum, ldb.ERR_OPERATIONS_ERROR)
+
+    def tearDown(self):
+        super(BatchModeTests, self).tearDown()
+
+
 class DnTests(TestCase):
 
     def setUp(self):
diff --git a/lib/ldb/wscript b/lib/ldb/wscript
index ef92f8f5991..61f6b664902 100644
--- a/lib/ldb/wscript
+++ b/lib/ldb/wscript
@@ -1,7 +1,7 @@
 #!/usr/bin/env python
 
 APPNAME = 'ldb'
-VERSION = '2.0.4'
+VERSION = '2.0.5'
 
 import sys, os
 
@@ -519,7 +519,7 @@ def build(bld):
                                 ldb_kv_cache.c''') +
                          'tests/ldb_key_value_sub_txn_test.c',
                          cflags='-DTEST_BE=\"tdb\"',
-                         deps='cmocka ldb ldb_tdb',
+                         deps='cmocka ldb ldb_tdb_err_map',
                          install=False)
 
         if bld.CONFIG_SET('HAVE_LMDB'):
@@ -561,7 +561,7 @@ def build(bld):
                                     ldb_kv_cache.c''') +
                              'tests/ldb_key_value_sub_txn_test.c',
                              cflags='-DTEST_BE=\"mdb\"',
-                             deps='cmocka ldb ldb_tdb',
+                             deps='cmocka ldb ldb_tdb_err_map',
                              install=False)
         else:
             bld.SAMBA_BINARY('ldb_no_lmdb_test',
diff --git a/python/samba/join.py b/python/samba/join.py


-- 
Samba Shared Repository



More information about the samba-cvs mailing list