4.1 Connection Establishment Sequence

This example shows how a connection is established using two machines:

  • MA

  • MB

These two machines are members of a single replica set.

There are two connections linking the two machines:

  • CAB: Connection from MA to MB.

  • CBA: Connection from MB to MA.

The schedules on these two connections are always on.

The following diagram shows the connection establishment sequence (the number indicates the sequence numbers).

Connection establishment sequence

Figure 3: Connection establishment sequence

The connection establishment for CAB and CBA are independent of each other. Details on the connection establishment of CAB follow (the connection establishment for CBA is done in the same sequence):

  • At time 1, MB sends CMD_NEED_JOIN to MA.

  • At time 2, On receiving CMD_NEED_JOIN from MB, MA sends CMD_START_JOIN to MB.

  • At time 3, On receiving CMD_START_JOIN from MA, MB sends CMD_JOINING to MA, which includes the current version vector of MB and a connection session GUID (see section 3.1.1.5) generated by MB to represent the connection session that is being established.

  • At time 4, on receiving CMD_JOINING, MA retrieves the version vector of MB and the connection session GUID generated by MB, and saves both in the connection object to be used to generate change orders.