svnsync and commit metadata

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

svnsync and commit metadata

James Stocks
Hello,

We are trying to write a check for our monitoring system which asserts
that an SVN mirror is up to date with the master.  We do currently
have a check looking at the youngest revision number/age on the master
and mirror, however, this wrongly asserts that the mirror is out of
sync during the brief window when the mirror hasn't caught up.

We would like to find a way of inspecting the time of a given commit
being successfully synchronised to a mirror as opposed to the
timestamp of the commit itself.  We think that this might be stored as
metadata in the subversion filesystem.  Alternatively, is it possible
to inspect the SVN repo on the mirror and determine the time of the
most recent successful svnsync?  I am aware that we could check the
return code of svnsync running on the master, however, we need to be
able to check this on the mirror end of the process.

We would appreciate advice anyone has with this situation, or tips
from anyone who has dealt with anything similar.

Many thanks,
James.

--


Reply | Threaded
Open this post in threaded view
|

Re: svnsync and commit metadata

Daniel Shahaf-2
James Stocks wrote on Thu, 10 Sep 2020 15:01 +0100:
> [...], this wrongly asserts that the mirror is out of
> sync during the brief window when the mirror hasn't caught up.
>
> We would like to find a way of inspecting the time of a given commit
> being successfully synchronised to a mirror as opposed to the
> timestamp of the commit itself.  We think that this might be stored as
> metadata in the subversion filesystem.

No, that timestamp isn't stored.  However, you could write a simple
post-commit hook to record it.

> Alternatively, is it possible
> to inspect the SVN repo on the mirror and determine the time of the
> most recent successful svnsync?

Yes, it's possible.  However, before I say how, I'll stress the
post-commit solution is preferable to the following one.

The following solution relies on implementation details: Check
$REPOS_DIR/{format,db/fs-type,db/format} in this order, then check the
timestamp of $REPOS_DIR/db/current.  That file is updated whenever and
only when $REPOS_DIR is committed to (revprop changes don't count).

> I am aware that we could check the
> return code of svnsync running on the master, however, we need to be
> able to check this on the mirror end of the process.
>

What you can do is inspect the svn:sync-* revprops on r0 of the mirror —
svn:sync-lock, svn:sync-last-merged-rev, & svn:sync-currently-copying —
and cross-reference them with `svnlook youngest` on the mirror, and
with whether there's an active TCP connection to whichever IP svnsync
runs on.  (The last part is needed in case svnsync exits abnormally,
leaving a stale svn:sync-currently-copying behind.  The next «svnsync
sync» run will DTRT in such cases, but your monitoring will
nevertheless want to detect them.)

> We would appreciate advice anyone has with this situation, or tips
> from anyone who has dealt with anything similar.

Yet another solution is to push commit notifications (using svnpubsub,
post-commit emails, or anything else) to the the host that runs svnsync
(in your case it's the master, but svnsync can also be run from the
mirror or from a third host) and _then_ monitor the exit code of svnsync.

Cheers,

Daniel