Skip to content

Conversation

@seedspirit
Copy link
Contributor

resolves #8613 (BA-4282)

Checklist: (if applicable)

  • Milestone metadata specifying the target backport version
  • Mention to the original issue
  • Installer updates including:
    • Fixtures for db schema changes
    • New mandatory config options
  • Update of end-to-end CLI integration tests in ai.backend.test
  • API server-client counterparts (e.g., manager API -> client SDK)
  • Test case(s) to:
    • Demonstrate the difference of before/after
    • Demonstrate the flow of abstract/conceptual models with a concrete implementation
  • Documentation
    • Contents in the docs directory
    • docstrings in public interfaces and type annotations

@seedspirit seedspirit marked this pull request as ready for review February 5, 2026 09:55
Copilot AI review requested due to automatic review settings February 5, 2026 09:55
@github-actions github-actions bot added size:L 100~500 LoC comp:manager Related to Manager component labels Feb 5, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request fixes a foreign key constraint violation (IntegrityError) that occurs when purging a scaling group that has sessions with associated kernels. The issue was that the cascade deletion sequence was attempting to delete sessions before deleting their associated kernels, which violates the fk_kernels_session_id_sessions foreign key constraint (which uses the default RESTRICT behavior).

Changes:

  • Added kernel deletion step in the cascade deletion sequence for purge_scaling_group
  • Added comprehensive test to verify purging scaling groups with the full FK hierarchy (scaling group → session → kernel + endpoint → route)

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/ai/backend/manager/repositories/scaling_group/db_source/db_source.py Added deletion of KernelRow records between endpoint and session deletion to prevent FK constraint violations
tests/unit/manager/repositories/scaling_group/test_scaling_group_repository.py Added test fixtures and test case to verify purging works correctly with the full entity hierarchy including kernels

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp:manager Related to Manager component size:L 100~500 LoC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

purge_scaling_group fails with IntegrityError when scaling group has sessions with kernels

1 participant