You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2014/10/11 18:14:28 UTC

svn commit: r1631075 - in /subversion/trunk/subversion: libsvn_fs_fs/fs.h libsvn_fs_fs/fs_fs.c libsvn_fs_fs/structure libsvn_fs_fs/util.c tests/libsvn_fs/fs-test.c

Author: stefan2
Date: Sat Oct 11 16:14:28 2014
New Revision: 1631075

URL: http://svn.apache.org/r1631075
Log:
Make FSFS format 7 use a different name for the 'transactions' folder.

This is somewhat similar to what happened during the f1/f2->f3 upgrade
which made old code either succeed with a commit or fail in various
places when the format upgrade already had an impact on the contents.

With this change, however, old servers will not be able to even access
txns after the upgrade and will consistently see ENOENT errors.  Hence,
they can't write to the repo.  New servers will only be able to continue
transactions after a hot upgrade when they refresh their format info
as done in e.g. r1627949.

* subversion/libsvn_fs_fs/fs.h
  (PATH_TXNS_DIR): Document that this is only valid for pre-f7 repos.
  (PATH_TXNS_LA_DIR): New path constant.

* subversion/libsvn_fs_fs/fs_fs.c
  (upgrade_body): Rename the txns dir if the repo has been pre-f7.
                  Be sure to revert that if the upgrade process failed.

* subversion/libsvn_fs_fs/util.c
  (svn_fs_fs__path_txns_dir): Return the now format-dependent txns folder.

* subversion/libsvn_fs_fs/structure
  (Layout of the FS directory): Document how the txns folder name depends
                                on the repo format.

* subversion/tests/libsvn_fs/fs-test.c
  (upgrade_while_committing): Adapt test case. Any txn access with an
                              outdated svn_fs_t will now fail with ENOENT.

Modified:
    subversion/trunk/subversion/libsvn_fs_fs/fs.h
    subversion/trunk/subversion/libsvn_fs_fs/fs_fs.c
    subversion/trunk/subversion/libsvn_fs_fs/structure
    subversion/trunk/subversion/libsvn_fs_fs/util.c
    subversion/trunk/subversion/tests/libsvn_fs/fs-test.c

