On Thu, Oct 16, 2014 at 4:25 PM, Stefan Sperling <s...@elego.de> wrote:

> On Tue, Sep 30, 2014 at 11:44:04AM +0200, Stefan Fuhrmann wrote:
> > On Tue, Sep 30, 2014 at 11:15 AM, Stefan Sperling <s...@apache.org>
> wrote:
> > > How do you open a transaction and postpone the commit?
> > > Using some custom code written against the FS API?
> > >
> >
> > It would require some custom code like "create greek tree,
> > create txn, modify a few nodes" on one side and "open the
> > only available txn, commit txn" on the other side.
>
> Do you have some example or starting point for that somewhere?
>

I attached a test that should do the right thing.
Execute the first two steps on separate architectures
and the 3rd one on an arch of your choice.


> > > Or can some tool such as svnmucc already do this?
> > >
> >
> > svnadmin can only list and remove txns. svnmucc
> >
>
> svnmucc what? :)
>

Hm ... don't quite remember. Probably something
along the line of "starts, builds up and commits
a txn in a single call". Basically, hard to use for
the purpose at hand.


> > > I presume you rely on apr_off_t, not off_t, right?
> >
> >
> > Yes, I always use apr_off_t. On my system, APR typedefs
> > it as off_t.
>
> off_t is always 64bit on OpenBSD, so I could only test little/big endian
> variance. Unless perhaps if I patched APR to use a 32bit type for off_t.
>

It would certainly be interesting to a) find systems
in the wild that still uses 32 bit off_t and b) for us to
check whether we still work on them.


> Would it be possible to test this in our regression test suite somehow?
>

That's probably hard unless we find a setup with
genuine 32 bit off_t because APR uses it directly
with lseek() and friends. So, we can't just redefine it.
Even the ILP32 bb-openbsd buildbot has 64 off_t.

-- Stefan^2.
/* distributed-test.c --- tests distributed transactions
 *
 * ====================================================================
 *    Licensed to the Apache Software Foundation (ASF) under one
 *    or more contributor license agreements.  See the NOTICE file
 *    distributed with this work for additional information
 *    regarding copyright ownership.  The ASF licenses this file
 *    to you under the Apache License, Version 2.0 (the
 *    "License"); you may not use this file except in compliance
 *    with the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing,
 *    software distributed under the License is distributed on an
 *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 *    KIND, either express or implied.  See the License for the
 *    specific language governing permissions and limitations
 *    under the License.
 * ====================================================================
 */

#include "../svn_test_fs.h"

/* Make this point to the shared repository location if it is not local
 * to the current folder.
 */
const char *repo_name = "test-repo-distributed";

/*-----------------------------------------------------------------*/


static svn_error_t *
create_transaction(const svn_test_opts_t *opts,
                   apr_pool_t *pool)
{
  svn_repos_t *repos;
  svn_fs_t *fs;
  svn_fs_txn_t *txn;
  svn_fs_root_t *txn_root;

  /* Create a filesystem */
  SVN_ERR(svn_test__create_repos(&repos, repo_name, opts, pool));
  fs = svn_repos_fs(repos);

  /* Add the Greek tree */
  SVN_ERR(svn_fs_begin_txn2(&txn, fs, 0, 0, pool));
  SVN_ERR(svn_fs_txn_root(&txn_root, txn, pool));
  SVN_ERR(svn_test__create_greek_tree(txn_root, pool));

  return SVN_NO_ERROR;
}

static svn_error_t *
commit_transaction(const svn_test_opts_t *opts,
                   apr_pool_t *pool)
{
  svn_repos_t *repos;
  svn_fs_t *fs;
  apr_array_header_t *txn_list;
  const char *txn_name;
  svn_fs_txn_t *txn;
  svn_revnum_t rev;

  /* Reopen the filesystem */
  SVN_ERR(svn_repos_open3(&repos, repo_name, NULL, pool, pool));
  fs = svn_repos_fs(repos);

  /* Reopen the first transaction that we can find */
  /* There should be exactly one left. */
  SVN_ERR(svn_fs_list_transactions(&txn_list, fs, pool));
  txn_name = APR_ARRAY_IDX(txn_list, 0, const char *);

  /* Check the list. It should have *exactly* two entries. */
  SVN_ERR(svn_fs_open_txn(&txn, fs, txn_name, pool));
  SVN_ERR(svn_fs_commit_txn(NULL, &rev, txn, pool));

  return SVN_NO_ERROR;
}

static svn_error_t *
verify_repository(const svn_test_opts_t *opts,
                  apr_pool_t *pool)
{
  svn_repos_t *repos;

  /* Reopen the filesystem */
  SVN_ERR(svn_repos_open3(&repos, repo_name, NULL, pool, pool));
  SVN_ERR(svn_repos_verify_fs3(repos, SVN_INVALID_REVNUM, SVN_INVALID_REVNUM,
                               FALSE, FALSE, FALSE, NULL, NULL, NULL, NULL,
                               pool));

  return SVN_NO_ERROR;
}


/* ------------------------------------------------------------------------ */

/* The test table.  */

static int max_threads = 1;

static struct svn_test_descriptor_t test_funcs[] =
  {
    SVN_TEST_NULL,
    SVN_TEST_OPTS_PASS(create_transaction,
                       "create transaction"),
    SVN_TEST_OPTS_PASS(commit_transaction,
                       "commit transaction"),
    SVN_TEST_OPTS_PASS(verify_repository,
                       "verify repository"),
    SVN_TEST_NULL
  };

SVN_TEST_MAIN

Reply via email to