← Complete program

Chapter 18 · Course 2 c18-m02

When should a time window close?

Your goal Build an event-time window, explain watermarks, and plan how to handle a late event.

The lesson, the vocabulary, the worked example and the mission are separate blocks. You can follow them in order or return to the one you need.

Video explanation

This English explanation has English subtitles. Its examples may use a separate practice dataset; use the data stated in the written mission for your answers.

01

Story · optional context

The story so far

You are the new data recruit at Aster Motors. Luca was hurt in a crash involving a car resembling the missing Noctis 01 prototype, and Voss wants to blame you. Mara Sol and investigator Imani found two gate commands under the technical identity SUPPLIER-SVC. The second, OPEN-18, says 21:18 UTC, seven minutes before the crash signal, but reaches the stream at 21:36. Voss wants to publish a timeline that leaves it out because the 21:10–21:20 result had already been prepared.

This lesson stands alone. A window groups events over a period of their event times. A watermark is a marker of how far a processor estimates older events have probably arrived. You will place OPEN-18 in a ten-minute window, understand when it closes, and choose an explicit rule for events that arrive afterwards. The gate clock still needs independent confirmation.

02

Before the lesson

Purpose of this course

Build an event-time window, explain watermarks, and plan how to handle a late event.

Topics covered

Place 21:18 inside [21:10, 21:20) and understand why the end is excluded.; Separate the 21:36 receipt time from a watermark determined by events and the chosen strategy.; Show how a watermark before 21:20 permits E2 to join the window before its first result.; Choose whether an event arriving after closure revises a result or enters a review list.

What you will learn

  • Place 21:18 inside [21:10, 21:20) and understand why the end is excluded.
  • Separate the 21:36 receipt time from a watermark determined by events and the chosen strategy.
  • Show how a watermark before 21:20 permits E2 to join the window before its first result.
  • Choose whether an event arriving after closure revises a result or enters a review list.

PART 1 · THE LESSON

Understand step by step

1

Lesson · explanation

A case where time changes the result

You are Aster Motors' new data recruit. Luca was hurt in a crash involving a car resembling the missing Noctis 01 prototype. Voss wants to blame you. Mara Sol and investigator Imani are studying two gate commands under the technical account SUPPLIER-SVC. OPEN-18 says 21:18 UTC, seven minutes before the 21:25 crash signal, yet its message reaches the stream at 21:36.

Voss shows a chart prepared before that arrival. The 21:10 to 21:20 box looks empty, so he says the timeline is finished. If you place messages at the time your computer receives them, OPEN-18 appears after the crash. If you use the time stated for the event, it belongs to an earlier box. Those two timelines answer different questions, and a trustworthy report keeps both visible.

A data engineer designs rules that turn messages into reliable results. Here you analyze a practice copy; you do not control a real gate. You will learn where an event belongs, when to publish a first result, and how to correct it when a message arrives late. You must also explain why the gate clock and a technical account do not yet identify a human or prove a cause.

Pause and think

Why might Voss's prepared chart omit OPEN-18?

See the explanation

OPEN-18 states event time 21:18 but does not reach the processor until 21:36, after an initial result may have been prepared.

2

Lesson · explanation

Two clocks for one message

Event time is when a source says something happened. Receipt time is when the processor sees the message. Imagine taking a picture at 21:18 and sending it to a friend at 21:36. Sending it later does not change the time stated by the camera. OPEN-18 declares event time 21:18 and arrives at 21:36, an eighteen-minute gap. Keep both values instead of replacing one with the other.

The clocks answer separate questions. To ask what the gate controller reported before the crash, group by stated event time. To ask when your system learned about it, inspect receipt time. Grouping OPEN-18 by 21:36 would place it after the 21:25 crash signal and hide its stated earlier position. Yet calling 21:18 a verified fact would also go too far: clocks can be wrong or badly synchronized.

Record the source of each value: 21:18 is stated in the gate message, while 21:36 is observed on arrival. An independent log should check the controller clock before the event timeline becomes evidence. For this exercise, the times are laboratory inputs. They teach a calculation; they do not prove who used SUPPLIER-SVC, whether the gate physically opened, or what caused Luca's crash.

