Skip to content

[LIVY-1073] Add SessionManager refresh and /recovery operator endpoint - #546

Open
soumyadeeplogin wants to merge 2 commits into
apache:masterfrom
soumyadeeplogin:livy-item3-sessionmanager-refresh
Open

[LIVY-1073] Add SessionManager refresh and /recovery operator endpoint#546
soumyadeeplogin wants to merge 2 commits into
apache:masterfrom
soumyadeeplogin:livy-item3-sessionmanager-refresh

Conversation

@soumyadeeplogin

@soumyadeeplogin soumyadeeplogin commented Aug 20, 2026

Copy link
Copy Markdown

What changes were proposed in this pull request?

Adds a SessionManager refresh capability and a /recovery operator endpoint on LivyServer, allowing an operator to trigger a manual re-sync of in-memory session state against the recovery/session-state store without restarting the Livy server process.

The /recovery/* endpoints are implemented as a standalone RecoveryServlet, restricted to livy.superusers. If livy.server.recovery.mode is off (no state store configured), the endpoints return 409 rather than a silently-empty result. The three endpoints (/recovery/sessions/refresh, /recovery/batches/refresh, /recovery/refresh) are documented in docs/rest-api.md.

How was this patch tested?

Unit tests added in SessionManagerSpec covering the refresh path, and RecoveryServletSpec covering the servlet's authorization (403 vs 200) and recovery-mode-off (409) behavior.

Was this patch authored or co-authored using generative AI tooling?

Yes. Generated-by: Claude Code (Sonnet 5, Anthropic), used to scan/plan the extraction of local patches for upstreaming and to draft/iterate on the code and tests in this PR under human review. Please refer to the ASF Generative Tooling Guidance for details.

Note on JIRA

Filed as LIVY-1073.

@soumyadeeplogin soumyadeeplogin changed the title Add SessionManager refresh and /recovery operator endpoint [LIVY-1073] Add SessionManager refresh and /recovery operator endpoint Aug 21, 2026
@soumyadeeplogin

Copy link
Copy Markdown
Author

Filed https://issues.apache.org/jira/browse/LIVY-1073 for this change.

@soumyadeeplogin

Copy link
Copy Markdown
Author

@gyogal @roczei could one of you approve the CI workflow run for this PR (first-time contributor gate) and take a look when you have a chance? Filed as LIVY-1073.

(cherry picked from commit d30c643)

Co-authored-by: Soumyadeep Roy <soumyadeep.roy@salesforce.com>
@soumyadeeplogin
soumyadeeplogin force-pushed the livy-item3-sessionmanager-refresh branch from 5619f1b to fe7bdc7 Compare August 25, 2026 16:07
@roczei

roczei commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

@soumyadeeplogin

Thanks for the PR! Could you please add the required AI tooling disclosure to the PR description?

Was this patch authored or co-authored using generative AI tooling?

(If yes, include 'Generated-by: ' followed by the tool name and version. If no, write 'No'.)
Please refer to the ASF Generative Tooling Guidance for details.

@soumyadeeplogin

Copy link
Copy Markdown
Author

Thanks, @roczei! Added the AI tooling disclosure section to the PR description.

@roczei

roczei commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Nice work on this! I reviewed the core logic and tests. I've left a few small thoughts below to help refine things:

Please update docs/rest-api.md with the three new endpoints:

/recovery/sessions/refresh
/recovery/batches/refresh
/recovery/refresh

Include the auth requirement as well

When livy.server.recovery.mode=off consider returning a clear error, so operators don't think they synced state when recovery is disabled.

Core logic is well tested, but a small integration test for 403 (non-superuser) vs 200 (superuser) on /recovery/* would increase confidence.

Extracts the previously-inline anonymous recovery servlet in
LivyServer into a standalone RecoveryServlet class, following the
existing BatchSessionServlet/InteractiveSessionServlet convention.
This makes it unit-testable and adds RecoveryServletSpec, covering
the 403 (non-superuser) vs 200 (superuser) authorization path that
had no test coverage.

Also has the servlet return 409 instead of a silently-empty
added=0/failed=0 result when livy.server.recovery.mode=off, since in
that case StateStore resolves to a no-op BlackholeStateStore and the
previous behavior was misleading.

Documents the three /recovery/* endpoints in docs/rest-api.md, which
had none.

Co-authored-by: Soumyadeep Roy <soumyadeep.roy@salesforce.com>
@soumyadeeplogin

Copy link
Copy Markdown
Author

Thanks for the detailed review, @roczei! Pushed a follow-up commit addressing all three points:

  1. Docs: added POST /recovery/sessions/refresh, /recovery/batches/refresh, and /recovery/refresh sections to docs/rest-api.md.
  2. Silent no-op when recovery is off: the servlet now returns 409 if livy.server.recovery.mode=off, instead of a misleading added=0, failed=0 result (the state store resolves to a no-op BlackholeStateStore in that mode, so there's genuinely nothing to refresh from).
  3. Integration test: added RecoveryServletSpec, covering 403 (non-superuser) vs 200 (superuser), and the new 409 (recovery disabled) case.

As part of this I also extracted the previously-inline anonymous servlet in LivyServer into a standalone RecoveryServlet class (same pattern as BatchSessionServlet/InteractiveSessionServlet), which is what made it testable in isolation.

@roczei roczei left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

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.

4 participants