Author: cmpilato
Date: Fri Dec 18 00:31:31 2009
New Revision: 892030

URL: http://svn.apache.org/viewvc?rev=892030&view=rev
Log:
On the 'issue-3550-dev' branch, continue teaching the BDB backend to
correctly find and manipulate path change records.

WARNING: This change makes svn_fs_paths_changed2() and friends read
path change records using a BDB transaction.  Back in r847868, I
explicitly made this code not use a BDB transaction, but I can't find
anything that reminds me if that was done because of actual problems
seen, or if it was done pre-emptively.  When I do some testing of lock
usage before and after this change, I see practically no difference in
the output of 'db_stat -c' runs.

* subversion/libsvn_fs_base/fs.h
  (struct transaction_t): Tweak comment for 'changes_id' member to
    correct a typo, but also to no longer indicate that this member
    may be NULL.

* subversion/libsvn_fs_base/bdb/txn-table.c
  (svn_fs_bdb__get_txn): Ensure that the returned transaction_t has a
    valid 'changes_id' member.

* subversion/libsvn_fs_base/tree.c
  (verify_locks): Call svn_fs_base__txn_get_changes_id() and
    use the result to lookup changed paths.
  (txn_body_paths_changed): Call svn_fs_base__txn_get_changes_id() and
    use the result to lookup changed paths.  Remove comment about
    lacking BDB transaction protection.
  (base_paths_changed): Use svn_fs_bdb__retry_txn() instead of
    svn_fs_bdb__retry() when fetching changed paths -- we can no
    longer expect the changed-path information to be immutable.

* subversion/libsvn_fs_base/revs-txns.c
  (svn_fs_base__txn_get_changes_id, txn_body_begin_obliteration_txn):
    Expect non-NULL 'changes_id' transaction_t members.
  (svn_fs_base__purge_txn): Delete the right set of changes!

Modified:
    subversion/branches/issue-3550-dev/subversion/libsvn_fs_base/bdb/txn-table.c
    subversion/branches/issue-3550-dev/subversion/libsvn_fs_base/fs.h
    subversion/branches/issue-3550-dev/subversion/libsvn_fs_base/revs-txns.c
    subversion/branches/issue-3550-dev/subversion/libsvn_fs_base/tree.c

Modified: 
subversion/branches/issue-3550-dev/subversion/libsvn_fs_base/bdb/txn-table.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/issue-3550-dev/subversion/libsvn_fs_base/bdb/txn-table.c?rev=892030&r1=892029&r2=892030&view=diff
==============================================================================
--- 
subversion/branches/issue-3550-dev/subversion/libsvn_fs_base/bdb/txn-table.c 
(original)
+++ 
subversion/branches/issue-3550-dev/subversion/libsvn_fs_base/bdb/txn-table.c 
Fri Dec 18 00:31:31 2009
@@ -242,6 +242,12 @@
   /* Convert skel to native type. */
   SVN_ERR(svn_fs_base__parse_transaction_skel(&transaction, skel,
                                               bfd->format, pool));
+  
+  /* Fixup TRANSACTION to ensure that it has a value 'changes_id'
+   *member. */
+  if (transaction->changes_id == NULL)
+    transaction->changes_id = apr_pstrdup(pool, txn_name);
+
   *txn_p = transaction;
   return SVN_NO_ERROR;
 }

Modified: subversion/branches/issue-3550-dev/subversion/libsvn_fs_base/fs.h
URL: 
http://svn.apache.org/viewvc/subversion/branches/issue-3550-dev/subversion/libsvn_fs_base/fs.h?rev=892030&r1=892029&r2=892030&view=diff
==============================================================================
--- subversion/branches/issue-3550-dev/subversion/libsvn_fs_base/fs.h (original)
+++ subversion/branches/issue-3550-dev/subversion/libsvn_fs_base/fs.h Fri Dec 
18 00:31:31 2009
@@ -166,9 +166,8 @@
      no copies in this transaction.  */
   apr_array_header_t *copies;
 
