Skip to content

Two deployments placed at the same time can reserve more than a node's capacity #315

Closed

Description

@samuelmbabhazi

What

Placement reads the load of the nodes and then stores the new allocations, in one transaction per deployment but without a lock (DeploymentPipeline.place, apps/api/src/modules/deployments/application/deployment-pipeline.ts). Two deployments of different applications that are placed at the same moment each read the load without the other's replicas, and both can land on the same node. Together they can reserve more than the node's capacity.

One application cannot race with itself: it has at most one active deployment.

Found while working on #301. The behaviour is older, but it matters more now that every replica reserves CPU and memory (1 CPU and 512 MiB by default).

Expected

Two placements in the same organization never read the same load. Options to compare:

  • a transaction-level advisory lock per organization around the read and the insert in place;
  • a constraint or a check at insert time that the node still has room.

Done when

  • An integration test with PostgreSQL places two applications concurrently on a node that has room for one, and exactly one of the two deployments fails with the cpu or memory reason.
  • SPEC section 6 says how concurrent placements are serialized.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions