On 26 April 2016 at 23:11,  <kot...@apache.org> wrote:
> Author: kotkov
> Date: Tue Apr 26 20:11:30 2016
> New Revision: 1741096
>
> URL: http://svn.apache.org/viewvc?rev=1741096&view=rev
> Log:
> Rollback an sqlite transaction in case we fail to COMMIT it.
>
> Otherwise, the db connection might be left in an unusable state and can
> be causing different issues, especially in case the connection is a
> long-living one.
>
> See r1741071 and the commit_with_locked_rep_cache() test.
>
[...]

[...]

> Modified: subversion/trunk/subversion/libsvn_fs_fs/transaction.c
> URL: 
> http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/transaction.c?rev=1741096&r1=1741095&r2=1741096&view=diff
> ==============================================================================
> --- subversion/trunk/subversion/libsvn_fs_fs/transaction.c (original)
> +++ subversion/trunk/subversion/libsvn_fs_fs/transaction.c Tue Apr 26 
> 20:11:30 2016
> @@ -3824,6 +3824,8 @@ svn_fs_fs__commit(svn_revnum_t *new_rev_
>
>    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.
> @@ -3834,9 +3836,21 @@ svn_fs_fs__commit(svn_revnum_t *new_rev_
>        /* ### 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 (err && svn_error_find_cause(err, SVN_ERR_SQLITE_ROLLBACK_FAILED))
There is no need check for 'err' since svn_error_find_cause() already
checks for SVN_NO_ERROR.

> +        {
> +          /* 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;
>






-- 
Ivan Zhakov

Reply via email to