Repository navigation
Keeper log s3 - #79991
Keeper log s3#79991trololo23 wants to merge 62 commits into
Conversation
|
Egor Beketov seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
b5c3664 to
3c7bc93
Compare
|
Also i tested it on loading a tw-weather dataset, and there're results: It's so interest to see this 'waiting' effect on loading bar with s3 case - like the progress stops for about a 2 seconds(till Keeper replication and data sharing) and then goes forward. |
|
Hi @trololo23! Thanks for the contribution. The changelog entry is still the |
# Conflicts: # src/Coordination/Changelog.cpp # src/Coordination/CoordinationSettings.cpp # src/Coordination/KeeperContext.h # src/Server/KeeperTCPHandler.cpp
|
Workflow [PR], commit [4f0262e] Summary: ❌
AI ReviewSummaryThis PR adds an experimental Findings❌ Blockers
Final Verdict❌ Not ready to merge. The remaining S3 rollback and compaction issues can still lose durable history or make recovery depend on stale object state, and the user-facing contract is still incomplete around |
# Conflicts: # src/Coordination/KeeperContext.h
The previous declaration had `false` in the default position and `500` in the flags position, which is wrong. Default value is `500` and flags are `0`. Also clarified that units are microseconds in the description. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
🕵 Merged the latest The only CI red on the previous run, The unresolved review threads (the S3 durability-design family — compaction vs. |
# Conflicts: # src/Coordination/Changelog.h
`flushImpl` always ends by opening a fresh `write_buffer` for the next object, and a writer can also still be live when nothing was written since the previous `setFile`. In both cases `setFile` then overwrote `write_buffer` with a writer for a different object, destroying a live `WriteBufferFromS3` that was neither finalized nor canceled. That trips `chassert(false && "WriteBuffer is neither finalized nor canceled in destructor.")` in `WriteBuffer::~WriteBuffer` in debug and sanitizer builds. Cancel and reset the writer before installing the requested file. `cancel` rather than `finalize`, because the intermediate object holds no records and must not be published to S3. This addresses only the buffer-lifetime half of the review finding at `Changelog.cpp:215-237`; the `WriteMode::Append` rollback semantics in S3 mode remain a design decision for the feature author.
|
🕵 Merged the latest I also fixed one half of the newest review finding ( The The two CI reds on the previous run were both unrelated to this PR:
Also please take care of the CLA state — it blocks the merge regardless of CI. |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes15 object files changed (+137.69 KiB total), 0 added.
716 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Compile time of recompiled translation units52 translation units recompiled, 321 s compile time in total, 52 of them have a recent master baseline. Median compile-time ratio to the baselines is ×0.95 (machine-speed difference or a change affecting every TU); per-TU deltas below are relative to that ratio. |
…og_s3 # Conflicts: # src/Coordination/Changelog.cpp
`Changelog::writeThread` issues a `Flush` operation for every flush
request, including ones where no record was appended since the previous
flush -- an empty batch right after startup, or right after a flush that
already opened the next, still empty, S3 object. In that state
`S3ChangelogWriter::last_index_written` is empty, but
`S3ChangelogWriter::flush` dereferenced it unconditionally:
chassert(last_index_written);
flushImpl(*last_index_written + 1);
so the `chassert` fired in debug and sanitizer builds, and in the release
build the empty `std::optional` was read and the resulting garbage start
index handed to `flushImpl`. `flushImpl` then took its "empty state"
branch and fell through to reassign `write_buffer` with a freshly opened
object, destroying the live `WriteBufferFromS3` of the currently open
object while it was neither finalized nor canceled -- which trips the
`chassert(false && "WriteBuffer is neither finalized nor canceled in
destructor.")` in `WriteBuffer::~WriteBuffer`.
There is nothing to publish when no record was appended, and the object
that is already open must stay open to receive the following appends, so
an empty flush is now a no-op. This is a pure resource-lifetime and
`std::optional` correctness fix: it changes no durability semantics and
leaves the `WriteMode::Append` rewrite semantics of `writeAt` -- the
design half of the same review finding -- untouched.
|
🕵 Merged the latest Two conflicts, both mechanical, in
I verified the resulting diff against I also fixed the mechanical half of the empty-flush blocker ( The rest of the review findings are still design calls about the S3 durability contract and are left for you:
Each of those changes what the feature promises, so they are yours to decide — still left for you. The only CI red on the previous head was A reminder that the CLA is still unsigned for |
|
The CLA is unnecessary here, as this contribution is made as part of the coursework. |
|
🕵 Merged the latest The durability-design review items (compaction vs |
In S3 experimental changelog mode, the `writeAt` rollback path (`go_to_previous_file`) still compared the segment's disk against `getLatestLogDisk` and called `moveChangelogBetweenDisks` when they differ. The preserved segment lives on `s3_log_disk`, so this migrated already-durable data to a local disk that S3-mode startup never loads: `Changelog::readChangelogAndInitWriter` only scans `getS3LogDisk` when `isS3ExperimentalChangelog` is set, so the migrated prefix became invisible to recovery. Route the target disk through `getS3LogDisk` in S3 mode, the same way the startup path (`readChangelogAndInitWriter`) and the disk-move guard in `finalizeChangelogsAfterRead` already do. In S3 mode the segment is already on that disk, so no migration happens at all. This is the contract-neutral half of the finding: whether `writeAt` may reuse an existing S3 segment in place at all (`S3ChangelogWriter::setFile` ignoring `WriteMode::Append`) is a durability-design decision and is left to the author. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
🕵 CI on Pushed one contract-neutral fix taken out of the rollback blocker ( The design half of that same finding is untouched and still yours: whether Still left for you (unchanged, nine unresolved threads, none new since 2026-07-19):
Each of these changes the feature's durability contract or its user-visible surface, so they are design calls for you rather than something I should push. |
Refresh CI on current master. The branch has two merge bases, so the merged tree was assembled deterministically: master's tree overlaid with the nine files this pull request touches, with a three-way merge of `KeeperContext.cpp` (the only one master also changed) against the previously merged master.
|
🕵 Merged the current The branch had two merge bases again, so I assembled the merged tree deterministically (master's tree plus exactly the nine files this pull request touches, with a three-way merge of The only red on the previous head was I did not touch the design items. Still left for you:
|
|
I was pointed to this PR with the question if signing a CLA is mandatory for coursework. There was some internal discussion with the legal team about it. In short: PRs without signed CLA must only be merged if the PR author is an employee of ClickHouse Inc. (i.e. has a employment contract), or if the PR author has a consulting agreement with ClickHouse Inc. Coursework (e.g. for our intern tasks) is not exempt from this. @trololo23 Could you please sign the CLA? Thanks! |
|
Hi @rschu1ze, sorry for the late reply — this slipped off my radar completely. The CLA should be signed now for @trololo23. Let me know if the check still doesn't pass on your side. |
|
@trololo23 I see this -
I think the note for "Egor Beketov" will go away if you remove Egor's commits from the commit history, i.e squash them into commits from users with signed CLA. Or of course sign the CLA for Egor again. |
Refresh CI against the current `master` (`4d21de5fa77d`) and resolve the conflicts reported by GitHub. The branch again had two merge bases, so the merged tree was assembled deterministically: `master`'s tree plus exactly the nine files this pull request touches, with a three-way merge (base `2ca04b1b07f7`) of the three files `master` also changed - `Changelog.cpp`, `CoordinationSettings.cpp` and `CoordinationSettings.h`. The only textual conflict was in the `COORDINATION_SETTINGS_SUPPORTED_TYPES` macro in `CoordinationSettings.h`, where `master` added `Int64` and this branch added `String` on the same line; resolved as a union of both.
The restart test in `test_keeper_s3_changelog` restarted Keeper without removing the local coordination log directory, so it did not fully prove that recovery reads the changelog back from S3. Wipe `/var/lib/clickhouse/coordination/logs` between the stop and the start, so any local changelog residue cannot serve the replay. The local snapshot directory is deliberately kept: this feature moves only the changelog to S3, snapshots stay on `snapshot_storage_disk`, and with `snapshot_distance=10`, `stale_log_gap=10` and `reserved_log_items=1` the log is compacted once a snapshot is taken, so the changelog alone is not expected to carry the whole history.
|
🕵 Merged the current The branch had two merge bases again, so I assembled the merged tree deterministically: I also took the mechanical half of the review item on the replay test: The design items are untouched. Still left for you:
On the CLA: @rschu1ze's point is still open for the commits authored by "Egor Beketov". That is for you to resolve with him — I am not rewriting the branch history. |
| new_s3_description->prefix = DEFAULT_PREFIX; | ||
| new_s3_description->from_log_index = new_start_log_index; | ||
| new_s3_description->to_log_index = new_s3_description->from_log_index + log_file_settings.rotate_interval - 1; | ||
| new_s3_description->extension = "bin"; |
There was a problem hiding this comment.
S3ChangelogWriter still neither implements nor rejects compress_logs: appendRecord writes raw records, and flushImpl always opens the next segment as .bin here. With compress_logs=true, the setting silently stops working in S3 mode.
Worse, if writeAt ever reopens a carried-over compressed segment (for example from an old_log_storage_disk), setFile preserves the .bin.zstd extension but still rewrites raw bytes, so the next restart tries to decompress garbage. Please either reject compress_logs when s3_experimental_changelog is enabled or propagate the same compression/extension handling into the S3 writer.
There was a problem hiding this comment.
🕵 Fixed in 4f0262e3a70e by rejecting the combination: compress_logs together with s3_experimental_changelog now throws BAD_ARGUMENTS at startup. compress_logs defaults to false, so no working configuration changes; it just stops being silently ignored, and a carried-over bin.zstd segment can no longer be reopened and filled with raw bytes. Propagating real compression into the S3 writer and the compaction path remains open as a feature decision.
There was a problem hiding this comment.
This is not fully fixed in the current head.
The new startup check at src/Coordination/Changelog.cpp:4118-4123 only rejects compress_logs=true in the current config. Startup still loads changelogs from old_log_storage_disk at src/Coordination/Changelog.cpp:4227-4229, and writeAt can still reopen one of those older segments through current_writer->setFile(std::move(description), WriteMode::Append) at src/Coordination/Changelog.cpp:4949-4957.
S3ChangelogWriter::setFile preserves file_description->extension and immediately opens writeFile(s3_cur_path) at src/Coordination/Changelog.cpp:333-345, while appendRecord always writes raw bytes at src/Coordination/Changelog.cpp:361-385. So a carried-over changelog_4_6.bin.zstd from an old_log_storage_disk can still be reopened in S3 mode and rewritten with uncompressed bytes; the next restart will try to decompress garbage.
This thread should stay open until writeAt rejects or correctly re-encodes compressed carried-over segments as well.
There was a problem hiding this comment.
🕵 Addressed in 75b79138740 (continued in #123451): S3ChangelogWriter::setFile now throws NOT_IMPLEMENTED when asked to append to a compressed segment (is_compressed), so a carried-over bin.zstd segment can no longer be reopened and filled with raw bytes. Re-encoding remains a possible follow-up.
…log setups Three contract-neutral halves of the open review findings; the design questions in those threads (what the S3 mode should *do* about append-in-place rewrites, compaction planning and `LogLocation` rewriting) are untouched. 1. The S3 compaction thread removed merged source objects directly, without taking the descriptor's exclusive lock and without setting `removed_from_disk`. `executeReadPlan` and `serveReadAhead` rely on that flag being published under the lock: they check it and return `nullptr` instead of calling `readFile` on a removed path. A read plan or read-ahead cursor holding one of these `file_description` pointers could therefore hit `disk->readFile` after the object was unlinked and throw. The removal now goes through `withWriteLock` and sets the flag before `removeFile`, exactly like `Changelog::backgroundChangelogOperationsThread`. 2. `S3ChangelogWriter` neither implements nor rejects `compress_logs`: `appendRecord` writes raw records and `flushImpl` always opens the next object as `bin`, so the setting silently stops working, and a carried-over `bin.zstd` segment reopened by `writeAt` would be filled with raw bytes that the next startup cannot decompress. The combination is now rejected with `BAD_ARGUMENTS` at startup. 3. With `s3_experimental_changelog` enabled, startup scans only `old_log_storage_disk*` and `s3_log_disk`, so committed changelog files left on the regular local log disks are silently dropped from recovery. Since local-to-S3 migration is explicitly out of scope, that configuration is now rejected with `BAD_ARGUMENTS` pointing at `old_log_storage_disk`, instead of ignoring durable history. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
🕵 Merged the current I also took three more mechanical halves of the open review findings:
The design items are untouched. Still left for you:
Also still outstanding on the CLA: |
|
🕵 Superseded by #123451, which keeps all commits of this branch. I merged |







Experimental support for storing the Keeper changelog directly on object storage (S3) instead of (or in addition to) a local disk, gated behind the coordination setting
s3_experimental_changelog. Enables running Keeper without a local data volume.Configuration:
keeper_server.coordination_settings.s3_experimental_changelog— enable the experimental path.keeper_server.coordination_settings.s3_log_disk— name of the disk from<storage_configuration>to use for the changelog.keeper_server.coordination_settings.s3_flush_interval— flush interval in microseconds (default500).A background compaction thread merges adjacent S3 changelog files in the background to keep the file count bounded.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Experimental: support storing the Keeper changelog on S3, gated behind the coordination setting
s3_experimental_changelog.Documentation entry for user-facing changes
Note
Medium Risk
Adds a new code path for Keeper Raft log persistence to object storage (S3) with background file merging; although gated behind a new setting, it touches log durability/rotation behavior and could affect recovery if enabled.
Overview
Adds experimental support for writing Keeper changelogs directly to an S3 disk when
s3_experimental_changelogis enabled, including selecting the S3 disk vias3_log_disk.Refactors the changelog writer behind a new
IChangelogWriterinterface and introducesS3ChangelogWriter, which writes log segments to S3 and runs a background compaction thread to merge adjacent small segments; local-disk log loading/moving logic is adjusted to avoid cross-disk moves in S3 mode.Extends coordination settings /
KeeperContextto parse the new S3 changelog settings and adds an integration test scaffolding (MinIO-backed) plus a PR template checkbox prompting documentation for user-facing changes.Reviewed by Cursor Bugbot for commit fddb3be. Bugbot is set up for automated code reviews on this repo. Configure here.
Workflow [PR]
Sync PR [sync-upstream/pr/79991]