Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(pindexer): optional exit-on-catchup #5101

Merged
merged 2 commits into from
Feb 21, 2025
Merged

Conversation

conorsch
Copy link
Contributor

Describe your changes

For running batch jobs managing indexing pipelines, it'd be convenient to instruct pindexer to exit after it's finished processing the events that's available to it. This situation arises frequently in batch processing, where pindexer will be pointed at a source db that was restored from a db. Having pindexer exit 0 on success, else non-zero on error, will aid in building out test infrastructure.

Issue ticket number and link

N/A

Checklist before requesting a review

  • If this code contains consensus-breaking changes, I have added the "consensus-breaking" label. Otherwise, I declare my belief that there are not consensus-breaking changes, for the following reason:

    only affects runtime options for pindexer, no changes to protocol or consensus logic

@conorsch conorsch requested a review from cronokirby February 20, 2025 23:54
return Ok(());
if exit_on_catchup {
tracing::info!("catchup completed, exiting as requested");
std::process::exit(0);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit of a hack to std::process::exit() here. Perhaps we should instead return a custom Result::CatchUp that triggers an exit in the main loop? Didn't seem worthwhile for a quick feature add, but open to suggestions.

Copy link
Contributor

@cronokirby cronokirby Feb 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wrote up a quick commit to avoid std::process::exit: #5103 ; I think I'd like to see that included in this PR (or something equivalent). Result<bool> seems fine enough to capture the possibilities there, and avoids the woes of direct exits, in case we want to run this code in a different context.

For running batch jobs managing indexing pipelines, it'd be convenient
to instruct pindexer to exit after it's finished processing the events
that's available to it. This situation arises frequently in batch
processing, where pindexer will be pointed at a source db that was
restored from a db. Having pindexer exit 0 on success, else non-zero on
error, will aid in building out test infrastructure.
@conorsch
Copy link
Contributor Author

Thanks @cronokirby, that change is just what I was looking for!

@conorsch conorsch merged commit 8e45795 into main Feb 21, 2025
9 checks passed
@conorsch conorsch deleted the pindexer-exit-on-catchup branch February 21, 2025 19:40
@conorsch conorsch mentioned this pull request Feb 25, 2025
7 tasks
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.

2 participants