Commit 8fdb03a
fix: repair setCompression's persist-retry and same-instance reopen bugs
Independent pre-push review (codex + gemini + grok + Harper-domain
adjudication) of the full branch diff found two real correctness bugs in
the setCompression feature this PR already carries (not introduced by
the CI fix), both silently reverting a durably-requested compression
change:
- database.cpp: the no-op short-circuit compared only the LIVE
GetOptions() value. After a SetOptions() call whose in-memory apply
succeeded but whose OPTIONS-file persist failed (ENOSPC/EROFS/EIO --
the exact split the existing error message already describes), a
retry at the same algorithm/level saw "already matches" and returned
success without ever calling SetOptions() again, leaving the OPTIONS
file stale forever. Added a per-CF compressionPersistDirty flag
(ColumnFamilyDescriptor) that forces the retry through SetOptions()
until a persist actually succeeds.
- database.ts: a successful setCompression() never updated
Store.compression, which Store.open() re-normalizes and reapplies on
every open(). A close()+open() on the SAME RocksDatabase/Store
instance therefore silently re-requested the ORIGINAL open-time
codec, undoing a durably-persisted live change with no error.
Also, smaller findings from the same review:
- database.cpp: createRocksDBError() only assigns its out-param on
success; napi_throw() could receive an uninitialized napi_value if
error construction itself failed. Initialize to nullptr and skip the
throw when unset (createRocksDBError's own NAPI_STATUS_THROWS_VOID
calls already throw a fallback error in that case).
- database.ts: setCompression's JSDoc claimed compact() reliably
forces existing data onto the new codec; corrected to match the
README's documented kIfHaveCompactionFilter caveat.
- database.cpp: trimmed PR-narrative/reviewer-facing comment blocks
added by the prior commit down to the load-bearing invariants.
- compression.test.ts: three existing setCompression sequences left a
database open on assertion/call failure (missing try/finally) --
wrapped them, since on Windows an open handle blocks the afterEach
cleanup and can cascade into unrelated test failures.
New regression coverage (test/compression.test.ts): a same-instance
close()+open() proving the live change survives, and a permission-
denied (read-only directory) failure injection proving a retry at the
same algorithm actually re-persists instead of taking the shortcut.
Both fail without the corresponding fix (verified by temporarily
reverting each).
Full suite: pnpm check clean; 722/722 passing tests, 2 pre-existing
skips (Node, full run).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WV3oB7zEeJvKFugn8DQ93e1 parent ea890eb commit 8fdb03a
3 files changed
Lines changed: 62 additions & 54 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
823 | 823 | | |
824 | 824 | | |
825 | 825 | | |
826 | | - | |
827 | | - | |
828 | | - | |
829 | | - | |
830 | | - | |
831 | | - | |
832 | | - | |
833 | | - | |
834 | | - | |
835 | | - | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
836 | 829 | | |
837 | 830 | | |
838 | | - | |
839 | | - | |
840 | | - | |
841 | | - | |
842 | | - | |
843 | | - | |
844 | | - | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
845 | 836 | | |
846 | | - | |
847 | | - | |
848 | | - | |
849 | | - | |
850 | | - | |
851 | | - | |
852 | | - | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
853 | 841 | | |
854 | 842 | | |
855 | 843 | | |
| |||
860 | 848 | | |
861 | 849 | | |
862 | 850 | | |
863 | | - | |
864 | | - | |
865 | | - | |
866 | | - | |
867 | | - | |
| 851 | + | |
| 852 | + | |
868 | 853 | | |
869 | | - | |
870 | | - | |
871 | | - | |
872 | 854 | | |
873 | 855 | | |
874 | 856 | | |
| |||
902 | 884 | | |
903 | 885 | | |
904 | 886 | | |
905 | | - | |
906 | | - | |
907 | | - | |
908 | | - | |
909 | | - | |
910 | | - | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
911 | 894 | | |
912 | 895 | | |
913 | 896 | | |
| |||
929 | 912 | | |
930 | 913 | | |
931 | 914 | | |
932 | | - | |
933 | | - | |
934 | | - | |
935 | | - | |
936 | | - | |
937 | | - | |
938 | | - | |
939 | | - | |
940 | | - | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
941 | 920 | | |
942 | 921 | | |
943 | 922 | | |
944 | 923 | | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
945 | 927 | | |
946 | 928 | | |
947 | 929 | | |
948 | 930 | | |
949 | 931 | | |
950 | | - | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
951 | 935 | | |
952 | | - | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
953 | 939 | | |
954 | 940 | | |
| 941 | + | |
955 | 942 | | |
956 | 943 | | |
957 | 944 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
550 | 550 | | |
551 | 551 | | |
552 | 552 | | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
553 | 565 | | |
554 | 566 | | |
555 | 567 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
298 | 299 | | |
299 | 300 | | |
300 | 301 | | |
301 | | - | |
302 | | - | |
303 | | - | |
304 | | - | |
305 | | - | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
306 | 307 | | |
307 | 308 | | |
308 | 309 | | |
| |||
318 | 319 | | |
319 | 320 | | |
320 | 321 | | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
321 | 330 | | |
322 | 331 | | |
323 | 332 | | |
| |||
0 commit comments