public override void Commit(string id) { EsentTransactionContext context; if (transactionContexts.TryGetValue(id, out context) == false) { throw new InvalidOperationException("There is no transaction with id: " + id + " ready to commit. Did you call PrepareTransaction?"); } lock (context) { //using(context.Session) - disposing the session is actually done in the rollback, which is always called using (context.EnterSessionContext()) { context.Transaction.Commit(txMode); if (context.DocumentIdsToTouch != null) { using (docDb.DocumentLock.Lock()) { using (storage.DisableBatchNesting()) { storage.Batch(accessor => { foreach (var docId in context.DocumentIdsToTouch) { docDb.CheckReferenceBecauseOfDocumentUpdate(docId, accessor); try { Etag preTouchEtag; Etag afterTouchEtag; accessor.Documents.TouchDocument(docId, out preTouchEtag, out afterTouchEtag); } catch (ConcurrencyException) { log.Info("Concurrency exception when touching {0}", docId); } } }); } } } foreach (var afterCommit in context.ActionsAfterCommit) { afterCommit(); } } } }