summaryrefslogtreecommitdiff
path: root/subversion/libsvn_fs_fs/transaction.c
diff options
context:
space:
mode:
Diffstat (limited to 'subversion/libsvn_fs_fs/transaction.c')
-rw-r--r--subversion/libsvn_fs_fs/transaction.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/subversion/libsvn_fs_fs/transaction.c b/subversion/libsvn_fs_fs/transaction.c
index 3968c6fa5deb8..fabfe3e3e03b4 100644
--- a/subversion/libsvn_fs_fs/transaction.c
+++ b/subversion/libsvn_fs_fs/transaction.c
@@ -2334,12 +2334,17 @@ rep_write_contents_close(void *baton)
b->fnv1a_checksum_ctx,
b->scratch_pool));
- SVN_ERR(store_sha1_rep_mapping(b->fs, b->noderev, b->scratch_pool));
SVN_ERR(store_p2l_index_entry(b->fs, &rep->txn_id, &entry,
b->scratch_pool));
}
SVN_ERR(svn_io_file_close(b->file, b->scratch_pool));
+
+ /* Write the sha1->rep mapping *after* we successfully written node
+ * revision to disk. */
+ if (!old_rep)
+ SVN_ERR(store_sha1_rep_mapping(b->fs, b->noderev, b->scratch_pool));
+
SVN_ERR(unlock_proto_rev(b->fs, &rep->txn_id, b->lockcookie,
b->scratch_pool));
svn_pool_destroy(b->scratch_pool);
@@ -3623,6 +3628,8 @@ svn_fs_fs__commit(svn_revnum_t *new_rev_p,
if (ffd->rep_sharing_allowed)
{
+ svn_error_t *err;
+
SVN_ERR(svn_fs_fs__open_rep_cache(fs, pool));
/* Write new entries to the rep-sharing database.
@@ -3633,9 +3640,21 @@ svn_fs_fs__commit(svn_revnum_t *new_rev_p,
/* ### A commit that touches thousands of files will starve other
(reader/writer) commits for the duration of the below call.
Maybe write in batches? */
- SVN_SQLITE__WITH_TXN(
- write_reps_to_cache(fs, cb.reps_to_cache, pool),
- ffd->rep_cache_db);
+ SVN_ERR(svn_sqlite__begin_transaction(ffd->rep_cache_db));
+ err = write_reps_to_cache(fs, cb.reps_to_cache, pool);
+ err = svn_sqlite__finish_transaction(ffd->rep_cache_db, err);
+
+ if (svn_error_find_cause(err, SVN_SQLITE__ERR_ROLLBACK_FAILED))
+ {
+ /* Failed rollback means that our db connection is unusable, and
+ the only thing we can do is close it. The connection will be
+ reopened during the next operation with rep-cache.db. */
+ return svn_error_trace(
+ svn_error_compose_create(err,
+ svn_fs_fs__close_rep_cache(fs)));
+ }
+ else if (err)
+ return svn_error_trace(err);
}
return SVN_NO_ERROR;