Pause and think

Does arrival at 21:36 change OPEN-18's stated event time?

See the explanation

No. Its stated event time remains 21:18; 21:36 records when the processor received it.

3

Lesson · explanation

Make windows with clear boundaries

A window is a time box for grouping events. Imani draws fixed ten-minute boxes: [21:00,21:10), [21:10,21:20), and [21:20,21:30). The left square bracket includes the start; the right parenthesis excludes the end. This convention gives a boundary event one home instead of counting it in two neighboring windows. The notation may look new, but it is just a precise label on each box.

E1 at 21:05 enters [21:00,21:10). E2/OPEN-18 at 21:18 enters [21:10,21:20). The crash signal at 21:25 enters [21:20,21:30). A record at exactly 21:20 enters the third box. Even one second before it, 21:19:59, belongs to the second. Check the exact boundary instead of guessing from a box's nickname.

Picture cards marked with event times. A 21:18 card goes into the box beginning at 21:10; a 21:20 card goes into the next. Putting E2 in [21:30,21:40) because it arrived at 21:36 answers a question about reception, not the stated event. When you show a window result, label which time field selected its box. Otherwise a reader cannot reproduce your chart.

Pause and think

Which window contains an event exactly at 21:20?

See the explanation

[21:20,21:30), because 21:20 is excluded from [21:10,21:20) and included in the next window.

4

Lesson · explanation

A watermark marks estimated progress

A stream may receive events out of order. The processor must eventually decide it has waited long enough to produce a window result. A watermark is a marker in event time: according to the chosen strategy, it says how far the system estimates older events have probably arrived. It is not the wall clock and does not have to equal the latest receipt time. It helps processing move forward despite disorder.

Imagine a teacher waiting for homework from several pupils. She says, 'I think most work dated before Tuesday has arrived, so I can start marking.' A forgotten worksheet can still appear. Likewise, a watermark permits a first calculation without promising that every earlier event has arrived. One sender may be silent, or a message may be stuck on its way. The marker represents a policy and an estimate.

Sources and processing strategy determine this marker. Two streams receiving a message at 21:36 may have different watermarks. The eighteen-minute delay between OPEN-18's 21:18 and its receipt at 21:36 does not, by itself, calculate a watermark. To explain a real result, inspect the observed marker, the out-of-order policy, and relevant source progress. Simply saying 'watermark equals 21:36' would be an unsupported guess.

Pause and think

Must the watermark equal receipt time 21:36?

See the explanation

No. It is an event-time progress marker produced by a strategy, not a copy of the receipt clock.

5

Lesson · explanation

Two watermarks lead to different choices

OPEN-18 belongs to [21:10,21:20), whose end is 21:20. Suppose it arrives at 21:36 while the watermark is still 21:15. The marker has not passed the end of its window. In this practice scenario, E2 can join the window before the first result is produced. Its late arrival on the wall clock does not move its declared event time or its ten-minute box.

Now replay the same arrival with a watermark already at 21:22. The marker has passed 21:20, so the initial window result may already be out. E2 still says 21:18 and belongs to the same logical window, but it is late for that first result. Apply a declared revision or review policy. Dropping the record just because it challenges Voss's chart would turn a processing decision into a hidden omission.

The event is identical in both examples; only processor progress at arrival differs. Compare the watermark with the end of the event's window, not with the crash time and not with receipt time alone. A real engine's precise trigger and closure rules also depend on configuration. A watermark is useful for deciding what to publish, yet it never proves absolute completeness of the underlying story.

Pause and think

If the watermark is 21:22 when E2 arrives, does E2's event time become 21:22?

See the explanation

No. Its stated event time remains 21:18; 21:22 describes the processor's progress past the window end.

6

Lesson · explanation

Plan a correction rather than freezing an error

