Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql: ANALYZE causes flow:memory budget exceeded error #68670

Closed
mgartner opened this issue Aug 10, 2021 · 0 comments · Fixed by #69483
Closed

sql: ANALYZE causes flow:memory budget exceeded error #68670

mgartner opened this issue Aug 10, 2021 · 0 comments · Fixed by #69483
Assignees
Labels
A-sql-table-stats Table statistics (and their automatic refresh). C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. T-sql-queries SQL Queries Team
Projects

Comments

@mgartner
Copy link
Collaborator

mgartner commented Aug 10, 2021

Running ANALYZE on large tables can sometimes cause errors like: flow: memory budget exceeded: 10240 bytes requested, 0 currently allocated, 0 bytes in budget.

Full stack trace:

I210723 17:26:35.786147 192731269 jobs/registry.go:1106 ⋮ [n8] CREATE STATS job 678266620850536456: stepping through state reverting with error: ‹flow›: memory budget exceeded: 10240 bytes requested, 0 currently allocated, 0 bytes in budget
(1) attached stack trace
  -- stack trace:
  | github.com/cockroachdb/cockroach/pkg/util/mon.(*BytesMonitor).increaseBudget
  | 	/go/src/github.com/cockroachdb/cockroach/pkg/util/mon/bytes_usage.go:682
  | [...repeated from below...]
Wraps: (2) ‹flow›
Wraps: (3) candidate pg code: 53200
Wraps: (4) attached stack trace
  -- stack trace:
  | github.com/cockroachdb/cockroach/pkg/util/mon.memoryResource.NewBudgetExceededError
  | 	/go/src/github.com/cockroachdb/cockroach/pkg/util/mon/resource.go:37
  | github.com/cockroachdb/cockroach/pkg/util/mon.(*BytesMonitor).increaseBudget
  | 	/go/src/github.com/cockroachdb/cockroach/pkg/util/mon/bytes_usage.go:682
  | github.com/cockroachdb/cockroach/pkg/util/mon.(*BytesMonitor).reserveBytes
  | 	/go/src/github.com/cockroachdb/cockroach/pkg/util/mon/bytes_usage.go:615
  | github.com/cockroachdb/cockroach/pkg/util/mon.(*BoundAccount).Grow
  | 	/go/src/github.com/cockroachdb/cockroach/pkg/util/mon/bytes_usage.go:570
  | github.com/cockroachdb/cockroach/pkg/util/mon.(*BytesMonitor).increaseBudget
  | 	/go/src/github.com/cockroachdb/cockroach/pkg/util/mon/bytes_usage.go:690
  | github.com/cockroachdb/cockroach/pkg/util/mon.(*BytesMonitor).reserveBytes
  | 	/go/src/github.com/cockroachdb/cockroach/pkg/util/mon/bytes_usage.go:615
  | github.com/cockroachdb/cockroach/pkg/util/mon.(*BoundAccount).Grow
  | 	/go/src/github.com/cockroachdb/cockroach/pkg/util/mon/bytes_usage.go:570
  | github.com/cockroachdb/cockroach/pkg/util/mon.(*BytesMonitor).increaseBudget
  | 	/go/src/github.com/cockroachdb/cockroach/pkg/util/mon/bytes_usage.go:690
  | github.com/cockroachdb/cockroach/pkg/util/mon.(*BytesMonitor).reserveBytes
  | 	/go/src/github.com/cockroachdb/cockroach/pkg/util/mon/bytes_usage.go:615
  | github.com/cockroachdb/cockroach/pkg/util/mon.(*BoundAccount).Grow
  | 	/go/src/github.com/cockroachdb/cockroach/pkg/util/mon/bytes_usage.go:570
  | github.com/cockroachdb/cockroach/pkg/util/mon.(*BoundAccount).Resize
  | 	/go/src/github.com/cockroachdb/cockroach/pkg/util/mon/bytes_usage.go:550
  | github.com/cockroachdb/cockroach/pkg/util/mon.(*BoundAccount).ResizeTo
  | 	/go/src/github.com/cockroachdb/cockroach/pkg/util/mon/bytes_usage.go:563
  | github.com/cockroachdb/cockroach/pkg/sql/row.(*txnKVFetcher).fetch
  | 	/go/src/github.com/cockroachdb/cockroach/pkg/sql/row/kv_batch_fetcher.go:345
  | github.com/cockroachdb/cockroach/pkg/sql/row.(*txnKVFetcher).nextBatch
  | 	/go/src/github.com/cockroachdb/cockroach/pkg/sql/row/kv_batch_fetcher.go:454
  | github.com/cockroachdb/cockroach/pkg/sql/row.(*KVFetcher).NextKV
  | 	/go/src/github.com/cockroachdb/cockroach/pkg/sql/row/kv_fetcher.go:118
  | github.com/cockroachdb/cockroach/pkg/sql/row.(*Fetcher).NextKey
  | 	/go/src/github.com/cockroachdb/cockroach/pkg/sql/row/fetcher.go:671
  | github.com/cockroachdb/cockroach/pkg/sql/row.(*Fetcher).StartScanFrom
  | 	/go/src/github.com/cockroachdb/cockroach/pkg/sql/row/fetcher.go:661
  | github.com/cockroachdb/cockroach/pkg/sql/row.(*Fetcher).StartScan
  | 	/go/src/github.com/cockroachdb/cockroach/pkg/sql/row/fetcher.go:553
  | github.com/cockroachdb/cockroach/pkg/sql/rowexec.(*tableReader).Start
  | 	/go/src/github.com/cockroachdb/cockroach/pkg/sql/rowexec/tablereader.go:191
  | github.com/cockroachdb/cockroach/pkg/sql/rowexec.(*samplerProcessor).Run
  | 	/go/src/github.com/cockroachdb/cockroach/pkg/sql/rowexec/sampler.go:221
  | github.com/cockroachdb/cockroach/pkg/sql/flowinfra.(*FlowBase).startInternal.func1
  | 	/go/src/github.com/cockroachdb/cockroach/pkg/sql/flowinfra/flow.go:340
  | runtime.goexit
  | 	/usr/local/go/src/runtime/asm_amd64.s:1357
Wraps: (5) memory budget exceeded: 10240 bytes requested, 0 currently allocated, 0 bytes in budget

Related to #68590

Work-around

Creating statistics with throttling and at a time in the past with AS OF SYSTEM TIME should not produce the error:

CREATE STATISTICS vehicle_stats_1 FROM vehicles WITH OPTIONS THROTTLING 0.9 AS OF SYSTEM TIME '-30s';

gz#9224

@mgartner mgartner added C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. A-sql-table-stats Table statistics (and their automatic refresh). labels Aug 10, 2021
@mgartner mgartner added this to Triage in SQL Queries via automation Aug 10, 2021
@blathers-crl blathers-crl bot added the T-sql-queries SQL Queries Team label Aug 10, 2021
@yuzefovich yuzefovich moved this from Triage to 21.2 August Milestone in SQL Queries Aug 10, 2021
@yuzefovich yuzefovich assigned yuzefovich and unassigned DrewKimball Aug 19, 2021
@craig craig bot closed this as completed in 45ffbd0 Aug 28, 2021
SQL Queries automation moved this from 21.2 August Milestone to Done Aug 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-sql-table-stats Table statistics (and their automatic refresh). C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. T-sql-queries SQL Queries Team
Projects
Archived in project
3 participants