Skip to content

Conversation

@antiguru
Copy link
Member

@antiguru antiguru commented Feb 3, 2025

Design doc on how to improve cluster reliability by preventing creating expensive objects or running expensive queries.

Checklist

  • This PR has adequate test coverage / QA involvement has been duly considered. (trigger-ci for additional test/nightly runs)
  • This PR has an associated up-to-date design doc, is a design doc (template), or is sufficiently small to not require a design.
  • If this PR evolves an existing $T ⇔ Proto$T mapping (possibly in a backwards-incompatible way), then it is tagged with a T-proto label.
  • If this PR will require changes to cloud orchestration or tests, there is a companion cloud PR to account for those changes that is tagged with the release-blocker label (example).
  • If this PR includes major user-facing behavior changes, I have pinged the relevant PM to schedule a changelog post.

Signed-off-by: Moritz Hoffmann <[email protected]>
@antiguru antiguru changed the title Design: Limiting a query's heap size Design: Improving cluster reliability by preventing expensive queries Feb 4, 2025
Copy link
Contributor

@mgree mgree left a comment

Choose a reason for hiding this comment

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

Cool stuff!

We distinguish transient from permanent dataflows for the purposes of this design.
While we could apply the same mechanism to permanent dataflows, it is less clear how we would operate the system in the presence of a limit violation.
We cannot simply terminate a permanent dataflow, as it would affect all queries that depend on it, and our users expect dataflows to be always-on.
For this reason, we limit the scope of this design to transient dataflows, which are selects and subscribes.
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make sense to partition the system into a way of setting alerts based on resource usage (useful for transient and permanent dataflows) and actions taken on those alerts (more useful for transient dataflows, e.g., cancellation)?


A solution needs to limit the heap size usage of a query to a configurable value, and enforce it with high probability.

To measure the heap size of a query, we hook into the arrangement heap size infrastructure.
Copy link
Contributor

Choose a reason for hiding this comment

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

Will this count consolidations in Unions or the cost of finishing? (I don't know if our sort implementation is in-place or allocating, for example.)

Reducing the value yields the absolute heap size, which we can apply a threshold to detect limits exceeding their allocation.

We then forward the information to the controller, which can decide on how to handle dataflows with excessive resource utilization.
It can decide to terminate and fail a query, or let its execution continue.
Copy link
Contributor

Choose a reason for hiding this comment

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

Feels like we can surface this exact alert and have separately configurable actions?

We cannot simply terminate a permanent dataflow, as it would affect all queries that depend on it, and our users expect dataflows to be always-on.
For this reason, we limit the scope of this design to transient dataflows, which are selects and subscribes.

We also do not address the problem how the user can express the limit.
Copy link
Contributor

Choose a reason for hiding this comment

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

While RBAC doesn't talk about limits, a given user could have quotas (just like UNIX limits/quotas). Would allow them to say that dbt gets to use arbitrary memory for its ad hoc work, but someone on the data team has limits about how they interact with the production cluster/replicas.

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.

2 participants