A team may wait longer for the first result, allow late updates for a defined period, or send events that are too late into a separate review output. Waiting slows reporting. Revising means readers must track versions. Manual review costs effort. Whichever policy is chosen, keep the raw event visible. Its absence from the first chart is not evidence that it was absent from the stream or the events under investigation.

In Flink, allowed lateness and closure are driven by watermark progress. 'Twenty minutes of allowed lateness' is not automatically twenty wall-clock minutes from receipt at 21:36. You need the engine's rule and current state to know whether an old window can still update. If it can, OPEN-18 may cause a revised result. If it cannot, place E2 in a clearly named review output rather than silently deleting it.

Think of a newspaper printing a morning edition and an afternoon correction. The correction should say which edition it changes. Mara can store the window identifier [21:10,21:20), publication time, version number, initial or corrected status, and E2's identifier. A fresh chart with no link to the previous one hides the change. A versioned report lets Imani trace how OPEN-18 entered the investigation.

Pause and think

If a window no longer accepts an automatic update, should E2 be discarded?

See the explanation

No. Preserve the raw message and route it to review so any correction is documented.

7

Lesson · explanation

Say what the evidence can establish

An investigation timeline should distinguish stated event order from discovery order. On the first, OPEN-18 says 21:18 and the crash signal is 21:25, seven minutes later. On the second, the processor only received OPEN-18 at 21:36. These are not contradictory timelines: they answer different questions. Show the time source, selected window, and report version so another person can check the result.

OPEN-18's place in [21:10,21:20) does not prove the gate physically opened or that this command caused the crash. The record is a lead to investigate. The gate controller clock may be wrong; compare it with an independent log. SUPPLIER-SVC is a technical account, not a human name. Turning it into an accusation requires further evidence. Good data work states both a finding and its uncertainty.

Voss wants to present an incomplete first report as final. Your job is to show the late message, the rule used for it, and any documented correction without inventing a criminal conclusion. Reproducible data results let Mara and Imani ask why E2 appears in a corrected version. The difference between 'the message says 21:18' and 'we proved an action occurred at 21:18' matters throughout the case.

Pause and think

What can SUPPLIER-SVC alone tell us about a suspect?

See the explanation

It names a technical account in these records, but it does not identify the human who used it.

8

Lesson · explanation

Work through the mission calmly

Before the fictional meeting, draw [21:00,21:10), [21:10,21:20), and [21:20,21:30). Put E1 at 21:05 in the first, E2/OPEN-18 at 21:18 in the second, and the 21:25 crash signal in the third. Write 'received 21:36' next to E2 so the two clocks remain separate. Paper is enough for this practice; no Flink server or real gate is involved.

Under your drawing, write two scenarios. At watermark 21:15, the 21:20 end has not been passed and E2 may join the first result. At watermark 21:22, the initial result may already be published; E2 is late and requires a permitted revision or a review output. Keep the original message in either case. Do not turn receipt time 21:36 into a guessed watermark.

Finish with a short report for Mara: window, stated event time, receipt time, watermark scenario, decision, version, and evidence caveat. This structure helps Imani see exactly what changed and stops Voss from hiding the arrival. The scene is urgent in the story, but the exercise has no actual timer. Check the 21:20 boundary and spell out what remains unknown before submitting.

Pause and think

What should connect a corrected chart to the earlier incomplete chart?

See the explanation

Keep the window identifier and report version or initial/corrected status, along with the late E2 record.

Visual guide

OPEN-18 and the ten-minute window

  1. 1E2 event time 21:18 → window [21:10,21:20)
  2. 2Receipt 21:36 is not the watermark
  3. 3Watermark 21:15 → window open → include E2
  4. 4Watermark 21:22 → first window closed → late-event policy

A published result must be explainable and either correctable or accompanied by a late-event alert.

Code · read each line

A ten-minute window in a local copy

from datetime import datetime, timezone
def t(s): return datetime.fromisoformat("2026-04-12T"+s+":00+00:00")
window_start, window_end=t("21:10"),t("21:20")
e2={"id":"E2","event_at":t("21:18"),"received_at":t("21:36")}
def decide(watermark):
    if e2["event_at"] < window_start or e2["event_at"] >= window_end:
        return "wrong window"
    return "include E2" if watermark < window_end else "late: review or revise"
