From 01f204010e76d37aaee46da3aa80c6ba779e9d35 Mon Sep 17 00:00:00 2001 From: David Bremner Date: Sun, 26 Jun 2016 17:29:43 +0200 Subject: [PATCH] [PATCH 1/3] Use the Xapian::DB_RETRY_LOCK flag when available --- 72/033582f32c1abe353a1aabcfe1e13655a729cc | 177 ++++++++++++++++++++++ 1 file changed, 177 insertions(+) create mode 100644 72/033582f32c1abe353a1aabcfe1e13655a729cc diff --git a/72/033582f32c1abe353a1aabcfe1e13655a729cc b/72/033582f32c1abe353a1aabcfe1e13655a729cc new file mode 100644 index 000000000..d8f370df3 --- /dev/null +++ b/72/033582f32c1abe353a1aabcfe1e13655a729cc @@ -0,0 +1,177 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by arlo.cworth.org (Postfix) with ESMTP id D26B16DE091F + for ; Sun, 26 Jun 2016 08:30:15 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: -0.005 +X-Spam-Level: +X-Spam-Status: No, score=-0.005 tagged_above=-999 required=5 + tests=[AWL=-0.006, HEADER_FROM_DIFFERENT_DOMAINS=0.001] + autolearn=disabled +Received: from arlo.cworth.org ([127.0.0.1]) + by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id AexM4RKrpVXv for ; + Sun, 26 Jun 2016 08:30:06 -0700 (PDT) +Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) + by arlo.cworth.org (Postfix) with ESMTPS id 90D5A6DE01C2 + for ; Sun, 26 Jun 2016 08:30:06 -0700 (PDT) +Received: from remotemail by fethera.tethera.net with local (Exim 4.84) + (envelope-from ) + id 1bHC0K-00023H-9K; Sun, 26 Jun 2016 11:29:48 -0400 +Received: (nullmailer pid 26559 invoked by uid 1000); + Sun, 26 Jun 2016 15:29:48 -0000 +From: David Bremner +To: notmuch@notmuchmail.org +Subject: [PATCH 1/3] Use the Xapian::DB_RETRY_LOCK flag when available +Date: Sun, 26 Jun 2016 17:29:43 +0200 +Message-Id: <1466954985-25761-2-git-send-email-david@tethera.net> +X-Mailer: git-send-email 2.8.1 +In-Reply-To: <1466954985-25761-1-git-send-email-david@tethera.net> +References: <1466954985-25761-1-git-send-email-david@tethera.net> +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.20 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Sun, 26 Jun 2016 15:30:16 -0000 + +From: Istvan Marko + +Xapian 1.3 has introduced the DB_RETRY_LOCK flag (Xapian bug +275). Detect it in configure and optionally use it. With this flag +commands that need the write lock will wait for their turn instead of +aborting when it's not immediately available. + +Amended by db: allow disabling in configure +--- + configure | 35 +++++++++++++++++++++++++++++++++++ + lib/database.cc | 8 +++++++- + 2 files changed, 42 insertions(+), 1 deletion(-) + +diff --git a/configure b/configure +index 49fa5b9..ae0a027 100755 +--- a/configure ++++ b/configure +@@ -72,6 +72,7 @@ WITH_EMACS=1 + WITH_BASH=1 + WITH_RUBY=1 + WITH_ZSH=1 ++WITH_RETRY_LOCK=1 + + usage () + { +@@ -140,6 +141,7 @@ Some features can be disabled (--with-feature=no is equivalent to + --without-emacs Do not install lisp file + --without-ruby Do not install ruby bindings + --without-zsh-completion Do not install zsh completions files ++ --without-retry-lock Do not use blocking xapian opens, even if available + + Additional options are accepted for compatibility with other + configure-script calling conventions, but don't do anything yet: +@@ -211,6 +213,14 @@ for option; do + fi + elif [ "${option}" = '--without-ruby' ] ; then + WITH_RUBY=0 ++ elif [ "${option%%=*}" = '--with-retry-lock' ]; then ++ if [ "${option#*=}" = 'no' ]; then ++ WITH_RETRY_LOCK=0 ++ else ++ WITH_RETRY_LOCK=1 ++ fi ++ elif [ "${option}" = '--without-retry-lock' ] ; then ++ WITH_RETRY_LOCK=0 + elif [ "${option%%=*}" = '--with-zsh-completion' ]; then + if [ "${option#*=}" = 'no' ]; then + WITH_ZSH=0 +@@ -392,6 +402,24 @@ EOF + rm -f _field_processor.o _field_processor.cc + + default_xapian_backend="" ++ # DB_RETRY_LOCK is only supported on Xapian > 1.3.2 ++ have_xapian_db_retry_lock=0 ++ if [ $WITH_RETRY_LOCK = "1" ]; then ++ printf "Checking for Xapian lock retry support... " ++ cat>_retry.cc< ++int flag = Xapian::DB_RETRY_LOCK; ++EOF ++ if ${CXX} ${CXXFLAGS_for_sh} ${xapian_cxxflags} -c _retry.cc -o _retry.o > /dev/null 2>&1 ++ then ++ have_xapian_db_retry_lock=1 ++ printf "Yes.\n" ++ else ++ printf "No. (optional)\n" ++ fi ++ rm -f _retry.o _retry.cc ++ fi ++ + printf "Testing default Xapian backend... " + cat >_default_backend.cc < +@@ -1022,6 +1050,9 @@ HAVE_XAPIAN_COMPACT = ${have_xapian_compact} + # Whether the Xapian version in use supports field processors + HAVE_XAPIAN_FIELD_PROCESSOR = ${have_xapian_field_processor} + ++# Whether the Xapian version in use supports DB_RETRY_LOCK ++HAVE_XAPIAN_DB_RETRY_LOCK = ${have_xapian_db_retry_lock} ++ + # Whether the getpwuid_r function is standards-compliant + # (if not, then notmuch will #define _POSIX_PTHREAD_SEMANTICS + # to enable the standards-compliant version -- needed for Solaris) +@@ -1097,6 +1128,7 @@ COMMON_CONFIGURE_CFLAGS = \\ + -DSTD_ASCTIME=\$(STD_ASCTIME) \\ + -DHAVE_XAPIAN_COMPACT=\$(HAVE_XAPIAN_COMPACT) \\ + -DHAVE_XAPIAN_FIELD_PROCESSOR=\$(HAVE_XAPIAN_FIELD_PROCESSOR) \\ ++ -DHAVE_XAPIAN_DB_RETRY_LOCK=\$(HAVE_XAPIAN_DB_RETRY_LOCK) \\ + -DUTIL_BYTE_ORDER=\$(UTIL_BYTE_ORDER) + + CONFIGURE_CFLAGS = \$(COMMON_CONFIGURE_CFLAGS) +@@ -1117,6 +1149,9 @@ NOTMUCH_HAVE_XAPIAN_COMPACT=${have_xapian_compact} + # Whether the Xapian version in use supports field processors + NOTMUCH_HAVE_XAPIAN_FIELD_PROCESSOR=${have_xapian_field_processor} + ++# Whether the Xapian version in use supports lock retry ++NOTMUCH_HAVE_XAPIAN_DB_RETRY_LOCK=${have_xapian_db_retry_lock} ++ + # Which backend will Xapian use by default? + NOTMUCH_DEFAULT_XAPIAN_BACKEND=${default_xapian_backend} + +diff --git a/lib/database.cc b/lib/database.cc +index afafe88..66ee267 100644 +--- a/lib/database.cc ++++ b/lib/database.cc +@@ -49,6 +49,12 @@ typedef struct { + #define STRINGIFY(s) _SUB_STRINGIFY(s) + #define _SUB_STRINGIFY(s) #s + ++#if HAVE_XAPIAN_DB_RETRY_LOCK ++#define DB_ACTION (Xapian::DB_CREATE_OR_OPEN | Xapian::DB_RETRY_LOCK) ++#else ++#define DB_ACTION Xapian::DB_CREATE_OR_OPEN ++#endif ++ + /* Here's the current schema for our database (for NOTMUCH_DATABASE_VERSION): + * + * We currently have three different types of documents (mail, ghost, +@@ -939,7 +945,7 @@ notmuch_database_open_verbose (const char *path, + + if (mode == NOTMUCH_DATABASE_MODE_READ_WRITE) { + notmuch->xapian_db = new Xapian::WritableDatabase (xapian_path, +- Xapian::DB_CREATE_OR_OPEN); ++ DB_ACTION); + } else { + notmuch->xapian_db = new Xapian::Database (xapian_path); + } +-- +2.8.1 + -- 2.26.2