diff --git a/src/box/applier.cc b/src/box/applier.cc index 009985e162faf5c606c753810957e9d143b4ea69..58838bfb06883f95613e040327cd02009276788c 100644 --- a/src/box/applier.cc +++ b/src/box/applier.cc @@ -1254,8 +1254,8 @@ static void replica_txn_wal_write_cb(struct replica_cb_data *rcb) { struct replica *r = replica_by_id(rcb->replica_id); - if (likely(r != NULL)) - r->applier_txn_last_tm = rcb->txn_last_tm; + if (likely(r != NULL && r->applier != NULL)) + r->applier->txn_last_tm = rcb->txn_last_tm; } static int @@ -1735,9 +1735,7 @@ applier_signal_ack(struct applier *applier) * timestamp in tm field. If user delete the node from _cluster * space, we obtain a nil pointer here. */ - struct replica *r = replica_by_id(applier->instance_id); - applier->ack_msg.txn_last_tm = (r == NULL ? 0 : - r->applier_txn_last_tm); + applier->ack_msg.txn_last_tm = applier->txn_last_tm; applier->ack_msg.vclock_sync = applier->last_vclock_sync; applier->ack_msg.term = box_raft()->term; vclock_copy(&applier->ack_msg.vclock, &replicaset.vclock); diff --git a/src/box/applier.h b/src/box/applier.h index 7451a302b281aba45d46371364533edf2f2e7017..5f97fb3d960b9ec1a4fbad621901d3f546d711dc 100644 --- a/src/box/applier.h +++ b/src/box/applier.h @@ -115,10 +115,7 @@ struct applier_data_msg { /** A message sent from tx to applier thread to trigger ACK. */ struct applier_ack_msg { struct cmsg base; - /** - * Last written transaction timestamp. - * Set to replica::applier_txn_last_tm. - */ + /** Last written transaction timestamp. */ double txn_last_tm; /** Last known raft term. */ uint64_t term; @@ -213,6 +210,12 @@ struct applier { struct applier_msg *pending_msgs[3]; /** Pending message count. */ int pending_msg_cnt; + /** + * Last written transaction timestamp. It can be updated by TX thread + * while the ACK msg with its own copy of this timestamp is being used + * by a worker thread. + */ + double txn_last_tm; /** Message sent to applier thread to trigger ACK. */ struct applier_ack_msg ack_msg; struct cmsg_hop ack_route[2]; diff --git a/src/box/replication.cc b/src/box/replication.cc index 83bc4b6cd4db8472216232e92dc9e8594e7cf346..50cbe77ef085cc749d81e023f87d5390485aaace 100644 --- a/src/box/replication.cc +++ b/src/box/replication.cc @@ -304,7 +304,6 @@ replica_new(void) trigger_create(&replica->on_applier_state, replica_on_applier_state_f, NULL, NULL); replica->applier_sync_state = APPLIER_DISCONNECTED; - replica->applier_txn_last_tm = 0; latch_create(&replica->order_latch); return replica; } diff --git a/src/box/replication.h b/src/box/replication.h index b58d54419af54c0665f762dcb7836127cc079fbc..82a54976e47144af08b112dfe3a60a0071f876d5 100644 --- a/src/box/replication.h +++ b/src/box/replication.h @@ -427,11 +427,6 @@ struct replica { * separate from applier. */ enum applier_state applier_sync_state; - /** - * Applier's last written to WAL transaction timestamp. - * Needed for relay lagging statistics. - */ - double applier_txn_last_tm; /* The latch is used to order replication requests. */ struct latch order_latch; };