# # # patch "ancestry.cc" # from [3c777fd295ee1ff41231877691411041819fe875] # to [d715baeea404e2ac649353dd7f4cb5c4b398360f] # # patch "cmd_netsync.cc" # from [352b0957e54298dfa1de185aaa125f105204c762] # to [2c5890ad3f4aad844a540c646681d8e602a83669] # # patch "database.cc" # from [2dfd49dd717b8644a1667630682e1fdccd64261f] # to [975f41e3c7c3be72412129197d555089ccbd0814] # # patch "options_list.hh" # from [bc318ee8e2ee4717aee0aee2b8a549c617fc6c76] # to [75b873f63f934840944a6dd0d69b901c49c02180] # # patch "roster.hh" # from [d537c98290349bdd63a111cd0afafe39d3a9992d] # to [9d6e7487f8b65f59ff44545df86fab7fada2a0e7] # ============================================================ --- ancestry.cc 3c777fd295ee1ff41231877691411041819fe875 +++ ancestry.cc d715baeea404e2ac649353dd7f4cb5c4b398360f @@ -534,7 +534,8 @@ make_roster_for_revision(database & db, void make_roster_for_revision(database & db, node_id_source & nis, revision_t const & rev, revision_id const & new_rid, - roster_t & new_roster, marking_map & new_markings) + roster_t & new_roster, marking_map & new_markings, + bool check_sanity) { MM(rev); MM(new_rid); @@ -550,17 +551,22 @@ make_roster_for_revision(database & db, // If nis is not a true_node_id_source, we have to assume we can get temp // node ids out of it. ??? Provide a predicate method on node_id_sources // instead of doing a typeinfo comparison. - new_roster.check_sane_against(new_markings, - typeid(nis) != typeid(true_node_id_source)); + if (check_sanity) + { + new_roster.check_sane_against(new_markings, + typeid(nis) != typeid(true_node_id_source)); + } } void make_roster_for_revision(database & db, revision_t const & rev, revision_id const & new_rid, - roster_t & new_roster, marking_map & new_markings) + roster_t & new_roster, marking_map & new_markings, + bool check_sanity) { true_node_id_source nis(db); - make_roster_for_revision(db, nis, rev, new_rid, new_roster, new_markings); + make_roster_for_revision(db, nis, rev, new_rid, new_roster, new_markings, + check_sanity); } // ancestry graph loader ============================================================ --- cmd_netsync.cc 352b0957e54298dfa1de185aaa125f105204c762 +++ cmd_netsync.cc 2c5890ad3f4aad844a540c646681d8e602a83669 @@ -494,7 +494,8 @@ CMD(pull, "pull", "", CMD_REF(network), N_("This pulls all branches that match the pattern given in PATTERN " "from the netsync server at the address ADDRESS."), options::opts::max_netsync_version | options::opts::min_netsync_version | - options::opts::set_default | options::opts::exclude) + options::opts::set_default | options::opts::exclude | + options::opts::sanity_check_percent) { database db(app); key_store keys(app); @@ -516,7 +517,8 @@ CMD_AUTOMATE(pull, N_("[ADDRESS[:PORTNUM "", options::opts::max_netsync_version | options::opts::min_netsync_version | - options::opts::set_default | options::opts::exclude) + options::opts::set_default | options::opts::exclude | + options::opts::sanity_check_percent) { database db(app); key_store keys(app); @@ -635,7 +637,8 @@ CMD(clone, "clone", "", CMD_REF(network) "Otherwise, it will be the head of the branch supplied. " "If no directory is given, the branch name will be used as directory"), options::opts::max_netsync_version | options::opts::min_netsync_version | - options::opts::revision) + options::opts::revision | + options::opts::sanity_check_percent) { if (args.size() < 2 || args.size() > 3 || app.opts.revision_selectors.size() > 1) throw usage(execid); ============================================================ --- database.cc 2dfd49dd717b8644a1667630682e1fdccd64261f +++ database.cc 975f41e3c7c3be72412129197d555089ccbd0814 @@ -209,7 +209,8 @@ public: // for scoped_ptr's sake public: explicit database_impl(system_path const & f, bool mem, - system_path const & roster_cache_performance_log); + system_path const & roster_cache_performance_log, + unsigned sanity_level); ~database_impl(); private: @@ -422,6 +423,10 @@ private: void add_prefix_matching_constraint(string const & colname, string const & prefix, query & q); + + unsigned sanity_check_percent; + unsigned sanity_check_current_pos; + bool should_do_sanity_check(); }; #ifdef SUPPORT_SQLITE_BEFORE_3003014 @@ -459,7 +464,8 @@ database_impl::database_impl(system_path #endif database_impl::database_impl(system_path const & f, bool mem, - system_path const & roster_cache_performance_log) : + system_path const & roster_cache_performance_log, + unsigned sanity_level) : filename(f), use_memory_db(mem), __sql(NULL), @@ -469,7 +475,9 @@ database_impl::database_impl(system_path roster_writeback_manager(*this), roster_cache_performance_log.as_external()), delayed_writes_size(0), - vcache(constants::db_version_cache_sz, 1) + vcache(constants::db_version_cache_sz, 1), + sanity_check_percent(sanity_level), + sanity_check_current_pos((date_t::now().as_millisecs_since_unix_epoch() / 1000) % 100) {} database_impl::~database_impl() @@ -487,6 +495,12 @@ database_impl::~database_impl() close(); } +bool database_impl::should_do_sanity_check() +{ + sanity_check_current_pos = (sanity_check_current_pos + 1) % 100; + return sanity_check_current_pos < sanity_check_percent; +} + struct database_cache { map > dbs; @@ -505,7 +519,8 @@ database::database(app_state & app) boost::shared_ptr & i = app.dbcache->dbs[app.opts.dbname]; if (!i) i.reset(new database_impl(app.opts.dbname, app.opts.dbname_is_memory, - app.opts.roster_cache_performance_log)); + app.opts.roster_cache_performance_log, + app.opts.sanity_check_percent)); imp = i; } @@ -2931,12 +2946,17 @@ database::put_roster_for_revision(revisi // to the db shared_ptr ros_writeable(new roster_t); MM(*ros_writeable); shared_ptr mm_writeable(new marking_map); MM(*mm_writeable); - manifest_id roster_manifest_id; - MM(roster_manifest_id); - make_roster_for_revision(*this, rev, new_id, *ros_writeable, *mm_writeable); - calculate_ident(*ros_writeable, roster_manifest_id, false); - E(rev.new_manifest == roster_manifest_id, rev.made_from, - F("revision contains incorrect manifest_id")); + bool check_sanity = imp->should_do_sanity_check(); + make_roster_for_revision(*this, rev, new_id, *ros_writeable, *mm_writeable, + check_sanity); + if (check_sanity) + { + manifest_id roster_manifest_id; + MM(roster_manifest_id); + calculate_ident(*ros_writeable, roster_manifest_id, false); + E(rev.new_manifest == roster_manifest_id, rev.made_from, + F("revision contains incorrect manifest_id")); + } // const'ify the objects, suitable for caching etc. roster_t_cp ros = ros_writeable; marking_map_cp mm = mm_writeable; ============================================================ --- options_list.hh bc318ee8e2ee4717aee0aee2b8a549c617fc6c76 +++ options_list.hh 75b873f63f934840944a6dd0d69b901c49c02180 @@ -244,6 +244,14 @@ GOPT(roster_cache_performance_log, "rost } #endif +OPT(sanity_check_percent, "reduced-sanity-checking-percent", + unsigned, 100, gettext_noop("only check the given percent of incoming revisions")) +#ifdef option_bodies +{ + sanity_check_percent = boost::lexical_cast(arg); +} +#endif + OPTION(globals, debug, false, "debug", gettext_noop("print debug log to stderr while running")) #ifdef option_bodies ============================================================ --- roster.hh d537c98290349bdd63a111cd0afafe39d3a9992d +++ roster.hh 9d6e7487f8b65f59ff44545df86fab7fada2a0e7 @@ -431,7 +431,8 @@ make_roster_for_revision(database & db, revision_t const & rev, revision_id const & rid, roster_t & result, - marking_map & marking); + marking_map & marking, + bool check_sanity = true); // This is for revisions that are not necessarily going to be written to the // db; you can specify your own node_id_source. @@ -441,7 +442,8 @@ make_roster_for_revision(database & db, revision_t const & rev, revision_id const & rid, roster_t & result, - marking_map & marking); + marking_map & marking, + bool check_sanity = true); void read_roster_and_marking(roster_data const & dat,