Modified: subversion/trunk/subversion/libsvn_fs_fs/fs.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/fs.h?rev=1631075&r1=1631074&r2=1631075&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/fs.h (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/fs.h Sat Oct 11 16:14:28 2014
@@ -58,7 +58,10 @@ extern "C" {
 #define PATH_PACK_LOCK_FILE   "pack-lock"        /* Pack lock file */
 #define PATH_REVS_DIR         "revs"             /* Directory of revisions */
 #define PATH_REVPROPS_DIR     "revprops"         /* Directory of revprops */
-#define PATH_TXNS_DIR         "transactions"     /* Directory of transactions */
+#define PATH_TXNS_DIR         "transactions"     /* Directory of transactions in
+                                                    repos w/o log addressing */
+#define PATH_TXNS_LA_DIR      "transactions-la"  /* Directory of transactions in
+                                                    repos with log addressing */
 #define PATH_NODE_ORIGINS_DIR "node-origins"     /* Lazy node-origin cache */
 #define PATH_TXN_PROTOS_DIR   "txn-protorevs"    /* Directory of proto-revs */
 #define PATH_TXN_CURRENT      "txn-current"      /* File with next txn key */

Modified: subversion/trunk/subversion/libsvn_fs_fs/fs_fs.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/fs_fs.c?rev=1631075&r1=1631074&r2=1631075&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/fs_fs.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/fs_fs.c Sat Oct 11 16:14:28 2014
@@ -1177,6 +1177,8 @@ upgrade_body(void *baton, apr_pool_t *po
   const char *format_path = path_format(fs, pool);
   svn_node_kind_t kind;
   svn_boolean_t needs_revprop_shard_cleanup = FALSE;
+  svn_error_t* err;
+  const char *txns_dir;
 
   /* Read the FS format number and max-files-per-dir setting. */
   SVN_ERR(read_format(&format, &max_files_per_dir, &min_log_addressing_rev,
@@ -1204,6 +1206,9 @@ upgrade_body(void *baton, apr_pool_t *po
   if (format == SVN_FS_FS__FORMAT_NUMBER)
     return SVN_NO_ERROR;
 
+  /* Remember the current 'transactions' dir path */
+  txns_dir = svn_fs_fs__path_txns_dir(fs, pool);
+
   /* If our filesystem predates the existence of the 'txn-current
      file', make that file and its corresponding lock file. */
   if (format < SVN_FS_FS__MIN_TXN_CURRENT_FORMAT)
@@ -1269,13 +1274,31 @@ upgrade_body(void *baton, apr_pool_t *po
      accidentally uses outdated information.  Keep the UUID. */
   SVN_ERR(svn_fs_fs__set_uuid(fs, fs->uuid, NULL, pool));
 
+  /* Rename the 'transactions' folder */
+  if (format < SVN_FS_FS__MIN_LOG_ADDRESSING_FORMAT)
+    SVN_ERR(svn_io_file_rename(txns_dir, svn_fs_fs__path_txns_dir(fs, pool),
+                               pool));
+
   /* Bump the format file. */
-  SVN_ERR(svn_fs_fs__write_format(fs, TRUE, pool));
-  if (upgrade_baton->notify_func)
-    SVN_ERR(upgrade_baton->notify_func(upgrade_baton->notify_baton,
-                                       SVN_FS_FS__FORMAT_NUMBER,
-                                       svn_fs_upgrade_format_bumped,
-                                       pool));
+  err = svn_fs_fs__write_format(fs, TRUE, pool);
+  if (err)
+    {
+      /* Something went wrong at the last minute.
+       * Undo the 'transactions' dir rename. */
+      if (format < SVN_FS_FS__MIN_LOG_ADDRESSING_FORMAT)
+        svn_error_compose(err,
+                          svn_io_file_rename(svn_fs_fs__path_txns_dir(fs,
+                                                                      pool),
+                                             txns_dir, pool));
+
+      SVN_ERR(err);
+    }
+  else
+    if (upgrade_baton->notify_func)
+      SVN_ERR(upgrade_baton->notify_func(upgrade_baton->notify_baton,
+                                        SVN_FS_FS__FORMAT_NUMBER,
+                                        svn_fs_upgrade_format_bumped,
+                                        pool));
 
   /* Now, it is safe to remove the redundant revprop files. */
   if (needs_revprop_shard_cleanup)

Modified: subversion/trunk/subversion/libsvn_fs_fs/structure
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/structure?rev=1631075&r1=1631074&r2=1631075&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/structure (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/structure Sat Oct 11 16:14:28 2014
@@ -44,7 +44,9 @@ repository) is:
       <rev>.<count>   Pack file, if the repository has been packed (see below)
       manifest        Pack manifest file, if a pack file exists (see below)
     revprops.db       SQLite database of the packed revision properties
-  transactions/       Subdirectory containing transactions
+  transactions/       Subdirectory containing transactions (format 1 to 6)
+    <txnid>.txn/      Directory containing transaction <txnid>
+  transactions-la/    Subdirectory containing transactions (format 7+)
     <txnid>.txn/      Directory containing transaction <txnid>
   txn-protorevs/      Subdirectory containing transaction proto-revision files
     <txnid>.rev       Proto-revision file for transaction <txnid>

Modified: subversion/trunk/subversion/libsvn_fs_fs/util.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/util.c?rev=1631075&r1=1631074&r2=1631075&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/util.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/util.c Sat Oct 11 16:14:28 2014
@@ -237,7 +237,11 @@ const char *
 svn_fs_fs__path_txns_dir(svn_fs_t *fs,
                          apr_pool_t *pool)
 {
-  return svn_dirent_join(fs->path, PATH_TXNS_DIR, pool);
+  fs_fs_data_t *ffd = fs->fsap_data;
+
+  return ffd->format >= SVN_FS_FS__MIN_LOG_ADDRESSING_FORMAT
+       ? svn_dirent_join(fs->path, PATH_TXNS_LA_DIR, pool)
+       : svn_dirent_join(fs->path, PATH_TXNS_DIR, pool);
 }
 
 const char *

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=1631075&r1=1631074&r2=1631075&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_fs/fs-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_fs/fs-test.c Sat Oct 11 16:14:28 2014
@@ -5411,7 +5411,7 @@ upgrade_while_committing(const svn_test_
   svn_fs_t *fs;
   svn_revnum_t head_rev = 0;
   svn_fs_root_t *root;
-  svn_fs_txn_t *txn;
+  svn_fs_txn_t *txn1, *txn2;
   const char *fs_path;
   apr_hash_t *fs_config = apr_hash_make(pool);
 
@@ -5432,21 +5432,24 @@ upgrade_while_committing(const svn_test_
   SVN_ERR(svn_test__create_fs2(&fs, fs_path, opts, fs_config, pool));
 
   SVN_ERR(svn_fs_open(&fs, fs_path, NULL, pool));
-  SVN_ERR(svn_fs_begin_txn(&txn, fs, head_rev, pool));
-  SVN_ERR(svn_fs_txn_root(&root, txn, pool));
+  SVN_ERR(svn_fs_begin_txn(&txn1, fs, head_rev, pool));
+  SVN_ERR(svn_fs_txn_root(&root, txn1, pool));
   SVN_ERR(svn_test__create_greek_tree(root, pool));
-  SVN_ERR(test_commit_txn(&head_rev, txn, NULL, pool));
+  SVN_ERR(test_commit_txn(&head_rev, txn1, NULL, pool));
+
+  /* Create txn with changes. */
+  SVN_ERR(svn_fs_begin_txn(&txn1, fs, head_rev, pool));
+  SVN_ERR(svn_fs_txn_root(&root, txn1, pool));
+  SVN_ERR(svn_fs_make_dir(root, "/foo", pool));
 
   /* Upgrade filesystem, but keep existing svn_fs_t object. */
   SVN_ERR(svn_fs_upgrade(fs_path, pool));
 
-  /* Create txn with changes. */
-  SVN_ERR(svn_fs_begin_txn(&txn, fs, head_rev, pool));
-  SVN_ERR(svn_fs_txn_root(&root, txn, pool));
-  SVN_ERR(svn_fs_make_dir(root, "/foo", pool));
+  /* Creating a new txn for the old svn_fs_t object shall fail. */
+  SVN_TEST_ASSERT_ERROR(svn_fs_begin_txn(&txn2, fs, head_rev, pool), ENOENT);
 
-  /* Commit txn. */
-  SVN_ERR(test_commit_txn(&head_rev, txn, NULL, pool));
+  /* Committing the already existing txn shall fail as well. */
+  SVN_TEST_ASSERT_ERROR(test_commit_txn(&head_rev, txn1, NULL, pool), ENOENT);
 
   /* Verify filesystem content. */
   SVN_ERR(svn_fs_verify(fs_path, NULL, 0, SVN_INVALID_REVNUM, NULL, NULL,



Re: svn commit: r1631075 - in /subversion/trunk/subversion: libsvn_fs_fs/fs.h libsvn_fs_fs/fs_fs.c libsvn_fs_fs/structure libsvn_fs_fs/util.c tests/libsvn_fs/fs-test.c

Posted by Branko Čibej <br...@wandisco.com>.
On 11.10.2014 18:14, stefan2@apache.org wrote:
> Author: stefan2
> Date: Sat Oct 11 16:14:28 2014
> New Revision: 1631075
>
> URL: http://svn.apache.org/r1631075
> Log:
> Make FSFS format 7 use a different name for the 'transactions' folder.

> --- subversion/trunk/subversion/libsvn_fs_fs/util.c (original)
> +++ subversion/trunk/subversion/libsvn_fs_fs/util.c Sat Oct 11 16:14:28 2014
> @@ -237,7 +237,11 @@ const char *
>  svn_fs_fs__path_txns_dir(svn_fs_t *fs,
>                           apr_pool_t *pool)
>  {
> -  return svn_dirent_join(fs->path, PATH_TXNS_DIR, pool);
> +  fs_fs_data_t *ffd = fs->fsap_data;
> +
> +  return ffd->format >= SVN_FS_FS__MIN_LOG_ADDRESSING_FORMAT
> +       ? svn_dirent_join(fs->path, PATH_TXNS_LA_DIR, pool)
> +       : svn_dirent_join(fs->path, PATH_TXNS_DIR, pool);
>  }

Perhaps:

    const char *const txns_path = 
      (ffd->format >= SVN_FS_FS__MIN_LOG_ADDRESSING_FORMAT
       ? PATH_TXNS_LA_DIR : PATH_TXNS_DIR);
    return svn_dirent_join(fs->path, txns_path, pool);

In any case, please put parentheses around conditional statements.


-- Brane