Virtual Synchrony
Virtual Synchrony is a mechanism or algorithm tackling the atomic
multicast problem. Similar to atomic transaction, atomic multicast refers to the scenario that a message is delivered to either all group members or to none at all. It is named virtual synchrony because operations are often performed concurrently and multicasts are often issued asynchronously, but algorithms can still be developed and reasoned about using simply, synchronous model.
Why atomicity is so important? consider a distributed database, all the nodes are replications of each other and form a group. Assume a client contacts a replica P and requests it to perform an update. The replica does so by multicasting the update to the other group members. Unfortunately, before the multicast completes, P crashes, leaving the rest of the group in a difficult position: some group members will have received the update request; others will not. If the members who have received the request deliver it to the database, then obviously we will have an inconsistent replicated database. This situation needs to be avoided and we should either have that the update is delivered to all nonfaulty members, or to none at all.
So we need a way to do reliable multicast in the presence of process failures. To achieve this, we make a distinction between receiving and delivering a message. In particular, we adopt a model in which the distributed system consists of message-handling components (middleware)as was shown in below
This provides us another abstraction layer so that we can have finer control of how to deliver the message to the application. When we define atomic multicast, we restrict it happens at a particular group view. Group view is a list of processes that a multicast message m is uniquely associated with. Within this group view, the message should be delivered to all group view members, or to none at all. The sender bundles this group view (list) at the time message m was multicast. An important observation is that each process on that list has the same view. In other words, they should all agree that m should be delivered by each one of them and by no other process.
Now suppose that message m is multicast at the time its sender, say P, has group view G. Furthermore, assume that while the multicast is taking place, another process Q joins or leaves the group. This change in group membership is naturally announced to all processes in G. Stated somewhat differently, a view change takes place by multicasting a message vc announcing the joining or leaving of Q. We now have two multicast messages simultaneously in transit: m and vc. What we need to guarantee is that m is either delivered by all processes in G before any one executes the view change as specified by vc, or m is not delivered at all.
Virtually synchrony guarantees that a message multicast to group view G is delivered by each nonfaulty process in G. If the sender of the message crashes during the multicast, the message is either delivered to all remaining processes, or ignored by each of them.
To illustrate these matters, consider the four processes shown above. At a certain point in time, we have a group consisting of S1, S2, S3, and S4. After some messages have been multicast, S3 crashes. However, before crashing, it succeeded in multicasting a message to processes S2 and S4, but not to S1. However, virtual synchrony in this case guarantees that the message is not delivered at all, effectively establishing the situation that the message was never sent before S3 crashed.
After S3 has been removed from the group, communication proceeds between the remaining group members. Later, when S3 recovers, it can join the group again, after its state has been brought up to date.
The principle of virtual synchrony comes from the fact that all multicasts take place between view changes. Put somewhat differently, a view change acts as a barrier across which no multicast can pass. All multicasts that are in transit while a view change takes place are completed before the view change comes into effect.
Implementing virtual synchrony
We use TCP as the point-to-point communication protocol. So multicasting a message m to a group of processes is implemented by reliably sending m to each group member. Note that although each transmission is guaranteed to succeed, this by no means guarantees that all group members receive m because the sender may fail before having transmitted m to each member. We also assumes that messages from the same source are received by a communication layer in the order they were sent by that source. In practice, this requirement is solved by using TCP connections for point-to-point communication.
Get Miguel’s stories in your inbox
Join Medium for free to get updates from this writer.
The main problem that needs to be solved is to guarantee that all messages sent to view G are delivered to all nonfaulty processes in G before the next group membership change takes place. The first issue that needs to be taken care of is making sure that each process in G has received all messages that were sent to G. Note that because the sender of a message m to G may have failed before completing its multicast, there may indeed be processes in G that will never receive m. Because the sender has crashed, these processes should get m from somewhere else.
The solution to this problem is to let every process in G keep m until it knows for sure that all members in G have received it. If m has been received by all members in G, m is said to be stable. Only stable messages are allowed to be delivered. To ensure stability, it is sufficient to select an arbitrary live process in G and request it to send m to all other processes in G.
To be more specific, assume the current view is G, but that it is necessary to install the next view G’. Without loss of generality, we assume that G and G’ differ by at most one process. A process P notices the view change when it receives a view-change message. Such a message may come from the process wanting to join or leave the group, or from a process that had detected the failure of a process in G that is now to be removed.
When a process P receives the view-change message for G’ , it first forwards a copy of any unstable message from G it still has to every process in G’ , and subsequently marks it as being stable. Recall that we assumes point-to-point communication is reliable, so that forwarded messages are never lost. Such forwarding guarantees that all messages in G that have been received by at least one process are received by all nonfaulty processes in G’. Note that it would also have been sufficient to elect a single coordinator to forward unstable messages.
To indicate that P no longer has any unstable messages and that it is prepared to install G’ as soon as the other processes can do that as well, it multicasts a flush message for G’.
After P has received a flush message for G’ from each other process, it can safely install the new view.
When a process Q receives a message m while Q still believes the current view is G , it delivers m taking any additional message-ordering constraints into account. If it had already received m, it considers the message to be a duplicate and discards it.
Because process Q will eventually receive the view-change message for G’ , it will also first forward any of its unstable messages and subsequently wrap things up by sending a flush message for G’ . Note that due to the assumed FIFO-message ordering as provided by the underlying communication layer, a flush message from a process is always received after the receipt of an unstable message from that same process.
The major flaw in the protocol described so far is that it cannot deal with process failures while a new view change is being announced. In particular, it assumes that until the new view G’ has been installed by each member in G’ , no process in G’ will fail (which would lead to a next view G’’ ). This problem is solved by announcing view changes for any view Gi+k even while previous changes have not yet been installed by all processes. The details are rather intricate, yet the principle should be clear.
Notes from Distributed Systems 3rd edition (2017), https://www.distributed-systems.net










