You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2014/05/11 04:43:06 UTC
svn commit: r1593753 - in /subversion/trunk/subversion: include/svn_repos.h
libsvn_repos/deprecated.c libsvn_repos/dump.c svnadmin/svnadmin.c
tests/cmdline/svnadmin_tests.py
Author: stefan2
Date: Sun May 11 02:43:06 2014
New Revision: 1593753
URL: http://svn.apache.org/r1593753
Log:
Add --metadata-only option to 'svnadmin verify'. This allows for very
fast detection of external corruption with a decent confidence level.
It does not render full verification redundant but aids the sysadmin
in their triage during an emergency.
For repositories with logical addressing, the metadata check already
verifies all rev file contents against the low-level checksums stored
in the index files. If any data gets modified by forces outside SVN
(catastrophic server failure etc), the chance of detection is very high.
OTOH, that check is basically a linear read at full disk speed providing
feedback 100 to 1000 times faster than a full verification.
The implementation is simple as we simply need to skip the per-revision
checks and only run the global checks. For BDB, this is still a complete
verification; for old FSFS repos, only the rep cache gets verified
which gives very little test coverage.
* subversion/include/svn_repos.h
(svn_repos_verify_fs3): Add new option flag. API had already been bumped.
* subversion/libsvn_repos/dump.c
(svn_repos_verify_fs3): Don't call verify_one_revision() when we only
want to verify the metadata.
* subversion/libsvn_repos/deprecated.c
(svn_repos_verify_fs2): Legacy code won't use the new feature.
* subversion/svnadmin/svnadmin.c
(svnadmin__cmdline_options_t): Declare new option.
(options): Add UI description of the new option.
(cmd_table): Add new option to 'svnadmin verify'.
(svnadmin_opt_state): Add an entry for the new option.
(subcommand_verify): Pass new option to repo API.
(sub_main): Pass the new CL option on to the command subroutine.
* subversion/tests/cmdline/svnadmin_tests.py
(verify_metadata_only): New test verifying that the new option
does not cause verification failures.
verify_quickly): New test using the new option to detect external
corruption in repos with log. addressing.
(test_list): Register new tests.
Modified:
subversion/trunk/subversion/include/svn_repos.h
subversion/trunk/subversion/libsvn_repos/deprecated.c
subversion/trunk/subversion/libsvn_repos/dump.c
subversion/trunk/subversion/svnadmin/svnadmin.c
subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py
Modified: subversion/trunk/subversion/include/svn_repos.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_repos.h?rev=1593753&r1=1593752&r2=1593753&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_repos.h (original)
+++ subversion/trunk/subversion/include/svn_repos.h Sun May 11 02:43:06 2014
@@ -2739,6 +2739,11 @@ svn_repos_info_format(int *repos_format,
* differ only in character representation, but are otherwise
* identical.
*
+ * If @a metadata_only is @c TRUE, backends that have a concept of separate
+ * metadata verification will only perform that and skip the more expensive
+ * file context reconstruction and verification. For FSFS format 7+ and
+ * FSX, this allows for a very fast check against external corruption.
+ *
* If @a notify_func is not null, then call it with @a notify_baton and
* with a notification structure in which the fields are set as follows.
* (For a warning or error notification that does not apply to a specific
@@ -2792,6 +2797,7 @@ svn_repos_verify_fs3(svn_repos_t *repos,
svn_revnum_t end_rev,
svn_boolean_t keep_going,
svn_boolean_t check_normalization,
+ svn_boolean_t metadata_only,
svn_repos_notify_func_t notify_func,
void *notify_baton,
svn_cancel_func_t cancel,
Modified: subversion/trunk/subversion/libsvn_repos/deprecated.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_repos/deprecated.c?rev=1593753&r1=1593752&r2=1593753&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_repos/deprecated.c (original)
+++ subversion/trunk/subversion/libsvn_repos/deprecated.c Sun May 11 02:43:06 2014
@@ -774,6 +774,7 @@ svn_repos_verify_fs2(svn_repos_t *repos,
end_rev,
FALSE,
FALSE,
+ FALSE,
notify_func,
notify_baton,
cancel_func,
Modified: subversion/trunk/subversion/libsvn_repos/dump.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_repos/dump.c?rev=1593753&r1=1593752&r2=1593753&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_repos/dump.c (original)
+++ subversion/trunk/subversion/libsvn_repos/dump.c Sun May 11 02:43:06 2014
@@ -2179,6 +2179,7 @@ svn_repos_verify_fs3(svn_repos_t *repos,
svn_revnum_t end_rev,
svn_boolean_t keep_going,
svn_boolean_t check_normalization,
+ svn_boolean_t metadata_only,
svn_repos_notify_func_t notify_func,
void *notify_baton,
svn_cancel_func_t cancel_func,
@@ -2256,38 +2257,39 @@ svn_repos_verify_fs3(svn_repos_t *repos,
pool));
}
- for (rev = start_rev; rev <= end_rev; rev++)
- {
- svn_pool_clear(iterpool);
-
- /* Wrapper function to catch the possible errors. */
- err = verify_one_revision(fs, rev, notify_func, notify_baton,
- start_rev, check_normalization,
- cancel_func, cancel_baton,
- iterpool);
-
- if (err)
- {
- if (err->apr_err == SVN_ERR_CANCELLED)
- return svn_error_trace(err);
-
- found_corruption = TRUE;
- notify_verification_error(rev, err, notify_func, notify_baton,
- iterpool);
- svn_error_clear(err);
-
- if (keep_going)
- continue;
- else
- break;
- }
-
- if (notify_func)
- {
- notify->revision = rev;
- notify_func(notify_baton, notify, iterpool);
- }
- }
+ if (!metadata_only)
+ for (rev = start_rev; rev <= end_rev; rev++)
+ {
+ svn_pool_clear(iterpool);
+
+ /* Wrapper function to catch the possible errors. */
+ err = verify_one_revision(fs, rev, notify_func, notify_baton,
+ start_rev, check_normalization,
+ cancel_func, cancel_baton,
+ iterpool);
+
+ if (err)
+ {
+ if (err->apr_err == SVN_ERR_CANCELLED)
+ return svn_error_trace(err);
+
+ found_corruption = TRUE;
+ notify_verification_error(rev, err, notify_func, notify_baton,
+ iterpool);
+ svn_error_clear(err);
+
+ if (keep_going)
+ continue;
+ else
+ break;
+ }
+
+ if (notify_func)
+ {
+ notify->revision = rev;
+ notify_func(notify_baton, notify, iterpool);
+ }
+ }
/* We're done. */
if (notify_func)
Modified: subversion/trunk/subversion/svnadmin/svnadmin.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svnadmin/svnadmin.c?rev=1593753&r1=1593752&r2=1593753&view=diff
==============================================================================
--- subversion/trunk/subversion/svnadmin/svnadmin.c (original)
+++ subversion/trunk/subversion/svnadmin/svnadmin.c Sun May 11 02:43:06 2014
@@ -202,7 +202,8 @@ enum svnadmin__cmdline_options_t
svnadmin__pre_1_5_compatible,
svnadmin__pre_1_6_compatible,
svnadmin__compatible_version,
- svnadmin__check_normalization
+ svnadmin__check_normalization,
+ svnadmin__metadata_only
};
/* Option codes and descriptions.
@@ -316,6 +317,11 @@ static const apr_getopt_option_t options
" in character representation, but are otherwise\n"
" identical")},
+ {"metadata-only", svnadmin__metadata_only, 0,
+ N_("verify metadata only (ignored for BDB),"
+ " checking against external corruption in\n"
+ " Subversion 1.9+ format repositories.\n")},
+
{NULL}
};
@@ -521,7 +527,7 @@ static const svn_opt_subcommand_desc2_t
("usage: svnadmin verify REPOS_PATH\n\n"
"Verify the data stored in the repository.\n"),
{'t', 'r', 'q', svnadmin__keep_going, 'M',
- svnadmin__check_normalization} },
+ svnadmin__check_normalization, svnadmin__metadata_only} },
{ NULL, NULL, {0}, NULL, {0} }
};
@@ -551,6 +557,7 @@ struct svnadmin_opt_state
svn_boolean_t wait; /* --wait */
svn_boolean_t keep_going; /* --keep-going */
svn_boolean_t check_normalization; /* --check-normalization */
+ svn_boolean_t metadata_only; /* --metadata-only */
svn_boolean_t bypass_prop_validation; /* --bypass-prop-validation */
svn_boolean_t ignore_dates; /* --ignore-dates */
enum svn_repos_load_uuid uuid_action; /* --ignore-uuid,
@@ -1784,6 +1791,7 @@ subcommand_verify(apr_getopt_t *os, void
verify_err = svn_repos_verify_fs3(repos, lower, upper,
opt_state->keep_going,
opt_state->check_normalization,
+ opt_state->metadata_only,
!opt_state->quiet
? repos_notify_handler : NULL,
¬ify_baton, check_cancel,
@@ -2497,6 +2505,9 @@ sub_main(int *exit_code, int argc, const
case svnadmin__check_normalization:
opt_state.check_normalization = TRUE;
break;
+ case svnadmin__metadata_only:
+ opt_state.metadata_only = TRUE;
+ break;
case svnadmin__fs_type:
SVN_ERR(svn_utf_cstring_to_utf8(&opt_state.fs_type, opt_arg, pool));
break;
Modified: subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py?rev=1593753&r1=1593752&r2=1593753&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py Sun May 11 02:43:06 2014
@@ -2449,6 +2449,68 @@ def freeze_freeze(sbox):
'freeze', '-F', arg_file, '--',
sys.executable, '-c', 'True')
+def verify_metadata_only(sbox):
+ "verify metadata only"
+
+ sbox.build(create_wc = False)
+ exit_code, output, errput = svntest.main.run_svnadmin("verify",
+ sbox.repo_dir,
+ "--metadata-only")
+ if errput:
+ raise SVNUnexpectedStderr(errput)
+
+ # Unfortunately, older formats won't test as thoroughly than newer ones
+ # resulting in different progress output. BDB will do a full check but
+ # not produce any output.
+ if svntest.main.is_fs_log_addressing():
+ svntest.verify.compare_and_display_lines(
+ "Unexpected error while running 'svnadmin verify'.",
+ 'STDOUT', ["* Verifying metadata at revision 0 ...\n",
+ "* Verifying repository metadata ...\n"], output)
+ elif svntest.main.fs_has_rep_sharing() \
+ and not svntest.main.is_fs_type_bdb():
+ svntest.verify.compare_and_display_lines(
+ "Unexpected error while running 'svnadmin verify'.",
+ 'STDOUT', ["* Verifying repository metadata ...\n"], output)
+ else:
+ svntest.verify.compare_and_display_lines(
+ "Unexpected error while running 'svnadmin verify'.",
+ 'STDOUT', [], output)
+
+
+@SkipUnless(svntest.main.is_fs_type_fsfs)
+def verify_quickly(sbox):
+ "verify quickly using metadata"
+
+ sbox.build(create_wc = False)
+ rev_file = open(fsfs_file(sbox.repo_dir, 'revs', '1'), 'r+b')
+
+ # set new contents
+ rev_file.seek(8)
+ rev_file.write('#')
+ rev_file.close()
+
+ exit_code, output, errput = svntest.main.run_svnadmin("verify",
+ sbox.repo_dir,
+ "--metadata-only")
+
+ # unfortunately, some backends needs to do more checks than other
+ # resulting in different progress output
+ if svntest.main.is_fs_log_addressing():
+ exp_out = svntest.verify.RegexListOutput([])
+ exp_err = svntest.verify.RegexListOutput(["svnadmin: E160004:.*",
+ "svnadmin: E165011:.*"], False)
+ else:
+ exp_out = svntest.verify.RegexListOutput([])
+ exp_err = svntest.verify.RegexListOutput([])
+
+ if (svntest.main.fs_has_rep_sharing()):
+ exp_out.insert(0, ".*Verifying.*metadata.*")
+ if svntest.verify.verify_outputs("Unexpected error while running 'svnadmin verify'.",
+ output, errput, exp_out, exp_err):
+ raise svntest.Failure
+
+
########################################################################
# Run the tests
@@ -2495,6 +2557,8 @@ test_list = [ None,
fsfs_hotcopy_old_with_propchanges,
verify_packed,
freeze_freeze,
+ verify_metadata_only,
+ verify_quickly,
]
if __name__ == '__main__':