print("window", "21:10-21:20")
print("watermark 21:15", decide(t("21:15")))
print("watermark 21:22", decide(t("21:22")))
print("event before crash minutes", int((t("21:25")-e2["event_at"]).total_seconds()/60))

The same E2 joins the first result if estimated progress has not crossed the window end. Once closed, an explicit late-event policy applies.

PART 2 · WATCH IT WORK

A complete worked example

Follow each step, then the result

Worked example: the 21:10 box

E2 says 21:18, arrives at 21:36, and the ten-minute window ends at 21:20.

  1. Put 21:18 between inclusive 21:10 and exclusive 21:20.
  2. With watermark 21:15, the 21:20 boundary is not crossed, so E2 joins the first result.
  3. With watermark 21:22, the boundary is crossed: mark E2 late and apply the revision policy.
  4. Record whether the report is initial or corrected; do not hide the change.
What this shows

The window uses event time; its closure uses estimated progress rather than receipt time alone.

How this helps with your mission

For the mission, place E2 at 21:18 in [21:10,21:20) and the crash signal at 21:25 in [21:20,21:30). Compare watermarks 21:15 and 21:22 with the 21:20 window end, choose inclusion or late-event handling, and retain report versions. Flag the gate clock and the human behind SUPPLIER-SVC as unverified.

PART 3 · YOUR TURN

Use the lesson to solve the mission

Story scene · practical task

Mission: the result Voss wants to freeze

Voss displays a graph without OPEN-18 and says the calculation is over. Imani places the 21:36 message on your screen. Mara asks you to rebuild the window and prepare a traceable correction before the meeting. The fictional scene is urgent; the exercise has no timer.

Your task

  1. Name the ten-minute windows containing E2 and the crash signal.
  2. Explain what happens if the watermark is 21:15 or 21:22 when E2 arrives.
  3. Propose a late-event policy that preserves E2 and records a corrected report.
  4. State a limit concerning the clock and SUPPLIER-SVC's human user.

How to know you have succeeded

  • E2 in [21:10,21:20); crash in [21:20,21:30).
  • At 21:15 include it; at 21:22 flag it late and revise or send it for review.
  • Keep report version and status; no silent loss.
  • Confirm the clock independently; the human identity remains unknown.
Open this mission in the browser workspace

Try code or SQL and keep a local draft. The mission questions are checked separately below.

Check the facts in your mission

Answer each factual question, then write your report in your own words. The program checks the choices; compare the report with the worked answer below.

1. Which ten-minute window contains E2/OPEN-18 by its stated 21:18 event time?
2. Which box contains the 21:25 crash signal, and where does an event at exactly 21:20 go?
3. E2 arrives at 21:36 while the watermark is 21:15. Which decision matches the lesson's scenario?
4. E2 arrives after the watermark has reached 21:22. Which statement is correct?
5. Which policy protects the investigation when E2 arrives after the first result?
6. What can be stated from the OPEN-18 message and SUPPLIER-SVC alone?
See the worked answer
  1. E2's 21:18 event time places it in [21:10,21:20). The 21:25 crash signal is in [21:20,21:30).
  2. 21:15 is before the window end, so E2 joins the first result. 21:22 is after it, so E2 is late for the initial result.
  3. Keep the raw event and revise if the window remains revisable; otherwise send it to manual review. Store the report version.
  4. The gate clock must be checked against independent records. SUPPLIER-SVC is a technical identity, not a named suspect.

You can now explain when a result may change. The next lesson protects the calculation against a failure midstream.

Before you leave

Remember this

  • An event-time window uses E2's stated 21:18 even though its message arrives at 21:36.
  • [21:10,21:20) includes 21:10 and 21:18, but excludes exactly 21:20.
  • A watermark estimates event-time progress; it is neither the wall clock nor a promise of complete data.
  • At watermark 21:15, E2 may join the first result; at 21:22 it is late for that result.
  • A late event needs a traceable revision when allowed or a review output, never silent disappearance.
  • The record and SUPPLIER-SVC alone prove neither human identity nor accident cause.

