Exercise 1: Writes to the Non-Isolated Node During a Partition — Possible Solution ==================================================================== THE TEST ------------------------------ Using this chapter's own CPSystem, with the partition active (partitioned = True): cp.write(node_a, 'stock', 45) # the non-isolated ("primary") node cp.write(node_b, 'stock', 30) # the isolated node - this chapter's own original test RESULTS ------------------------------ write to node_a during partition succeeded, node_a.data: {'stock': 45} write to node_b correctly rejected: Write rejected: partitioned, cannot guarantee consistency Writing to node_a succeeded normally, updating node_a.data correctly. Writing to node_b was rejected with the identical ConnectionError this chapter's own text already verified. WHAT THIS CONFIRMS ABOUT WHICH NODE CP ACTUALLY SACRIFICES ------------------------------ CPSystem.write() only checks `node is self.node_b` before deciding whether to reject a write - meaning it isn't sacrificing availability for the SYSTEM as a whole during a partition, only for whichever side is specifically treated as "isolated" (node_b, in this chapter's own setup). node_a keeps functioning normally throughout the entire partition - it never loses availability at all. This matches the real- world shape of CP systems: a partition typically leaves one side (the side that can still reach a quorum, or is designated primary) fully functional, while the OTHER side - the one that can't be trusted to stay consistent - is the one that goes unavailable. WHY THIS MATTERS FOR UNDERSTANDING "SACRIFICES AVAILABILITY" ------------------------------ It would be easy to read "CP sacrifices Availability" as meaning the whole system stops responding during a partition. This exercise confirms that's not accurate for this chapter's own two-node design - availability is sacrificed specifically for clients that happen to be talking to the isolated side. Clients reaching node_a during the exact same partition see a fully functional, fully available system the entire time. WHY THIS WORKS AS AN ANSWER ------------------------------ Both nodes are tested under the identical partition using this chapter's own unmodified CPSystem, and the asymmetric result (node_a succeeds, node_b fails) is used to correct a plausible misunderstanding of what "sacrifices availability" means in practice.