Skip to content

Commit

Permalink
Only execute access rights change queries on a single node
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
aris-aiven committed Nov 7, 2024
1 parent 1ef305c commit ded0c15
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions astacus/coordinator/plugins/clickhouse/steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,14 +190,14 @@ async def revoke_write_on_table(self, table: Table, user_name: bytes) -> None:
revoke_statement = (
f"REVOKE INSERT, ALTER UPDATE, ALTER DELETE ON {table.escaped_sql_identifier} FROM {escaped_user_name}"
)
await asyncio.gather(*(client.execute(revoke_statement.encode()) for client in self.clients))
await self.clients[0].execute(revoke_statement.encode())

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())

async def run_step(self, cluster: Cluster, context: StepsContext) -> None:
_, tables = context.get_result(RetrieveDatabasesAndTablesStep)
Expand Down

0 comments on commit ded0c15

Please sign in to comment.