Continue with the integrated lessons

After the lesson and its mission, work through the additional lessons below in order. Each workshop supplies its own fictional data: do not merge identifiers or times from separate exercises into the story timeline.

A–Z

Part of the lesson · keep nearby

New words, explained

These are the names of ideas used in the lesson above. Return here whenever a word feels unfamiliar.

Window
A time slice used to group facts, such as 21:10 inclusive through 21:20 exclusive.
Watermark
An event-time progress marker: the system estimates that older facts have probably arrived.
Exclusive end
A boundary outside the interval; 21:20 belongs to the next window.
Allowed lateness
A rule that can keep a result open for updates after its first close, based on watermark progress.
Late event
A fact whose event time falls in a window that has already closed when it arrives.
Revision
A new published result caused by a relevant fact arriving after the initial result.
Review output
A separate record of events too late to include automatically, so they are not silently lost.

Définir l’ordre causal des événements

Un nœud crée un lot, puis un deuxième reçoit cette création et annonce sa validation. Un troisième peut recevoir la validation avant la création à cause de délais différents. La narration semble inversée, et une base pourrait essayer de modifier un objet inexistant. Le problème n’est pas résolu par une horloge monotone, qui ne se compare pas entre nœuds, ni par des horloges civiles imparfaitement synchronisées : le deuxième message peut porter une date apparemment antérieure au premier.

La relation « arrive avant », ou happens-before, décrit une causalité potentielle. Un événement est une étape locale, l’envoi ou la réception d’un message. Sur un nœud à une seule séquence d’exécution, les événements suivent un ordre total local ; on peut représenter plusieurs fils par plusieurs nœuds logiques. Si a précède b localement, a→b. Si a envoie un message et b reçoit ce même message, a→b. Enfin, si a→c et c→b, alors a→b : on ferme la relation par transitivité.

Identifier chaque message de façon unique, par exemple par couple émetteur/numéro de séquence, permet de relier correctement émission et réception malgré les doublons. Le temps ne remonte pas entre envoi et réception. La relation est un ordre partiel strict : elle est transitive et irréflexive. Une boucle causale violerait l’ordre local ou la propagation de l’information ; une information ne peut pas arriver avant d’exister. L’asymétrie découle de l’irréflexivité et de la transitivité.

Si ni a→b ni b→a, les événements sont concurrents, notés a∥b. « Concurrents » ne signifie pas nécessairement « à la même heure » : il n’existe pas de chaîne de messages reliant ces événements dans un sens ou dans l’autre. Pour deux événements distincts, exactement une des relations a→b, b→a ou a∥b vaut. Pour un événement comparé à lui-même, ces trois propositions ne s’appliquent pas comme une trichotomie stricte.

Le lien avec la physique est celui d’une influence possible : un événement dans le cône de propagation d’un autre pourrait en dépendre ; un événement indépendant ne peut pas en être causé par les communications du modèle. L’algorithme n’affirme pas une causalité philosophique certaine. Un ordre total causal prolonge la relation partielle : a→b impose a avant b, tandis que deux événements concurrents peuvent être départagés arbitrairement.

Exemple appliqué aux données

relation = {('a','b'), ('c','d'), ('e','f'), ('b','c'), ('d','f')}
while True:
    étendue = relation | {(a,d) for a,b in relation for c,d in relation if b == c}
    if étendue == relation:
        break
    relation = étendue
assert ('a','f') in relation
assert not any(a == b for a,b in relation)
assert all((x,'e') not in relation and ('e',x) not in relation for x in 'abcd')

Simulation Python locale à exécuter séparément. Les assertions vérifient les cas présentés ; ce code ne constitue pas une implémentation distribuée de production.

À toi de jouer

A exécute a puis envoie m lors de b. B reçoit m lors de c puis envoie n lors de d. C exécute e puis reçoit n lors de f. Donne les dépendances par transitivité et les événements de A/B concurrents à e.

