@@ -153,9 +153,35 @@ version_t NVMeofGwMon::get_trim_to() const
153153 return 0 ;
154154}
155155
156+ /* *
157+ * restore_pending_map_info
158+ * function called during new paxos epochs
159+ * function called to restore in pending map all data that is not serialized
160+ * to paxos peons. Othervise it would be overriden in "pending_map = map"
161+ * currently just "allow_failovers_ts" variable is restored
162+ */
163+ void NVMeofGwMon::restore_pending_map_info (NVMeofGwMap & tmp_map) {
164+ std::chrono::system_clock::time_point now = std::chrono::system_clock::now ();
165+ for (auto & created_map_pair: tmp_map.created_gws ) {
166+ auto group_key = created_map_pair.first ;
167+ NvmeGwMonStates& gw_created_map = created_map_pair.second ;
168+ for (auto & gw_created_pair: gw_created_map) {
169+ auto gw_id = gw_created_pair.first ;
170+ if (gw_created_pair.second .allow_failovers_ts > now) {
171+ // restore not persistent information upon new epochs
172+ dout (10 ) << " restore skip-failovers timeout for gw " << gw_id << dendl;
173+ pending_map.created_gws [group_key][gw_id].allow_failovers_ts =
174+ gw_created_pair.second .allow_failovers_ts ;
175+ }
176+ }
177+ }
178+ }
179+
156180void NVMeofGwMon::create_pending ()
157181{
182+ NVMeofGwMap tmp_map = pending_map;
158183 pending_map = map;// deep copy of the object
184+ restore_pending_map_info (tmp_map);
159185 pending_map.epoch ++;
160186 dout (10 ) << " pending " << pending_map << dendl;
161187}
@@ -641,11 +667,12 @@ bool NVMeofGwMon::prepare_beacon(MonOpRequestRef op)
641667 if (pending_map.created_gws [group_key][gw_id].availability ==
642668 gw_availability_t ::GW_AVAILABLE) {
643669 dout (1 ) << " Warning :GW marked as Available in the NVmeofGwMon "
644- << " database, performed full startup - Apply GW !"
670+ << " database, performed full startup - Apply it but don't allow failover !"
645671 << gw_id << dendl;
646672 process_gw_down (gw_id, group_key, gw_propose, avail);
647- LastBeacon lb = {gw_id, group_key};
648- last_beacon[lb] = now; // Update last beacon
673+ pending_map.skip_failovers_for_group (group_key);
674+ dout (4 ) << " set skip-failovers for gw's group " << gw_id << " group "
675+ << group_key << dendl;
649676 } else if (
650677 pending_map.created_gws [group_key][gw_id].performed_full_startup ==
651678 false ) {
@@ -654,6 +681,8 @@ bool NVMeofGwMon::prepare_beacon(MonOpRequestRef op)
654681 pending_map.created_gws [group_key][gw_id].addr_vect =
655682 entity_addrvec_t (con->get_peer_addr ());
656683 }
684+ LastBeacon lb = {gw_id, group_key};
685+ last_beacon[lb] = now; // Update last beacon
657686 goto set_propose;
658687 }
659688 // gw already created
@@ -774,15 +803,19 @@ bool NVMeofGwMon::prepare_beacon(MonOpRequestRef op)
774803 % beacons_till_ack) == 0 ))|| (!apply_ack_logic) ) {
775804 send_ack = true ;
776805 if (apply_ack_logic) {
777- dout (10 ) << " ack sent: beacon index "
806+ dout (20 ) << " ack sent: beacon index "
778807 << pending_map.created_gws [group_key][gw_id].beacon_index
779808 << " gw " << gw_id <<dendl;
780809 }
781810 }
782811 if (send_ack && ((!gw_propose && epoch_filter_enabled) ||
783- (propose && !epoch_filter_enabled)) ) {
784- // if epoch-filter-bit: send ack to beacon in case no propose
785- // or if changed something not relevant to gw-epoch
812+ (propose && !epoch_filter_enabled) ||
813+ (avail == gw_availability_t ::GW_CREATED)) ) {
814+ /* always send beacon ack to gw in Created state,
815+ * it should be temporary state
816+ * if epoch-filter-bit: send ack to beacon in case no propose
817+ * or if changed something not relevant to gw-epoch
818+ */
786819 if (gw_created) {
787820 // respond with a map slice correspondent to the same GW
788821 ack_map.created_gws [group_key][gw_id] = map.created_gws [group_key][gw_id];
0 commit comments