Open
Description
In cockroachlabs/support#674 we see gc-jobs
queries contending from multiple nodes, and thrashing. It'd be much better if a single node was in charge of running this jobs deletion query, not all the nodes. #57041 makes the situation better by hopefully reducing the thrashing when contention does happen, but still.
I've discussed with @ajwerner that this would be a good time to introduce a general leases table for the cluster, and use it to assign responsibility for such background processes. The leases in the table could be implemented on top of the recent instances/sessions infrastructure (see crdb_internal.sql_liveness_is_alive(session_id)
).
Jira issue: CRDB-2877