fix(archive): make probe() async; remove block_on inside tokio runtime#2
Merged
Merged
Conversation
Archiver::probe() was synchronous but called Handle::current().block_on() on an async S3 head request. The startup path that invokes it sits inside a tokio runtime (Server::run_inner is async, called from rt.block_on in keplor-cli/main.rs), and tokio explicitly disallows nested block_on — abort with 'Cannot start a runtime from within a runtime'. Anyone enabling --features s3 and configuring [archive] hits this immediately on startup; this is the first time we shipped the feature live. Make probe() async and .await it at the call site. Verified end-to-end against a Cloudflare R2 bucket: 'event archival configured — S3 connectivity verified' on first start.
8915586 to
3d806de
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
`Archiver::probe()` was synchronous but called `Handle::current().block_on()` on an async S3 head request. The startup path that invokes it (`Server::run_inner`) is async — sitting inside the tokio runtime created in `keplor-cli/main.rs:run_server`. tokio explicitly disallows nested `block_on`, so anyone enabling `--features s3` and configuring `[archive]` hits this immediately on startup:
```
thread 'main' panicked at crates/keplor-store/src/archive.rs:74:49:
Cannot start a runtime from within a runtime. This happens because a function (like `block_on`) attempted to block the current thread while the thread is being used to drive asynchronous tasks.
```
This is the first time the s3 feature shipped live, so the bug had no production exposure before now.
Fix
3-line change.
Verified
End-to-end against a real Cloudflare R2 bucket — startup log:
```
{"level":"INFO","message":"event archival configured — S3 connectivity verified","bucket":"keplor-log","archive_after_hours":720,"archive_threshold_mb":15000,"interval_secs":3600}
```
`/health` 200, no panic.
Test plan