adapter: bound read-then-write dependency validation#37654
Merged
Conversation
Problem: A DELETE or UPDATE whose selection reads from a deep chain of stacked views could crash the coordinator, and the process would take the whole environment down with it. Such a statement now runs normally. A read set with an extreme number of transitive dependencies gets a clean error instead of an unbounded walk. validate_read_then_write_dependencies recursed over the transitive uses() of a read-then-write's read set, one coordinator-thread frame per object. A statement whose selection reads from a deep chain of stacked views overflowed the coordinator stack. Solution: Replace the recursion with an iterative worklist. Dedup at enqueue time so each object is validated once and the worklist stays proportional to the number of distinct objects, not the number of dependency edges. Cap the traversal at read_then_write_max_dependencies (a dyncfg, default 100k) and reject larger graphs with a clean error instead of walking an unbounded graph. Tests: - a unit test validating a 100k-deep chain (the old recursive code overflowed the stack on it) - a unit test for the dependency bound - a small read-then-write limits smoke test.
aljoscha
approved these changes
Jul 15, 2026
| use crate::catalog::Catalog; | ||
| use crate::error::AdapterError; | ||
|
|
||
| /// Adds `id` to the worklist the first time it is seen, enforcing the |
Contributor
There was a problem hiding this comment.
nit: this is really an implementation detail of the validation method, so maybe could declare in there. But fine if you just want to move on and merge
Contributor
Author
There was a problem hiding this comment.
I'm just going to leave it and close the issue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem:
validate_read_then_write_dependencies recursed over the transitive uses() of a read-then-write's read set, one coordinator-thread frame per object. A statement whose selection reads from a deep chain of stacked views overflowed the coordinator stack
Solution:
Replace the recursion with an iterative worklist. Dedup at enqueue time so each object is validated once and the worklist stays proportional to the number of distinct objects, not the number of dependency edges. Cap the traversal at read_then_write_max_dependencies (a dyncfg, default 100k) and reject larger graphs with a clean error instead of walking an unbounded graph.
Tests:
Fixes SQL-426