Return-Path: X-Original-To: apmail-subversion-commits-archive@minotaur.apache.org Delivered-To: apmail-subversion-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 07A8711607 for ; Tue, 12 Aug 2014 15:05:41 +0000 (UTC) Received: (qmail 55160 invoked by uid 500); 12 Aug 2014 15:05:40 -0000 Delivered-To: apmail-subversion-commits-archive@subversion.apache.org Received: (qmail 55133 invoked by uid 500); 12 Aug 2014 15:05:40 -0000 Mailing-List: contact commits-help@subversion.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@subversion.apache.org Delivered-To: mailing list commits@subversion.apache.org Received: (qmail 55123 invoked by uid 99); 12 Aug 2014 15:05:40 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 12 Aug 2014 15:05:40 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 12 Aug 2014 15:05:17 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 2B3CE2388868; Tue, 12 Aug 2014 15:05:16 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1617500 - /subversion/trunk/subversion/tests/libsvn_fs/fs-test.c Date: Tue, 12 Aug 2014 15:05:16 -0000 To: commits@subversion.apache.org From: philip@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140812150516.2B3CE2388868@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: philip Date: Tue Aug 12 15:05:15 2014 New Revision: 1617500 URL: http://svn.apache.org/r1617500 Log: Modify reopen_modify so it demonstrates the FSFS txn_dir_cache out-of-date problem. * subversion/tests/libsvn_fs/fs-test.c (struct reopen_modify_baton_t): New. (reopen_modify_child): New. (reopen_modify): Invoke a thread to make second change. (test_funcs): Mark reopen_modify WIMP. Modified: subversion/trunk/subversion/tests/libsvn_fs/fs-test.c Modified: subversion/trunk/subversion/tests/libsvn_fs/fs-test.c URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_fs/fs-test.c?rev=1617500&r1=1617499&r2=1617500&view=diff ============================================================================== --- subversion/trunk/subversion/tests/libsvn_fs/fs-test.c (original) +++ subversion/trunk/subversion/tests/libsvn_fs/fs-test.c Tue Aug 12 15:05:15 2014 @@ -23,6 +23,7 @@ #include #include #include +#include #include #include "../svn_test.h" @@ -37,6 +38,7 @@ #include "svn_props.h" #include "svn_version.h" +#include "svn_private_config.h" #include "private/svn_fs_util.h" #include "private/svn_fs_private.h" @@ -5307,19 +5309,58 @@ dir_prop_merge(const svn_test_opts_t *op return SVN_NO_ERROR; } +#if APR_HAS_THREADS +struct reopen_modify_baton_t { + const char *fs_path; + const char *txn_name; + apr_pool_t *pool; + svn_error_t *err; +}; + +static void * APR_THREAD_FUNC +reopen_modify_child(apr_thread_t *tid, void *data) +{ + struct reopen_modify_baton_t *baton = data; + svn_fs_t *fs; + svn_fs_txn_t *txn; + svn_fs_root_t *root; + + baton->err = svn_fs_open(&fs, baton->fs_path, NULL, baton->pool); + if (baton->err) + return NULL; + baton->err = svn_fs_open_txn(&txn, fs, baton->txn_name, baton->pool); + if (baton->err) + return NULL; + baton->err = svn_fs_txn_root(&root, txn, baton->pool); + if (baton->err) + return NULL; + baton->err = svn_fs_change_node_prop(root, "A", "name", + svn_string_create("value", baton->pool), + baton->pool); + svn_pool_destroy(baton->pool); + return NULL; +} +#endif + static svn_error_t * reopen_modify(const svn_test_opts_t *opts, apr_pool_t *pool) { +#if APR_HAS_THREADS svn_fs_t *fs; svn_revnum_t head_rev = 0; - svn_fs_root_t *root, *reopen_root; - svn_fs_txn_t *txn, *reopen_txn; - const char *txn_name; + svn_fs_root_t *root; + svn_fs_txn_t *txn; + const char *fs_path, *txn_name; svn_string_t *value; + struct reopen_modify_baton_t baton; + apr_status_t status, child_status; + apr_threadattr_t *tattr; + apr_thread_t *tid; /* Create test repository with greek tree. */ - SVN_ERR(svn_test__create_fs(&fs, "test-reopen-modify", opts, pool)); + fs_path = "test-reopen-modify"; + SVN_ERR(svn_test__create_fs(&fs, fs_path, opts, pool)); SVN_ERR(svn_fs_begin_txn(&txn, fs, head_rev, pool)); SVN_ERR(svn_fs_txn_root(&root, txn, pool)); SVN_ERR(svn_test__create_greek_tree(root, pool)); @@ -5331,22 +5372,36 @@ reopen_modify(const svn_test_opts_t *opt SVN_ERR(svn_fs_txn_root(&root, txn, pool)); SVN_ERR(svn_fs_make_dir(root, "X", pool)); - /* Reopen, add more changes. */ - SVN_ERR(svn_fs_open_txn(&reopen_txn, fs, txn_name, pool)); - SVN_ERR(svn_fs_txn_root(&reopen_root, reopen_txn, pool)); - SVN_ERR(svn_fs_change_node_prop(reopen_root, "A", "name", - svn_string_create("value", pool), - pool)); - - /* Reopen, commit */ - SVN_ERR(svn_fs_open_txn(&reopen_txn, fs, txn_name, pool)); - SVN_ERR(test_commit_txn(&head_rev, reopen_txn, NULL, pool)); + /* In another thread: reopen fs and txn, and add more changes. This + works in BDB and FSX but in FSFS the txn_dir_cache becomes + out-of-date and the thread's changes don't reach the revision. */ + baton.fs_path = fs_path; + baton.txn_name = txn_name; + baton.pool = svn_pool_create(pool); + status = apr_threadattr_create(&tattr, pool); + if (status) + return svn_error_wrap_apr(status, _("Can't create threadattr")); + status = apr_thread_create(&tid, tattr, reopen_modify_child, &baton, pool); + if (status) + return svn_error_wrap_apr(status, _("Can't create thread")); + status = apr_thread_join(&child_status, tid); + if (status) + return svn_error_wrap_apr(status, _("Can't join thread")); + if (baton.err) + return svn_error_trace(baton.err); + + /* Commit */ + SVN_ERR(test_commit_txn(&head_rev, txn, NULL, pool)); + /* Check for change made by thread. */ SVN_ERR(svn_fs_revision_root(&root, fs, head_rev, pool)); SVN_ERR(svn_fs_node_prop(&value, root, "A", "name", pool)); SVN_TEST_ASSERT(value && !strcmp(value->data, "value")); return SVN_NO_ERROR; +#else + return svn_error_create(SVN_ERR_TEST_SKIPPED, NULL, "no thread support"); +#endif } @@ -5444,8 +5499,9 @@ static struct svn_test_descriptor_t test "test svn_fs__compatible_version"), SVN_TEST_OPTS_PASS(dir_prop_merge, "test merge directory properties"), - SVN_TEST_OPTS_PASS(reopen_modify, - "test reopen and modify txn"), + SVN_TEST_OPTS_WIMP(reopen_modify, + "test reopen and modify txn", + "txn_dir_cache fail in FSFS"), SVN_TEST_NULL };