-
Notifications
You must be signed in to change notification settings - Fork 4.1k
server,sql: enable running SQL statements before the node start draining #72045
Description
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