Voir la correction expliquée

Les relations directes sont a→b, c→d, e→f, b→c et d→f. On déduit notamment a→c, a→d, a→f, b→d, b→f et c→f. e est concurrent à a, b, c et d ; le fait qu’il précède f n’indique pas qu’il précède les causes venues de B.

Références : Notes originales de Martin Kleppmann — Cambridge 2025/26.

Adapté de Distributed Systems — notes de cours 2025/26, Martin Kleppmann, University of Cambridge, pages 35–38. Consulter le PDF source et ses illustrations · Provenance. Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) — adaptation française et exemples modifiés

Construire une horloge de Lamport

Une horloge logique compte des événements plutôt que des secondes. Dans une horloge de Lamport, chaque nœud initialise son compteur à zéro et l’incrémente pour chaque événement local. À l’émission, il incrémente puis joint la valeur au message. À la réception d’un message portant t, il affecte à son compteur max(compteur,t)+1 avant de livrer le message à l’application. Compter un envoi comme un événement évite un double incrément accidentel dans une implémentation.

La propriété essentielle est a→b implique L(a)<L(b). Elle se vérifie pour les étapes locales et pour un envoi suivi de sa réception ; la transitivité étend ensuite le raisonnement à toute chaîne causale. L’inverse est faux : L(a)<L(b) ne prouve pas a→b, car deux compteurs indépendants peuvent prendre des valeurs différentes. Des événements distincts sur deux nœuds peuvent même avoir la même valeur logique.

Pour rendre les identifiants uniques, associer le compteur à une identité de nœud unique. Ordonner les couples lexicographiquement : comparer d’abord le compteur, puis le nom du nœud en cas d’égalité. On obtient un ordre total qui respecte toute causalité connue. Pour les événements concurrents, l’ordre obtenu est une décision conventionnelle, sans signification de temps physique.

Le compteur doit rester compatible avec le modèle de panne. En crash-stop, il n’y a pas de retour sous la même identité ; en crash-recovery, conserver l’état logique durable ou utiliser une nouvelle identité/époque selon le protocole. Sinon une machine peut réémettre un identifiant déjà utilisé. Le type entier Python évite un débordement de taille fixe dans la démonstration, mais le format de sérialisation et les limites de stockage restent à définir en production.

Un horodatage de Lamport permet de comparer des événements déjà connus, mais ne garantit pas qu’aucun message plus ancien n’arrivera plus tard. Il ne fournit donc pas, à lui seul, une livraison en ordre total avec progrès en présence de pannes. Cette distinction sera importante pour la diffusion : trier une liste complète et savoir quand cette liste est complète sont deux problèmes différents.

Exemple appliqué aux données

compteurs = {'A': 0, 'B': 0, 'C': 0}
def événement(nœud, reçu=0):
    compteurs[nœud] = max(compteurs[nœud], reçu) + 1
    return compteurs[nœud], nœud
a = événement('A'); b = événement('A')
c = événement('B', b[0]); d = événement('B')
e = événement('C'); f = événement('C', d[0])
assert [a,b,c,d,e,f] == [(1,'A'),(2,'A'),(3,'B'),(4,'B'),(1,'C'),(5,'C')]
assert a < b < c < d < f
# a et e sont concurrents malgré leur ordre lexicographique.

Simulation Python locale à exécuter séparément. Les assertions vérifient les cas présentés ; ce code ne constitue pas une implémentation distribuée de production.

À toi de jouer

Reprends le scénario A/B/C précédent, avec e comme premier événement local de C, et ajoute un événement local de A après b. Calcule les couples Lamport, puis explique pourquoi comparer e et a ne prouve pas une causalité.

Voir la correction expliquée

A produit a=(1,A), b=(2,A), puis son événement suivant=(3,A). B reçoit c=(3,B) et envoie d=(4,B). C produit e=(1,C), puis reçoit f=(5,C). Les couples départagent a et e par nom, mais les deux événements restent concurrents : l’ordre total ajoute un choix aux dépendances réelles.

