@@ -75,6 +75,28 @@ metric_entity_ptr instantiate_backup_policy_metric_entity(const std::string &pol
7575 return METRIC_ENTITY_backup_policy.instantiate (entity_id, {{" policy_name" , policy_name}});
7676}
7777
78+ bool validate_backup_interval (int64_t backup_interval_seconds, std::string &hint_message)
79+ {
80+ // The backup interval must be larger than checkpoint reserve time.
81+ // Or the next cold backup checkpoint may be cleared by the clear operation.
82+ if (backup_interval_seconds <= FLAGS_cold_backup_checkpoint_reserve_minutes * 60 ) {
83+ hint_message = fmt::format (
84+ " backup interval must be larger than cold_backup_checkpoint_reserve_minutes={}" ,
85+ FLAGS_cold_backup_checkpoint_reserve_minutes);
86+ return false ;
87+ }
88+
89+ // There is a bug occurred in backup if the backup interval is less than 1 day, this is a
90+ // temporary resolution, the long term plan is to remove periodic backup.
91+ // See details https://github.com/apache/incubator-pegasus/issues/1081.
92+ if (backup_interval_seconds < 86400 ) {
93+ hint_message = fmt::format (" backup interval must be >= 86400 (1 day)" );
94+ return false ;
95+ }
96+
97+ return true ;
98+ }
99+
78100} // anonymous namespace
79101
80102backup_policy_metrics::backup_policy_metrics (const std::string &policy_name)
@@ -1281,13 +1303,10 @@ void backup_service::add_backup_policy(dsn::message_ex *msg)
12811303 std::set<int32_t > app_ids;
12821304 std::map<int32_t , std::string> app_names;
12831305
1284- // The backup interval must be greater than checkpoint reserve time.
1285- // Or the next cold backup checkpoint may be cleared by the clear operation.
1286- if (request.backup_interval_seconds <= FLAGS_cold_backup_checkpoint_reserve_minutes * 60 ) {
1306+ std::string hint_message;
1307+ if (!validate_backup_interval (request.backup_interval_seconds , hint_message)) {
12871308 response.err = ERR_INVALID_PARAMETERS;
1288- response.hint_message = fmt::format (
1289- " backup interval must be greater than FLAGS_cold_backup_checkpoint_reserve_minutes={}" ,
1290- FLAGS_cold_backup_checkpoint_reserve_minutes);
1309+ response.hint_message = hint_message;
12911310 _meta_svc->reply_data (msg, response);
12921311 msg->release_ref ();
12931312 return ;
@@ -1628,17 +1647,19 @@ void backup_service::modify_backup_policy(configuration_modify_backup_policy_rpc
16281647 }
16291648
16301649 if (request.__isset .new_backup_interval_sec ) {
1631- if (request.new_backup_interval_sec > 0 ) {
1650+ std::string hint_message;
1651+ if (validate_backup_interval (request.new_backup_interval_sec , hint_message)) {
16321652 LOG_INFO (" {}: policy will change backup interval from {}s to {}s" ,
16331653 cur_policy.policy_name ,
16341654 cur_policy.backup_interval_seconds ,
16351655 request.new_backup_interval_sec );
16361656 cur_policy.backup_interval_seconds = request.new_backup_interval_sec ;
16371657 have_modify_policy = true ;
16381658 } else {
1639- LOG_WARNING (" {}: invalid backup_interval_sec({})" ,
1659+ LOG_WARNING (" {}: invalid backup_interval_sec({}), {} " ,
16401660 cur_policy.policy_name ,
1641- request.new_backup_interval_sec );
1661+ request.new_backup_interval_sec ,
1662+ hint_message);
16421663 }
16431664 }
16441665
0 commit comments