Time, Clocks, and the Ordering of Events in a Distributed System

Concepts

  • Distributed system

    • A collection of distinct processes which are spatially separated, and which communicate with each other by exchanging messages

    • Each process contains a sequence of events

  • Three important concepts

    • Time

    • Clock

    • Ordering of events

      • "Happen before": partial ordering of the events in the system, without using physical clocks

  • Though: problem of failures is a difficult one

    • The entire concept of failure is only meaningful in the context of physical time

    • Without it, there is no way of distinguish a failed process from one which is just puasing between events

  • The partial ordering

    • -->: "happen before" relation.

      • If a and b are events in the same process, and a comes before b, then a --> b

      • If a is the sending of a message by one process and b is the receipt of the same message by another process, then a --> b

      • If a --> b and b --> c then a --> c

    • Two distinct events a and b are said to be concurrent if and

    • Irreflexive partial ordering on the set of all events in the system

  • Logical clocks

    • Clocks: a way to assign number to the event, where the number is thought of as the time at which the event occurred

    • Clock CiC_i for each process PiP_i is a function which assigns a number Ci<a>C_i<a>to any event aa in that process (logical clock)

    • C<b>=Cj<b>C<b>=C_j<b> if b is an event in process PjP_j

      • But the converse condition is not true!

  • Total ordering of the events

    • Define relation => as follows

      • If a is an event in process PiP_i and b is an event in process PjP_j, then a => b if and only if either

      • This relation is a way of completing the "happened before" partial ordering to a total ordering

      • Clock condition implies that if a-->b then a ==> b

    • This ordering depends upon the system of clock CiC_i, and is not unique

      • Different choice of clocks which satisfy the clock condition yields different relation =>

      • It is only the partial ordering --> which is uniquely determined by the system of events

    • Why do we need total ordering?

      • The reason for implementing a correct system of logical clock is to obtain such total ordering

      • é€»č¾‘ę—¶é’Ÿč®¾č®”ēš„ęœ€ē»ˆē›®ēš„å°±ę˜Æäøŗäŗ†å¾—åˆ°äø€ē§äŗ‹ä»¶å…Øå±€ęŽ’åŗēš„ęœŗåˆ¶

    • Scenarios

      • System composed with a fixed collection of processes which share a single resource

      • Only one process can use the resource at a time, so the processes must synchronize themselves to avoid conflict

      • Find an algorithm for granting the resource to a process which satisfies the following condition

        • A process which has been granted the resource must release it before it can be granted to another process

        • Different requests for the resource must be granted in the order in which they are made

        • If every process which is granted the resource eventually releases it, then every request is eventually granted

  • Anomalous Behavior (cite)

    • Person issues a request A on a computer A, and then telephones a friend in another city to have him issue a request B on a different computer B. It is possible for request B to receive a lower timestamp and be ordered before request A.

    • This can happen because the system has no way of knowing that A actually preceded B, since that precedence information is based on messages external to the system.

    • Two possible ways

      • Explicit introduce into the system about necessary information about the ordering

        • I.e. friend could specify that B be given a timestamp latter than T_A

        • This gives users the responsibility to avoid anomalous behavior

      • Construct a system of clocks which satisfies (i.e. properly synchronized physical clocks)

        • Stronger than ordinary clock condition because --> is a stronger relation than ->

        • The discussion on the physical clock references the paper (the following materials are from the reference reading) --> need to understand and revisit this part

        • Goal: é€ščæ‡čæč”Œäø€äøŖę—¶é’ŸåŒę­„ē®—ę³•ļ¼ŒäæčÆę—¶é’ŸåÆ¹äŗŽä»»ä½•äŗ‹ä»¶ę‰“äøŠēš„ę—¶é—“ęˆ³éƒ½äøäŗ§ē”Ÿå‰é¢ēš„å¼‚åøøč”Œäøŗļ¼ˆanomalous behaviorļ¼‰ć€‚ä¹Ÿå°±ę˜ÆčÆ“ļ¼ŒåÆ¹äŗŽä»»ę„äø¤äøŖęœ‰ååŗå…³ē³»ēš„äŗ‹ä»¶ļ¼ˆęˆ–č€…čÆ“åÆčƒ½åœØå› ęžœę€§äøŠäŗ§ē”Ÿå½±å“ēš„äø¤äøŖäŗ‹ä»¶ļ¼‰ļ¼Œęˆ‘ä»¬ēš„ē‰©ē†ę—¶é’Ÿč¦äæčÆę€»ę˜Æä¼šäøŗåŽäø€äøŖäŗ‹ä»¶ę‰“äøŠäø€äøŖę›“å¤§ēš„ę—¶é—“ęˆ³ć€‚č¦å®žēŽ°čæ™äøŖē›®ę ‡ļ¼Œęˆ‘ä»¬é¢äø“ēš„éšœē¢äø»č¦ę„ęŗäŗŽē‰©ē†ę—¶é’Ÿēš„äø¤ē§čÆÆå·®ļ¼š

          • ę—¶é’Ÿēš„čæč”Œé€ŸēŽ‡č·ŸēœŸå®žę—¶é—“ēš„ęµé€é€ŸēŽ‡åÆčƒ½ęœ‰å·®å¼‚ļ¼›

          • ä»»ę„äø¤äøŖę—¶é’Ÿēš„čæč”Œé€ŸēŽ‡ęœ‰å·®å¼‚ļ¼Œå®ƒä»¬ēš„čÆ»ę•°ä¼šę¼‚ē§»å¾—č¶Šę„č¶Ščæœć€‚

        • LamportåœØč®ŗę–‡äø­ęå‡ŗēš„ē‰©ē†ę—¶é’ŸåŒę­„ē®—ę³• å°†čæ™äø¤ē§ę—¶é’ŸčÆÆå·®č€ƒč™‘åœØå†…ļ¼Œäøę–­åœ°åÆ¹å„äøŖčæ›ēØ‹ęœ¬åœ°ēš„ē‰©ē†ę—¶é’Ÿčæ›č”Œå¾®č°ƒļ¼ŒęŠŠčÆÆå·®ęŽ§åˆ¶åœØčƒ½å¤Ÿę»”č¶³Strong Clock Conditionēš„čŒƒå›“å†…ć€‚

        • åˆ†åˆ«č€ƒč™‘čæ›ēØ‹å†…ēš„äŗ‹ä»¶å’Œč·Øčæ›ēØ‹ēš„äŗ‹ä»¶ļ¼š

          • åÆ¹äŗŽčæ›ēØ‹å†…å‘ē”Ÿēš„äøåŒäŗ‹ä»¶ļ¼Œåæ…é”»äæčÆåŽå‘ē”Ÿēš„äŗ‹ä»¶ęÆ”å…ˆå‘ē”Ÿēš„äŗ‹ä»¶ę—¶é—“ęˆ³č¦å¤§ć€‚čæ™å®žé™…äøŠę˜Æč¦ę±‚ęˆ‘ä»¬äæčÆęÆäøŖē‰©ē†ę—¶é’Ÿå®žä¾‹ēš„čÆ»ę•°ę€»ę˜Æå•č°ƒé€’å¢žēš„ć€‚čæ™ę˜ÆęÆ”č¾ƒå®¹ę˜“å®žēŽ°ēš„ļ¼Œęˆ‘ä»¬åŖéœ€č¦åœØå¾®č°ƒę—¶é’ŸčÆ»ę•°ēš„ę—¶å€™ļ¼ŒåŖęŠŠčÆ»ę•°č°ƒå¤§č€ŒäøęŠŠčÆ»ę•°č°ƒå°ć€‚

          • åÆ¹äŗŽå‘ē”ŸåœØäø¤äøŖäøåŒčæ›ēØ‹äøŠēš„äŗ‹ä»¶

            • äøŗäŗ†äæčÆäøå‡ŗēŽ°å¼‚åøøč”Œäøŗļ¼Œęˆ‘ä»¬å°±č¦ę±‚ļ¼Œäøē®”A向Bä¼ é€’äæ”ęÆčæ™äøŖčæ‡ēØ‹å‘ē”Ÿēš„é€Ÿåŗ¦ęœ‰å¤šåæ«ļ¼ˆęœ€åæ«åÆä»„č¾¾åˆ°å…‰é€Ÿļ¼Œä½†åœØå®žé™…ē³»ē»Ÿäø­ļ¼Œē”±äŗŽē½‘ē»œå»¶čæŸå’Œē¼“å­˜ē­‰åŽŸå› ä¼šę…¢å¾ˆå¤šļ¼‰ļ¼ŒčÆ·ę±‚Bå‘ē”Ÿę—¶ēš„ę—¶é’ŸčÆ»ę•°éƒ½åæ…é”»å¤§äŗŽčÆ·ę±‚Aå‘ē”Ÿę—¶ēš„ę—¶é’ŸčÆ»ę•°ć€‚

            • čæ™äøŖč¦ę±‚åÆčƒ½ę²”ę³•č¢«ę»”č¶³ēš„åŽŸå› åœØäŗŽäø¤č¾¹ēš„ē‰©ē†ę—¶é’ŸåÆčƒ½ęœ‰čÆÆå·®ć€‚

            • å› ę­¤ļ¼Œå°±éœ€č¦åœØäøåŒēš„ē‰©ē†ę—¶é’Ÿä¹‹é—“äŗ¤ę¢äæ”ęÆļ¼Œå¹¶å€ŸåŠ©čæ™äŗ›äæ”ęÆåŒę­„ę—¶é’ŸčÆ»ę•°ć€‚

              • Expect åÆä»„ęŠŠę—¶é’Ÿä¹‹é—“ēš„čÆÆå·®ęŽ§åˆ¶åœØäø€å®ščŒƒå›“å†… ļ¼ˆåŖč¦ęˆ‘ä»¬åœØę—¶é’Ÿä¹‹é—“äŗ¤ę¢äæ”ęÆč¶³å¤Ÿé¢‘ē¹ļ¼‰ć€‚čæ™ę˜Æäø¤ē§ęœŗåˆ¶ēš„čµ›č·‘ļ¼š

                • äø€ę–¹é¢ļ¼ŒAé€ščæ‡ē³»ē»Ÿå¤–ēš„ę–¹å¼å‘Bä¼ é€’äæ”ęÆļ¼ŒåŖč¦čæ™äøŖčæ‡ēØ‹č¶³å¤Ÿåæ«ļ¼Œä»–ä»¬å°±ęœ‰åÆčƒ½ā€œēœ‹åˆ°ā€ę—¶é’ŸčÆÆå·®é€ ęˆēš„ę—¶é’ŸčÆ»ę•°å‡é€€ļ¼ˆä¹Ÿå°±ę˜Æå‡ŗēŽ°äŗ†å¼‚åøøč”Œäøŗļ¼‰

                • å¦äø€ę–¹é¢ļ¼Œē‰©ē†ę—¶é’ŸåŒę­„ē®—ę³•é€ščæ‡åœØę—¶é’Ÿä¹‹é—“äøę–­äŗ¤ę¢äæ”ęÆå¹¶ęŒ‰ē…§äø€å®šč§„åˆ™č°ƒę•“ę—¶é’ŸčÆ»ę•°ļ¼Œå°†ę—¶é’ŸčÆÆå·®ęŽ§åˆ¶åœØäø€å®ščŒƒå›“å†…ć€‚åŖč¦ē®—ę³•ēš„å„äøŖå‚ę•°č®¾ē½®å¾—å½“ļ¼Œå°±čƒ½äæčÆļ¼šå³ä½æA向Bä¼ é€’äæ”ęÆēš„é€Ÿåŗ¦č¾¾åˆ°ē‰©ē†ęžé™ā€”ā€”å…‰é€Ÿļ¼Œä»–ä»¬ä¹Ÿę— ę³•ā€œēœ‹åˆ°ā€ę—¶é’ŸčÆ»ę•°ēš„å‡é€€ēŽ°č±”ć€‚äŗŽę˜Æļ¼ŒStrong Clock Condition就被滔足了。

Last updated

Was this helpful?