@@ -971,20 +971,26 @@ void verifyLoggingEvent()
971971 // exit all requesters
972972 // serve slower nodes 30 more minutes before officially switching epoch
973973 Logger::get ()->info (" Received END_EPOCH message. Serving 30 minutes and then closing BOB" );
974- SLEEP (1000ULL * gTimeToWaitEpochEnd ); // 30 minutes
975- gStopFlag .store (true );
976- // the endTick tick is a virtual tick, we need to migrate its data to new keys:
977- uint32_t endTick = lastQuorumTick + 1 ; // the system just "borrow" this tick index
978974
979- db_rename (" tick_log_range:" + std::to_string (endTick),
980- " end_epoch:tick_log_range:" +std::to_string (gCurrentProcessingEpoch ));
981- db_rename (" log_ranges:" + std::to_string (endTick),
982- " end_epoch:log_ranges:" +std::to_string (gCurrentProcessingEpoch ));
983975 std::string key = " end_epoch_tick:" + std::to_string (gCurrentProcessingEpoch );
976+ uint32_t endTick = lastQuorumTick + 1 ; // the system just "borrow" this tick index
984977 db_insert_u32 (key, endTick);
978+ // copy log range struct
979+ db_copy (" log_ranges:" + std::to_string (endTick), " end_epoch:log_ranges:" +std::to_string (gCurrentProcessingEpoch ));
980+ // copy log range meta data per tick
981+ db_hcopy (" tick_log_range:" + std::to_string (endTick), " end_epoch:tick_log_range:" +std::to_string (gCurrentProcessingEpoch ));
985982 // end epoch tick is a virtual tick for logging, we set it back to lastQuorumTick
986983 db_update_field (" db_status" , " latest_event_tick" , std::to_string (lastQuorumTick));
987984 db_insert_u32 (" verified_history:" + std::to_string (gCurrentProcessingEpoch ), lastQuorumTick); // update historical tracker
985+ SLEEP (1000ULL * gTimeToWaitEpochEnd ); // default: 30 minutes
986+ gStopFlag .store (true );
987+ // the endTick tick is a virtual tick, we need to migrate its data to new keys:
988+ // these operation are needed when it does seamless transition because in new epoch
989+ // the init tick will be the same as this end epoch tick
990+ db_rename (" tick_log_range:" + std::to_string (endTick),
991+ " backup_end_epoch:tick_log_range:" +std::to_string (gCurrentProcessingEpoch ));
992+ db_rename (" log_ranges:" + std::to_string (endTick),
993+ " backup_end_epoch:log_ranges:" +std::to_string (gCurrentProcessingEpoch ));
988994 }
989995 Logger::get ()->info (" verifyLoggingEvent stopping gracefully." );
990996}
0 commit comments