See individual commits for refactors that make the enhancement easier.
Since we use a query that scans the whole role_members table to
populate the membership cache, it is wasteful to launch multiple
singleflight requests for different users. This patch changes
the cache refresh logic of the singleflight so that it always populates
the entire cache, which means there will only ever be one in-flight
query per each node.
fixes https://github.com/cockroachdb/cockroach/issues/135931
Release note (performance improvement): Improved the internal caching
logic for role membership information. This reduces the latency impact
of commands such as DROP ROLE, CREATE ROLE, and GRANT role TO user,
which cause the role membership cache to be invalidated.
See individual commits for refactors that make the enhancement easier.
Since we use a query that scans the whole role_members table to populate the membership cache, it is wasteful to launch multiple singleflight requests for different users. This patch changes the cache refresh logic of the singleflight so that it always populates the entire cache, which means there will only ever be one in-flight query per each node.
fixes https://github.com/cockroachdb/cockroach/issues/135931 Release note (performance improvement): Improved the internal caching logic for role membership information. This reduces the latency impact of commands such as
DROP ROLE
,CREATE ROLE
, andGRANT role TO user
, which cause the role membership cache to be invalidated.