Skip to content

TiDB should track, limit (and maybe spill) the temporary memory used by CursorFetch #43233

Closed
@YangKeao

Description

Enhancement

To avoid the bug in concurrent executing statements, TiDB fetches all the results and stored them in the memory. The following FETCH command only reads data from memory. It's especially hard for TiDB to support a real "CursorFetch", as the execution model of TiDB assumes that the access to session struct is exclusive, which is not true for "CursorFetch".

This behavior will cause OOM, when the result set is big or there are many cursor fetch statement. It's even more unexpected as the user may only need the first several rows. We could have some ways to relief this problem:

  1. Trace the memory through setting a suitable chunk allocator. However, the connection allocator will reset after command execution, so we need a new allocator across different statements.
  2. Spill result to disk if needed.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

affects-6.5This bug affects the 6.5.x(LTS) versions.affects-7.1This bug affects the 7.1.x(LTS) versions.severity/majorsig/sql-infraSIG: SQL Infratype/bugThe issue is confirmed as a bug.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions