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

Only execute access rights change queries on a single node #257

Merged
merged 1 commit into from
Nov 7, 2024

Conversation

aris-aiven
Copy link
Contributor

@aris-aiven aris-aiven commented Nov 7, 2024

For the read-only step, we're filtering by replicated users, whose grant information is stored in ZooKeeper.

This means that executing the query on multiple nodes is counterproductive. Instead of achieving faster information propagation, we're getting transaction errors from ZooKeeper. Any one of these can in turn fail the step.

Here's one such example:

Query failed: b'REVOKE INSERT, ALTER UPDATE, ALTER DELETE ON `default`.`keeper_map` FROM `alice`' on <host>:
status_code=500,
exception_code=999,
response=b'Code: 999. Coordination::Exception: Transaction failed: Op #0, path: /clickhouse/access/uuid/914a9caa-682f-5dce-4ed7-b0f16f564798. (KEEPER_EXCEPTION) (version 24.3.5.1)\n'

For the read-only step, we're filtering by replicated users, whose grant
information is stored in ZooKeeper.

This means that executing the query on multiple nodes is counterproductive.
Instead of achieving faster information propagation, we're getting transaction
errors from ZooKeeper. Any one of these can in turn fail the step.
@aris-aiven aris-aiven marked this pull request as ready for review November 7, 2024 18:16
@aris-aiven aris-aiven requested a review from a team November 7, 2024 18:17

async def grant_write_on_table(self, table: Table, user_name: bytes) -> None:
escaped_user_name = escape_sql_identifier(user_name)
grant_statement = (
f"GRANT INSERT, ALTER UPDATE, ALTER DELETE ON {table.escaped_sql_identifier} TO {escaped_user_name}"
)
await asyncio.gather(*(client.execute(grant_statement.encode()) for client in self.clients))
await self.clients[0].execute(grant_statement.encode())
Copy link
Contributor

@Khatskevich Khatskevich Nov 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change looks very controversial to me

  1. Yes, in principle it is not necessary to change privileges multiple times, but we do not control how fast it will reach other servers, do we? Theoretically it might be delayed for unknown time which spoils all guarantees.
  2. I really want to continue this discussion. So far I think it is better to just delete this step completely...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean the cluster is in a single region, and zookeeper is strictly serializable, so the upper bound on the latency for the change to go through in ZK is <5ms.

Actually I don't think the deduplication log is relevant for the restore. The log is saved in ZooKeeper, and the restore process doesn't start from a ZK snapshot but from an empty state. So the block-level information is lost.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will test if in practice the argument I just provided stands, but the main branch is broken at the moment and I'd rather we fix it. If the step is irrelevant, then of course we'll drop it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Zookeeper only supports write operation serialization, but reads could propagate slowly.
They first go to the local zookeeper, and then to the clickhouse to be processed, as I understand.
But looks like it does not efficiently make things worse, you are right.

  1. the solution is not easy, so, lets start with this one

@aris-aiven aris-aiven requested review from a team and Khatskevich November 7, 2024 20:08
@Khatskevich Khatskevich merged commit 28484bc into main Nov 7, 2024
2 checks passed
@Khatskevich Khatskevich deleted the aris-fix-zk-transaction-error branch November 7, 2024 22:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants