On Sun, Nov 25, 2007 at 08:49:22AM +0000, Pierre Habouzit wrote: > On Sun, Nov 25, 2007 at 08:26:24AM +0000, Mikio Hirabayashi wrote: > > Hi, > > > > > being one of the bogofilter maintainers, I have some questions to QDBM's > > > future, Tokyo Cabinet's behaviour and benchmark. > > > > > > First of all, it's good to see that your database libraries are > > > evolving, and apparently to their advantage. Thanks a lot for your hard > > > work and dedication. > > > > Thanks for testing TC for your great project. > > I'm happy if TC can help it. > > > > > - What is the future of QDBM? Will it be developed further? > > > Will it receive bug fixes? > > > > Though I don't plan to add new feature to QDBM, I'll succeed to maintain > > QDBM and receive bug fixes. > > > > > - Regarding the robustness of TC databases: > > > > > > + How does (a rough sketch is sufficient) TC prevent corruption in > > > "catastrophic situation"? > > > > In my designing ---- > > As for TCHDB (hash database API), the database should not be corrupted even > > under > > catastrophic situation. The robustness is higher than QDBM. > > As for TCBDB (B+ tree database API), the database without transaction can be > > corrupted under catastrophic situation. But, the database within > > transaction > > should not be corrupted. > > Hmm bogofilter uses bdb but without transactions, I didn't knew about > them. That could be worth adding to my patch. I'll try to understand how > the thing works and will probably propose a second patch on top of the > previous then.
Attached is the patch to enable transactions, to apply on top of the current bogofilter trunk. Cheers, -- ·O· Pierre Habouzit ··O [EMAIL PROTECTED] OOO http://www.madism.org
From 7f06e9d90af19cffd8f7ca180f135f711da4ea1d Mon Sep 17 00:00:00 2001
From: Pierre Habouzit <[EMAIL PROTECTED]>
Date: Sun, 25 Nov 2007 14:53:08 +0100
Subject: [PATCH] Add transaction support to bogofilter tokyocabinet datastore.
note: transactions in tokyocabinet are only used in write mode.
Signed-off-by: Pierre Habouzit <[EMAIL PROTECTED]>
---
src/Makefile.am | 2 +-
src/datastore_tc.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++
src/tests/t.frame | 2 +-
3 files changed, 64 insertions(+), 2 deletions(-)
diff --git a/src/Makefile.am b/src/Makefile.am
index db1ef40..fc2e195 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -186,7 +186,7 @@ datastore_SOURCE = datastore_sqlite.c
datastore_opthelp_dummies.c \
else
if ENABLE_TOKYOCABINET_DATASTORE
datastore_SOURCE = datastore_tc.c \
- datastore_txn_dummies.c datastore_opthelp_dummies.c \
+ datastore_opthelp_dummies.c \
datastore_dummies.c
else
if ENABLE_TRANSACTIONS
diff --git a/src/datastore_tc.c b/src/datastore_tc.c
index 0624e2b..f27908d 100644
--- a/src/datastore_tc.c
+++ b/src/datastore_tc.c
@@ -40,6 +40,68 @@ typedef struct {
TCBDB *dbp;
} dbh_t;
+/* transaction stuff */
+
+static int tc_txn_begin(void *vhandle) {
+ dbh_t *dbh = vhandle;
+ if (!dbh->dbp->wmode || tcbdbtranbegin(dbh->dbp))
+ return DST_OK;
+ print_error(__FILE__, __LINE__, "tc_txn_begin(%p), err: %d, %s", dbh->dbp,
+ tcbdbecode(dbh->dbp), tcbdberrmsg(tcbdbecode(dbh->dbp)));
+ return DST_FAILURE;
+}
+
+static int tc_txn_abort(void *vhandle) {
+ dbh_t *dbh = vhandle;
+ if (!dbh->dbp->wmode || tcbdbtranabort(dbh->dbp))
+ return DST_OK;
+ print_error(__FILE__, __LINE__, "tc_txn_abort(%p), err: %d, %s", dbh->dbp,
+ tcbdbecode(dbh->dbp), tcbdberrmsg(tcbdbecode(dbh->dbp)));
+ return DST_FAILURE;
+}
+
+static int tc_txn_commit(void *vhandle) {
+ dbh_t *dbh = vhandle;
+ if (!dbh->dbp->wmode || tcbdbtrancommit(dbh->dbp))
+ return DST_OK;
+ print_error(__FILE__, __LINE__, "tc_txn_commit(%p), err: %d, %s",
+ dbh->dbp, tcbdbecode(dbh->dbp),
+ tcbdberrmsg(tcbdbecode(dbh->dbp)));
+ return DST_FAILURE;
+}
+
+static dsm_t dsm_tc = {
+ /* public -- used in datastore.c */
+ &tc_txn_begin,
+ &tc_txn_abort,
+ &tc_txn_commit,
+
+ /* private -- used in datastore_db_*.c */
+ NULL, /* dsm_env_init */
+ NULL, /* dsm_cleanup */
+ NULL, /* dsm_cleanup_lite */
+ NULL, /* dsm_get_env_dbe */
+ NULL, /* dsm_database_name */
+ NULL, /* dsm_recover_open */
+ NULL, /* dsm_auto_commit_flags*/
+ NULL, /* dsm_get_rmw_flag */
+ NULL, /* dsm_lock */
+ NULL, /* dsm_common_close */
+ NULL, /* dsm_sync */
+ NULL, /* dsm_log_flush */
+ NULL, /* dsm_pagesize */
+ NULL, /* dsm_purgelogs */
+ NULL, /* dsm_checkpoint */
+ NULL, /* dsm_recover */
+ NULL, /* dsm_remove */
+ NULL, /* dsm_verify */
+ NULL, /* dsm_list_logfiles */
+ NULL /* dsm_leafpages */
+};
+
+dsm_t *dsm = &dsm_tc;
+
+
/* Function definitions */
const char *db_version_str(void)
diff --git a/src/tests/t.frame b/src/tests/t.frame
index deb4ce7..ff7719b 100755
--- a/src/tests/t.frame
+++ b/src/tests/t.frame
@@ -44,7 +44,7 @@ case $DB_NAME in
*) DB_TXN=false ;;
esac ;;
*QDBM*) DB_TXN=false ;;
- *Tokyo*) DB_TXN=false ;;
+ *Tokyo*) DB_TXN=true ;;
*SQLite*) DB_TXN=true ;;
*TrivialDB*) DB_TXN=false ;;
*) echo >&2 "Unknown data base type in bogofilter -V: $DB_NAME"
--
1.5.3.6.2015.g9baba
pgpt8AHA3It0k.pgp
Description: PGP signature

