Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Khepri: Use read-only transactions to query for user/topic permissions #11398

Merged

Conversation

the-mikedavis
Copy link
Member

Read-only transactions in Khepri are done with queries rather than commands. We can set these queries to favor low-latency - querying the local node rather than trying to contact the leader - to make them faster and available when Khepri is in a minority. This fixes some 'bad generator' errors when exporting definitions from a cluster member in a minority.

This is related to #10915 but #10915 mostly covers handling timeouts from commands rather than queries, and these commits port out cleanly.

Read-write transactions behave like commands (for example 'put' or
'delete') but read-only transactions behave like queries (for example
'get' or 'exists'). When a transaction is passed as read-only we can
re-use the same default options we use for most Khepri queries and
favor low-latency queries. This reads the values from the local node
rather than the leader (or a consistent query), making the query faster
and preventing timeouts when attempting the query when the cluster is
in minority.

The child commit will update some read-only transaction callsites that
take advantage of this low-latency favor.
…sions

The parent commit favors low-latency queries for read-only transactions,
so marking these read-only transactions as explicitly read-only will
cause them to be run against the local node. This ensures that functions
like `rabbit_auth_backend_internal:list_permissions/0` do not return
`{error, timeout}` when the cluster is in minority, fixing 'bad
generator' errors during definitions export (via
`rabbit_definitions:all_definitions/0`).
This is a mix of a few changes:

* Suppress the compiler warning from the export_all attribute.
* Lower Khepri's command handling timeout value. By default this is
  set to 30s in rabbit which makes each of the cases in
  `client_operations` take an excessively long time. Before this change
  the suite took around 10 minutes to complete. Now it takes between two
  and three minutes.
* Swap the order of client and broker teardown steps in end_per_group
  hook. The client teardown steps will always fail if run after the
  broker teardown steps because they rely on a value in `Config` that
  is deleted by broker teardown.
@the-mikedavis the-mikedavis merged commit 5e4a432 into main Jun 7, 2024
325 checks passed
@the-mikedavis the-mikedavis deleted the md/khepri/read-only-permissions-transaction-queries branch June 7, 2024 13:20
the-mikedavis added a commit that referenced this pull request Jun 7, 2024
Khepri: Use read-only transactions to query for user/topic permissions (backport #11398)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants