Skip to content

feat(db): partition browser sessions by created_at#364

Merged
KurodaKayn merged 4 commits into
mainfrom
feat/browser-session-partitioning
Jun 23, 2026
Merged

feat(db): partition browser sessions by created_at#364
KurodaKayn merged 4 commits into
mainfrom
feat/browser-session-partitioning

Conversation

@KurodaKayn

Copy link
Copy Markdown
Owner

Feature Description

  • Add monthly PostgreSQL partitioning for remote_browser_sessions using created_at, matching the existing archive-managed hot-table strategy.
  • Preserve active-session safety for PostgreSQL partitioned tables by replacing the partition-hostile global unique fallback with a scoped advisory transaction lock when Redis coordination is unavailable.
  • Update Phase 4 database optimization progress to mark browser-session partitioning complete with verification entry points.

Implementation Approach

  • Register remote_browser_sessions in the monthly partition DDL with a partition-compatible (id, created_at) primary key and rolling/default partition support.
  • Update the model, cleanup lookup, and no-Redis creation path so browser-session lifecycle code remains compatible with the composite key and PostgreSQL partition constraints.
  • Extend DB schema coverage so remote_browser_sessions is checked alongside the other partitioned event/activity tables.

Testing

  • Passed: go test ./internal/db ./internal/services/browser_session ./internal/services/archive
  • Passed: bash script/ci/backend.sh
  • Passed: cd backend && golangci-lint run ./...

Remote browser session history needs the same rolling hot-table boundary as the other archive-managed tables.

Add remote_browser_sessions to monthly PostgreSQL partition setup and make the model use a partition-compatible key.

Use a scoped database guard for no-Redis active-session creation so PostgreSQL partition constraints remain valid.
Browser session history now shares the monthly partition contract with event and activity tables.

Extend the partition-compatible primary key coverage to include remote_browser_sessions.

The schema test now catches regressions that would break PostgreSQL partition constraints.
Phase 4 now includes browser session history in the monthly partitioned hot-table set.

Refresh the progress table, capability matrix, and checklist with the new verification entry points.

This keeps the scaling plan aligned with the implemented schema and session-guard change.
The PostgreSQL fallback guard needs a deterministic lock key without tripping gosec overflow checks.

Use a fixed advisory-lock namespace with PostgreSQL hashtext for the user/platform scope.

This preserves the partition-compatible active-session guard while keeping backend lint clean.
@KurodaKayn KurodaKayn merged commit 32d7181 into main Jun 23, 2026
14 checks passed
@KurodaKayn KurodaKayn deleted the feat/browser-session-partitioning branch June 23, 2026 09:24
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.

1 participant