01A write succeeds in memory but the process crashes before fsync. How does the answer differ under `always`, `everysec`, and `no`?introScenarioYou are reasoning about the durability guarantees of the append-only file under different fsync policies.AAll three policies lose the write equally, because appending to the AOF buffer only happens after fsync has succeeded.BBoth `always` and `everysec` guarantee zero loss because they involve fsync; only `no` can lose the write — the difference between them is only how much CPU the fsync calls cost.CAlways minimizes that window by fsyncing each write, everysec can lose about the last second, and no depends on the operating system flush schedule.DEverysec is the safest because batching gives the OS time to flush, while `always` risks losing more writes under load.
02Why should `GET a` never appear in AOF, but `EXPIRE a 60` might?introScenarioYou are deciding which commands the AOF layer should record as the server executes them.AGET is read-only and should not be replayed, while EXPIRE changes future state and may need to be recorded as a mutation.BBoth should appear, because the AOF must record every command the server executed in order to reproduce the exact history.CEXPIRE is also excluded, because TTL metadata lives outside the keyspace and is restored separately from the command log.DGET is excluded because replaying it would overwrite the stored value with whatever the command returned at logging time.
03During AOF rewrite, why is `SET counter 42` a valid replacement for many earlier increments?appliedScenarioAn AOF rewrite is compacting a log that contains thousands of INCR commands against one counter key.AIt is valid because INCR commands are idempotent, so collapsing any number of them never changes the final result.BIt is only valid if the original log contained exactly 42 increments; otherwise the rewrite must preserve the full history.CIt is valid because rewrite scans the old log and keeps only the last command seen for each key, discarding the rest.DSET counter 42 is valid if 42 is the current state; rewrite stores an equivalent compact history rather than every increment.
04What is dangerous about replaying a relative expiration after downtime?appliedScenarioA server was down for two hours and is now replaying its AOF, which contains expiration commands recorded before the outage.AReplaying a relative TTL makes the key expire too early, because replay runs much faster than real time.BA relative expiration can grant extra lifetime after downtime, so AOF should replay an absolute deadline or normalized command.CRelative expirations cannot be parsed during replay, because the original wall-clock time is not stored anywhere in the file, which is why the loader falls back to treating them as absolute deadlines.DThe danger is double expiration, where the key is removed once at runtime and once again at replay, corrupting the keyspace.
05Which part of AOF persistence is about correctness, and which part is about file size?advancedScenarioYou are explaining to a teammate which AOF mechanisms protect data and which mechanisms only manage operational cost.AThe fsync policy is about file size, while rewrite is the correctness mechanism that repairs a corrupted log.BAppending and rewrite are both correctness mechanisms; file size is managed entirely by the operating system.CAppending and replaying the right mutations is correctness; rewrite is mainly about bounding file size while preserving equivalent state.DRewrite is about correctness because it removes commands that failed, while appending controls file size through buffering.