-  /* key into the `changed' table by which changed paths for this
-     transaction may be found, or NULL if changes are keyed on the
-     transaction's ID.  */
+  /* key into the `changes' table by which changed paths for this
+     transaction may be found.  */
   const char *changes_id;
 
   /* TRUE iff the changes records for this transaction are known to be

Modified: 
subversion/branches/issue-3550-dev/subversion/libsvn_fs_base/revs-txns.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/issue-3550-dev/subversion/libsvn_fs_base/revs-txns.c?rev=892030&r1=892029&r2=892030&view=diff
==============================================================================
--- subversion/branches/issue-3550-dev/subversion/libsvn_fs_base/revs-txns.c 
(original)
+++ subversion/branches/issue-3550-dev/subversion/libsvn_fs_base/revs-txns.c 
Fri Dec 18 00:31:31 2009
@@ -353,8 +353,7 @@
 {
   transaction_t *txn;
   SVN_ERR(get_txn(&txn, fs, txn_name, FALSE, trail, pool));
-  *changes_id = txn->changes_id ? txn->changes_id 
-                                : apr_pstrdup(pool, txn_name);
+  *changes_id = txn->changes_id;
   return SVN_NO_ERROR;
 }
 
@@ -938,9 +937,7 @@
     }
 
   /* Dup the "changes" that are keyed by the txn_id. */
-  SVN_ERR(changes_dup(changes_id,
-                      old_txn->changes_id ? old_txn->changes_id : old_txn_id,
-                      trail, trail->pool));
+  SVN_ERR(changes_dup(changes_id, old_txn->changes_id, trail, trail->pool));
 
   /* ### TODO: Update the "node-origins" table.
    * Or can this be deferred till commit time? Probably not. */
@@ -1107,6 +1104,7 @@
 static svn_error_t *
 txn_body_cleanup_txn_changes(void *baton, trail_t *trail)
 {
+  /* The 'baton' is the 'changes_id'. */
   return svn_fs_bdb__changes_delete(trail->fs, baton, trail, trail->pool);
 }
 
@@ -1250,7 +1248,7 @@
   /* Kill the transaction's changes (which should gracefully recover
      if...). */
   SVN_ERR(svn_fs_base__retry_txn(fs, txn_body_cleanup_txn_changes,
-                                 (void *)txn_id, TRUE, pool));
+                                 (void *)txn->changes_id, TRUE, pool));
 
   /* Kill the transaction's copies (which should gracefully...). */
   if (txn->copies)

Modified: subversion/branches/issue-3550-dev/subversion/libsvn_fs_base/tree.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/issue-3550-dev/subversion/libsvn_fs_base/tree.c?rev=892030&r1=892029&r2=892030&view=diff
==============================================================================
--- subversion/branches/issue-3550-dev/subversion/libsvn_fs_base/tree.c 
(original)
+++ subversion/branches/issue-3550-dev/subversion/libsvn_fs_base/tree.c Fri Dec 
18 00:31:31 2009
@@ -2488,6 +2488,7 @@
              apr_pool_t *pool)
 {
   apr_pool_t *subpool = svn_pool_create(pool);
+  const char *changes_id;
   apr_hash_t *changes;
   apr_hash_index_t *hi;
   apr_array_header_t *changed_paths;
@@ -2495,6 +2496,8 @@
   int i;
 
   /* Fetch the changes for this transaction. */
+  SVN_ERR(svn_fs_base__txn_get_changes_id(&changes_id, trail->fs, txn_name,
+                                          trail, trail->pool));
   SVN_ERR(svn_fs_bdb__changes_fetch(&changes, trail->fs, txn_name,
                                     trail, pool));
 
@@ -4115,11 +4118,8 @@
 txn_body_paths_changed(void *baton,
                        trail_t *trail)
 {
-  /* WARNING: This is called *without* the protection of a Berkeley DB
-     transaction.  If you modify this function, keep that in mind. */
-
   struct paths_changed_args *args = baton;
-  const char *txn_id;
+  const char *txn_id, *changes_id;
   svn_fs_t *fs = args->root->fs;
 
   /* Get the transaction ID from ROOT. */
@@ -4129,7 +4129,9 @@
   else
     txn_id = args->root->txn;
 
-  return svn_fs_bdb__changes_fetch(&(args->changes), fs, txn_id,
+  SVN_ERR(svn_fs_base__txn_get_changes_id(&changes_id, fs, txn_id,
+                                          trail, trail->pool));
+  return svn_fs_bdb__changes_fetch(&(args->changes), fs, changes_id,
                                    trail, trail->pool);
 }
 
@@ -4142,8 +4144,8 @@
   struct paths_changed_args args;
   args.root = root;
   args.changes = NULL;
-  SVN_ERR(svn_fs_base__retry(root->fs, txn_body_paths_changed, &args,
-                             FALSE, pool));
+  SVN_ERR(svn_fs_base__retry_txn(root->fs, txn_body_paths_changed, &args,
+                                 FALSE, pool));
   *changed_paths_p = args.changes;
   return SVN_NO_ERROR;
 }


Reply via email to