Brief
Reconstruct a row's creation, update, and deletion from CDC events without confusing current absence with never having existed.
Voss opens the current register: AUTH-9 is gone. Imani brings four messages from the CDC copy, and Mara asks you to explain the disappearance before the team drops the lead. In the fiction the case must move quickly; the exercise has no timer.
Your mission
- Order c, u, d, and tombstone for the same key.
- Reconstruct
approvedat each stage and final state. - Explain the difference between operation d and the tombstone's null value.
- Give a check and a limit before attributing the change to a person.
How to check your work
- 0/100, 0/120, 0/140, then tombstone.
- False, true, absent; past existence shown in the copy.
- Operation d documents deletion; tombstone supports compaction.
- Source/LSN/access checked; human author not inferred.
Course example
events=[
{"key":"AUTH-9","value":{"op":"c","lsn":"0/100","after":{"approved":False}}},
{"key":"AUTH-9","value":{"op":"u","lsn":"0/120","before":{"approved":False},"after":{"approved":True}}},
{"key":"AUTH-9","value":{"op":"d","lsn":"0/140","before":{"approved":True},"after":None}},
{"key":"AUTH-9","value":None},
]
current={}
history=[]
for event in events:
value=event["value"]
if value is None:
history.append("tombstone")
continue
op=value["op"]
if op=="d":
current.pop(event["key"],None)
else:
current[event["key"]]=value["after"]
history.append(op+" "+value["lsn"])
print("events",history)
print("final_row",current.get("AUTH-9"))
print("delete_lsn",events[2]["value"]["lsn"])
print("tombstone_value",events[3]["value"])