Skip to main content

CSE 331: Exam review and persistent data

A server's data in variables lives in the program's memory, and ends with the run. Data is persistent if it outlasts the run of the program that wrote it, and a file on the disk does. So the guestbook keeps its book in a file, and its promise reaches across runs: when the server responds to a post request, that message will be saved forever, through every stop, a crash included.

Writing the file over in place breaks that promise: a test that injects a crash just after the file is opened (fault injection) loses every message. Writing a new file, syncing it to the disk, and moving it into place with an atomic move keeps it, and an argument that checks one claim at every point shows why, leaning on what the move and sync promise. A test that crashes only the program cannot see a missing sync; a power loss could. A database keeps these promises for you.