> From: Karl Fogel [mailto:kfogel@newton.ch.collab.net]
> Sent: Friday, February 28, 2003 9:01 PM
[...]
> When this is all done, svn_fs_apply_textdelta() has returned a window
> consumer that expects that stream to still be available for writes!
Yes, I can see that. What I don't get is why the stream is being closed
more than once.
[...]
> Anyway, when that stream is finally closed, years later, there's no
> way for us to know how many retries (that is, the retry loop inside
> svn_fs__retry_txn) it will take. Like any other function that happens
> inside a trail, rep_write_close_contents() must be be reinvokable --
> not necessarily reentrant, just redoable, since there's no telling how
> many times the whole trail might get run before it succeeds.
>
> We were violating the retryability rule, since an md5 context can only
> stand to be finalized once.
>
> Does this help?
Well, I didn't fully get it until I went through the code myself, so for
educational reasons I'll post my findings here so others can benefit.
This is mostly simplified code and callstacks, but it should be readable.
svn_fs_apply_textdelta
svn_fs__retry_txn(txn_body_apply_textdelta)
svn_fs__dag_get_edit_stream
svn_fs__rep_contents_write_stream
baton = rep_write_get_baton
stream = svn_stream_create(baton)
svn_stream_set_write(stream, rep_write_contents)
svn_stream_set_close(stream, rep_write_close_contents)
What happens with the stream from here on? Is it really
possible that the stream is closed _more than once_?
The answer lies in the main window handler returned by
svn_fs_apply_textdelta:
window_consumer(stream)
svn_fs__retry_txn(txn_body_txdelta_finalize_edits(stream))
svn_stream_close(stream) <-- !!!
svn_fs__dag_finalize_edits
So, apparently yes it can. Now I see why you'd need a flag to
indicate we already have finalized the checksum, since you might
revisit this code aswell (sigh).
rep_write_contents(baton)
svn_fs__retry_txn(txn_body_write_rep(baton))
apr_md5_update is called after the operations that might fail, so
you never update the checksum twice for the same data. That is,
unless the operation trying to write one window fails after
rep_write_contents and is itself wrapped in svn_fs__retry_txn.
rep_write_close_contents(baton)
if (!finalized)
apr_md5_finalize
finalized = true
svn_fs__retry_txn(txn_body_write_close_rep(baton))
Make sense?
Sander
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Mar 1 14:19:05 2003