Skip to content

fix: add AOF persistence for hash and set commands - #28

Merged
kacy merged 1 commit into
mainfrom
refactor/aof-and-code-audit
Feb 6, 2026
Merged

fix: add AOF persistence for hash and set commands#28
kacy merged 1 commit into
mainfrom
refactor/aof-and-code-audit

Conversation

@kacy

@kacy kacy commented Feb 6, 2026

Copy link
Copy Markdown
Owner

summary

critical bug fix discovered during code audit: HSET, HDEL, HINCRBY, SADD, and SREM mutations were not being logged to the append-only file, causing data loss on restart when using AOF persistence.

  • adds AofRecord variants for HSet, HDel, HIncrBy, SAdd, SRem
  • implements binary serialization and deserialization for new record types
  • updates recovery module to replay hash and set mutations
  • extends to_aof_record() in shard.rs to emit new records on successful mutations
  • adds round-trip tests for all new AOF record types

also includes minor improvements from the audit:

  • improved documentation in memory.rs with platform notes
  • clarified MSET fan-out logic in connection.rs

test plan

  • cargo test passes (487 tests, up from 474)
  • cargo fmt clean
  • cargo clippy clean
  • new AOF record serialization round-trip tests
  • new to_aof_record tests for HSET, HDEL, HINCRBY, SADD, SREM

design notes

the AOF format uses sequential tag numbers (14-18) for the new record types, maintaining backward compatibility with existing AOF files. the serialization format follows the same pattern as existing commands (length-prefixed fields with CRC32 checksums).

critical bug fix: HSET, HDEL, HINCRBY, SADD, and SREM mutations were
not being logged to the append-only file, causing data loss on restart.

changes:
- add AofRecord variants for HSet, HDel, HIncrBy, SAdd, SRem
- implement serialization and deserialization for new record types
- update recovery to replay hash and set mutations
- extend to_aof_record() in shard.rs to emit new records
- add round-trip tests for all new AOF record types
- improve memory.rs documentation with platform notes
- clarify MSET fan-out logic in connection.rs
@kacy
kacy merged commit c0ee964 into main Feb 6, 2026
5 checks passed
@kacy
kacy deleted the refactor/aof-and-code-audit branch February 7, 2026 20:06
kacy added a commit that referenced this pull request Feb 11, 2026
fix: add AOF persistence for hash and set commands
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant