Skip to content

Quota handling can lead to deadlock under load #122

@knolleary

Description

@knolleary

Current Behavior

If we receive multiple parallel updates for the some instance, but different scopes, a deadlock can occur.

  1. request received to update instance A, scope B.
  2. Within a transaction, we select the row with an update lock
  3. We determine the change in size of that context entry, but then need to check the total quota usage for the instance - so do a query for all scopes under instance A

If a second update comes in parallel for instance A, scope C, it will achieve a lock on that row. That then blocks the quota check off the first request. Both requests are now deadlocked.

Expected Behavior

Not to deadlock

Steps To Reproduce

Drive multiple requests to different context scopes in parallel.

Environment

  • FlowFuse version:
  • Node.js version:
  • npm version:
  • Platform/OS:
  • Browser:

Linked Customers

  • Customer name and/or link to HubSpot contact

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions