DisSysLab · Homework 2

Global snapshots and logical clocks

Two questions: a snapshot algorithm built on logical clocks, and the plan for your project. Class 4, global snapshots, has what you need for Question 1.

Question 1

Snapshots at a logical time

Each agent A has a physical clock. The physical clocks are not synchronized. Each physical clock ticks forward for ever, and its value is an integer.

Each agent A also maintains a logical clock: a local variable A.clock, which is a pair (T, k) of integers. Logical clock values are compared lexicographically: (T, k) < (T′, k′) if T < T′, or if T = T′ and k < k′. Agent A updates A.clock by these rules:

  1. Each time A's physical clock advances by one unit, A increases the T-value of A.clock by 1 and sets its k-value to 0.
  2. Each event at an agent increases its (T, k) pair. When an agent sends a message, it increases its k-value by 1 and timestamps the message with the updated (T, k).
  3. When agent A, with clock (T, k), receives a message with timestamp (T′, k′):
    • if T > T′, then k := k + 1;
    • if T = T′, then k := max(k, k′) + 1;
    • if T < T′, then T := T′ and k := k′ + 1.

The graph of agents (vertices) and channels (directed edges) is strongly connected: there is a directed path from every agent to every other agent.

Part 1

Is the following algorithm for taking a global snapshot correct?

Each agent A records its local state when the T-value of A.clock reaches L, where L is a given positive constant. Agent A records the state of each incoming channel C as the sequence of messages with timestamps less than (L, 0) that A receives on C after A.clock reaches (L, 0). The agent states and channel states recorded in this way together form the global snapshot.

Either give an informal proof that the algorithm is correct, or give a counterexample and then change the algorithm so that it becomes correct.

Part 2

Each agent A records its local state and the states of its incoming channels, as in Part 1, each time the T-value of its logical clock reaches 0, L, 2L, 3L, …, where L is a positive constant. Let S_snap[t], for t = 0, L, 2L, …, be the global state recorded when the agents' logical clocks reach (T, k) = (t, 0).

The following algorithm is proposed for detecting a stable property P. Each agent sends its recorded local state, and the recorded states of its incoming channels, to a separate agent called the detector. (How they are sent does not matter.) The detector assembles S_snap[t] from what it receives. When it has a complete snapshot S_snap[t], the detector claims that P holds if P holds in S_snap[t].

Answer yes or no to each question, and justify your answer.

  1. Is the algorithm correct?
  2. If the detector claims that P holds at some point, does P hold at that point?
  3. If P holds at some point, will the detector eventually claim that P holds?

Question 2

Your project

Turn in your plan for your class project. The project guide says what goes in it: your question, team members, data source, a related paper or reference, and the course ideas you plan to use.