From 4afaafdc770612185c4e11d3f09226ce168462a5 Mon Sep 17 00:00:00 2001 From: Greg Soltis Date: Thu, 22 Mar 2018 15:45:05 -0700 Subject: Change write groups to use transactions (#912) * Start work on leveldb transactions * Style * Working API. Not plumbed in yet * Move files into correct place * Wrangling file locations and associations * Tests pass * Add some comments * style * Fix copyright * Rewrite iterator internals to handle deletion-while-iterating. Also add tests for same * Switch to strings instead of slices * Style * More style fixes * Start switching writegroup over * Swap out write group tracking for transaction usage * Style * Response to feedback before updating docs * Style * Add comment * Initialize version_ * Satisfy the linter * Start switching writegroup over * Swap out write group tracking for transaction usage * Style * Checkpoint before implementing BatchDescription * Style * Everything passing * Drop unused function * Style * Renaming * Style * Add log line * Style * Add debug log line for commits, drop unused BatchDescription --- .../core/src/firebase/firestore/local/leveldb_transaction.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'Firestore/core/src/firebase/firestore/local') diff --git a/Firestore/core/src/firebase/firestore/local/leveldb_transaction.cc b/Firestore/core/src/firebase/firestore/local/leveldb_transaction.cc index 4e4a313..d6c9799 100644 --- a/Firestore/core/src/firebase/firestore/local/leveldb_transaction.cc +++ b/Firestore/core/src/firebase/firestore/local/leveldb_transaction.cc @@ -20,6 +20,7 @@ #include "Firestore/core/src/firebase/firestore/local/leveldb_key.h" #include "Firestore/core/src/firebase/firestore/util/firebase_assert.h" +#include "Firestore/core/src/firebase/firestore/util/log.h" using leveldb::DB; using leveldb::ReadOptions; @@ -202,9 +203,14 @@ void LevelDbTransaction::Commit() { batch.Put(it->first, it->second); } + if (util::LogGetLevel() <= util::kLogLevelDebug) { + util::LogDebug("Committing transaction: %s", ToString().c_str()); + } + Status status = db_->Write(write_options_, &batch); - FIREBASE_ASSERT_MESSAGE(status.ok(), "Failed to commit transaction: %s", - status.ToString().c_str()); + FIREBASE_ASSERT_MESSAGE(status.ok(), + "Failed to commit transaction:\n%s\n Failed: %s", + ToString().c_str(), status.ToString().c_str()); } std::string LevelDbTransaction::ToString() { -- cgit v1.2.3