Skip to content

feat(database): add sessions.gc reaper on jobs Engine - #3342

Open
adlerhurst wants to merge 3 commits into
cursor/jobs-slice-2-engine-ee5efrom
cursor/jobs-slice-3-sessions-gc-ee5e
Open

adlerhurst wants to merge 3 commits into
cursor/jobs-slice-2-engine-ee5efrom
cursor/jobs-slice-3-sessions-gc-ee5e

Conversation

@adlerhurst

@adlerhurst adlerhurst commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

TL;DR

5 of 6 (bases on #3341). First product handler: periodic sessions.gc drains expired sessions in batches, clears refresh grants, emits Path B session.expired, indexes expires_at.

Reviewer map

Core (review first) Mechanical / larger
apps/api/internal/service/sessions_gc.go (+ tests) OpenAPI / ogen session.expired
dialect DeleteSessions + stmttest events catalog / console EVENT_TYPES
expires_at index migrations (sqlite 056 / postgres 069 / spanner 074) server boot soft-fail SetPeriodic

Review follow-ups

  • Deletes DeleteRefreshGrantsBySessionID per reaped session (same tx as delete/emit).
  • Batch drain until deleted < limit (or ctx done).
  • Soft-fail schedule write at boot (warn, continue).
  • Size: still large (catalog/OpenAPI + reaper); recommend future split — not split silently.

Stack

… → #3341 ← this → #3343.

Open in Web Open in Cursor 

Copilot AI balanced review requested due to automatic review settings November 25, 2026 10:17
@adlerhurst
adlerhurst added this pull request to stack #3337 November 25, 2026 10:17
@vercel

vercel Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
cloud Ready Ready Preview Dec 3, 2026 5:38am UTC

Request Review

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

🦋 Changeset detected

Latest commit: f858f13

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 27 packages
Name Type
@zitadel/server Minor
@zitadel/cli Minor
@zitadel/testing Minor
@zitadel/server-darwin-arm64 Minor
@zitadel/server-darwin-x64 Minor
@zitadel/server-linux-arm64 Minor
@zitadel/server-linux-x64 Minor
@zitadel/server-win32-x64 Minor
@zitadel/api Minor
@zitadel/components Minor
@zitadel/config Minor
@zitadel/sdk-angular Minor
@zitadel/sdk-core Minor
@zitadel/sdk-next Minor
@zitadel/sdk-nuxt Minor
@zitadel/sdk-qwik Minor
@zitadel/sdk-qwik-router Minor
@zitadel/sdk-react Minor
@zitadel/sdk-solid Minor
@zitadel/sdk-solid-start Minor
@zitadel/sdk-svelte Minor
@zitadel/sdk-sveltekit Minor
@zitadel/sdk-tanstack-start Minor
@zitadel/sdk-vue Minor
@zitadel/cloud Patch
@zitadel/client-sdk-contract Patch
@zitadel/server-sdk-contract Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@cursor
cursor Bot force-pushed the cursor/jobs-slice-3-sessions-gc-ee5e branch from aa69756 to d3b8646 Compare November 25, 2026 10:18
@cursor
cursor Bot force-pushed the cursor/jobs-slice-3-sessions-gc-ee5e branch from ee69bc6 to 07f004e Compare November 25, 2026 13:38
@cursor
cursor Bot force-pushed the cursor/jobs-slice-3-sessions-gc-ee5e branch from 07f004e to b50df82 Compare November 26, 2026 04:59
@cursor
cursor Bot force-pushed the cursor/jobs-slice-3-sessions-gc-ee5e branch from 3b3aaf9 to 314e81a Compare November 26, 2026 05:06
@cursor
cursor Bot force-pushed the cursor/jobs-slice-3-sessions-gc-ee5e branch from 314e81a to d32791a Compare November 27, 2026 15:43
@cursor
cursor Bot force-pushed the cursor/jobs-slice-3-sessions-gc-ee5e branch from d32791a to efb761d Compare December 2, 2026 07:53

@fforootd fforootd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Four findings inline: refresh grants left behind, a missing index, the reaper's throughput, and a boot failure mode. Stack overview on #3335.


Generated by Claude Code

Comment thread apps/api/cmd/server/server.go Resolved
cursoragent and others added 3 commits December 3, 2026 05:34
Periodic sessions.gc with filter DeleteSessions, session.expired Path B event,
console EVENT_TYPES, and deleted-count logging.

Co-authored-by: s2s4gq4jby <s2s4gq4jby@privaterelay.appleid.com>
Clear refresh grants with each reaped session, index expires_at for the
filter/sort, drain batches until a short page, and soft-fail SetPeriodic
at boot so a sweeper schedule write cannot stop sign-in.

Co-authored-by: Silvan <adlerhurst@users.noreply.github.com>
Co-authored-by: Silvan <adlerhurst@users.noreply.github.com>

This branch was successfully deployed

1 active deployment
Preview — e0ed8e56 Deployed Dec 3, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Inbox

Development

Successfully merging this pull request may close these issues.

4 participants