Références : Notes originales de Martin Kleppmann — Cambridge 2025/26.

Adapté de Distributed Systems — notes de cours 2025/26, Martin Kleppmann, University of Cambridge, pages 38–40. Consulter le PDF source et ses illustrations · Provenance. Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) — adaptation française et exemples modifiés

Distinguer les garanties d’ordre d’une diffusion

Une diffusion, ou broadcast, livre un message à tous les membres d’un groupe ; ce concept dépasse la diffusion IP locale. Le groupe peut être fixe ou gérer entrées et sorties selon un protocole. On construit souvent la diffusion à partir de liens point à point. Une diffusion best-effort peut perdre des messages ; une diffusion fiable les retransmet pour que les nœuds corrects finissent par les livrer, sans borne temporelle dans un modèle asynchrone ou partiellement synchrone.

Distingue les actions : l’application demande de diffuser, l’algorithme envoie des messages sur le réseau, le réseau les reçoit, puis l’algorithme les livre à l’application. Une réception peut être mise en tampon avant livraison. Cette attente permet de respecter un ordre malgré l’arrivée désordonnée des paquets. Une boucle locale représente aussi la livraison à soi-même, nécessaire pour que tous les membres observent la même abstraction.

La diffusion FIFO respecte l’ordre d’émission de chaque émetteur, mais n’impose pas un ordre commun entre deux émetteurs. Si A diffuse m1 puis m3 et B diffuse m2, les ordres m2,m1,m3 ; m1,m2,m3 ; m1,m3,m2 sont possibles. Si B a diffusé m2 en réaction à m1, un récepteur qui livre m2 avant m1 respecte éventuellement FIFO mais viole la causalité.

La diffusion causale impose que la diffusion de m1 précédant causalement celle de m2 entraîne la livraison de m1 avant m2 partout. Les messages concurrents restent librement ordonnés. Si m2 et m3 répondent tous deux à m1 sans dépendre l’un de l’autre, les séquences m1,m2,m3 et m1,m3,m2 sont valides. Le récepteur retarde une réponse reçue avant sa cause jusqu’à réception de la dépendance.

La diffusion en ordre total, dite atomique dans ce contexte, impose la même séquence de livraison sur tous les nœuds ; elle ne spécifie pas à elle seule quelle séquence choisir. FIFO-total ajoute le respect de l’ordre de chaque émetteur. Un ordre total seul n’est pas nécessairement causal ; FIFO-total est plus fort que causal, causal est plus fort que FIFO, puis viennent fiable et best-effort. Pour FIFO et causal, la livraison locale à l’émetteur peut être immédiate ; un ordre total peut imposer d’attendre un message d’un autre nœud avant sa propre livraison.

Exemple appliqué aux données

from itertools import permutations
ordres = list(permutations(['m1','m2','m3']))
fifo = [o for o in ordres if o.index('m1') < o.index('m3')]
causal = [o for o in fifo if o.index('m1') < o.index('m2')]
assert len(fifo) == 3 and len(causal) == 2

Simulation Python locale à exécuter séparément. Les assertions vérifient les cas présentés ; ce code ne constitue pas une implémentation distribuée de production.

À toi de jouer

Explique pourquoi causal implique FIFO. Puis explique le rôle de la livraison à soi-même pour démontrer que FIFO-total respecte la causalité des diffusions.

Voir la correction expliquée

Deux diffusions successives d’un même nœud sont reliées par l’ordre local, donc par happens-before. Pour FIFO-total, une diffusion causée par la livraison d’une autre est placée après cette livraison sur le nœud qui la produit ; l’ordre total transporte cet ordre partout, et FIFO couvre les émissions locales successives. En suivant la chaîne de dépendances, la propriété s’étend transitivement.

Références : Notes originales de Martin Kleppmann — Cambridge 2025/26.

Adapté de Distributed Systems — notes de cours 2025/26, Martin Kleppmann, University of Cambridge, pages 43–47. Consulter le PDF source et ses illustrations · Provenance. Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) — adaptation française et exemples modifiés

Official references