samba-tool: Run samba-tool domain tombstones expunge in a transaction
authorAndrew Bartlett <abartlet@samba.org>
Thu, 1 Sep 2016 00:13:40 +0000 (12:13 +1200)
committerGarming Sam <garming@samba.org>
Thu, 1 Sep 2016 03:49:15 +0000 (05:49 +0200)
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
python/samba/netcmd/domain.py

index 8e89272da506e00879a5717971bb95fa909e0766..928caa3ffda66aa1358d8e62b3bb6dd6b4ae6505 100644 (file)
@@ -3800,15 +3800,22 @@ This command expunges tombstones from the database."""
         else:
             ncs = list(ncs)
 
+        started_transaction = False
         try:
+            samdb.transaction_start()
+            started_transaction = True
             (removed_objects,
              removed_links) = samdb.garbage_collect_tombstones(ncs,
                                                                current_time=current_time,
                                                                tombstone_lifetime=tombstone_lifetime)
 
         except Exception, err:
+            if started_transaction:
+                samdb.transaction_cancel()
             raise CommandError("Failed to expunge / garbage collect tombstones", err)
 
+        samdb.transaction_commit()
+
         self.outf.write("Removed %d objects and %d links successfully\n"
                         % (removed_objects, removed_links))