Skip to content

server,sql: enable running SQL statements before the node start draining #72045

@Azhng

Description

@Azhng

Currently, CockroachDB has subsystems (e.g. SQL Stats) that holds data in-memory and flushes them into system tables periodically.
When a node shuts down, these subsystems should be notified and start to flush their in-memory data into system tables, otherwise the in-memory data will just simply be deleted and cannot be recovered.
This becomes an issue in Serverless clusters, where the tenant node is shutdown after a period of inactivity, (usually less than the flush interval).

CRDB's current shutdown process looks like following:

shutdown requested -> block incoming sql traffic -> start draining -> stop stopper

We would like to introduce additional stage in the shutdown process:

shutdown requested -> block incoming sql traffic -> run final sql -> start draining -> stop stopper

This allows subsystems like SQL Stats to have a chance to flush its in-memory data during the graceful shutdown.

cc: @cockroachdb/server
cc: @cockroachdb/sql-observability

Epic CRDB-11087

Metadata

Metadata

Assignees

Labels

P-1Issues/test failures with a fix SLA of 1 monthT-server-and-securityDB Server & Security

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions