clickhouse-java icon indicating copy to clipboard operation
clickhouse-java copied to clipboard

[jdbc-v2] JDBC fails to execute query if user is `readonly`

Open chernser opened this issue 6 months ago • 2 comments

Description

The issue was reproduced while executing the query in DBeaver with a read-only user.

Error Log or Exception StackTrace

2025-06-10 11:55:23.220 - SQL Error [22000]: Code: 164. DB::Exception: <Unreadable error message> (transport error: 500)
org.jkiss.dbeaver.model.sql.DBSQLException: SQL Error [22000]: Code: 164. DB::Exception: <Unreadable error message> (transport error: 500)
	at org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCStatementImpl.executeStatement(JDBCStatementImpl.java:130)
	at org.jkiss.dbeaver.ui.editors.sql.execute.SQLQueryJob.executeStatement(SQLQueryJob.java:657)
	at org.jkiss.dbeaver.ui.editors.sql.execute.SQLQueryJob.lambda$2(SQLQueryJob.java:550)
	at org.jkiss.dbeaver.model.exec.DBExecUtils.tryExecuteRecover(DBExecUtils.java:189)
	at org.jkiss.dbeaver.ui.editors.sql.execute.SQLQueryJob.executeSingleQuery(SQLQueryJob.java:569)
	at org.jkiss.dbeaver.ui.editors.sql.execute.SQLQueryJob.extractData(SQLQueryJob.java:1043)
	at org.jkiss.dbeaver.ui.editors.sql.SQLEditor$QueryResultsContainer.readData(SQLEditor.java:4363)
	at org.jkiss.dbeaver.ui.controls.resultset.ResultSetJobDataRead.lambda$0(ResultSetJobDataRead.java:128)
	at org.jkiss.dbeaver.model.exec.DBExecUtils.tryExecuteRecover(DBExecUtils.java:189)
	at org.jkiss.dbeaver.ui.controls.resultset.ResultSetJobDataRead.run(ResultSetJobDataRead.java:126)
	at org.jkiss.dbeaver.ui.controls.resultset.ResultSetViewer$ResultSetDataPumpJob.run(ResultSetViewer.java:5145)
	at org.jkiss.dbeaver.model.runtime.AbstractJob.run(AbstractJob.java:119)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
Caused by: java.sql.SQLException: Code: 164. DB::Exception: <Unreadable error message> (transport error: 500)
	at com.clickhouse.jdbc.internal.ExceptionUtils.toSqlState(ExceptionUtils.java:67)
	at com.clickhouse.jdbc.internal.ExceptionUtils.toSqlState(ExceptionUtils.java:42)
	at com.clickhouse.jdbc.StatementImpl.executeQueryImpl(StatementImpl.java:149)
	at com.clickhouse.jdbc.StatementImpl.execute(StatementImpl.java:309)
	at org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCStatementImpl.execute(JDBCStatementImpl.java:344)
	at org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCStatementImpl.executeStatement(JDBCStatementImpl.java:128)
	... 12 more
Caused by: com.clickhouse.client.api.ServerException: Code: 164. DB::Exception: <Unreadable error message> (transport error: 500)
	at com.clickhouse.client.api.internal.HttpAPIClientHelper.readError(HttpAPIClientHelper.java:371)
	at com.clickhouse.client.api.internal.HttpAPIClientHelper.executeRequest(HttpAPIClientHelper.java:426)
	at com.clickhouse.client.api.Client.lambda$query$10(Client.java:1723)
	at com.clickhouse.client.api.Client.runAsyncOperation(Client.java:2156)
	at com.clickhouse.client.api.Client.query(Client.java:1766)
	at com.clickhouse.client.api.Client.query(Client.java:1667)
	at com.clickhouse.jdbc.StatementImpl.executeQueryImpl(StatementImpl.java:135)
	... 15 more

Environment

  • Client version: 0.8.6
  • Language version: 17

chernser avatar Jun 10 '25 19:06 chernser

We also need to add tests for read-only user. see examples: https://github.com/ClickHouse/clickhouse-js/blob/main/packages/client-common/tests/integration/read_only_user.test.ts

I'm not sure why you observe DB::Exception: <Unreadable error message> (transport error: 500) when nodejs client tests assert against an error message https://github.com/ClickHouse/clickhouse-js/blob/main/packages/client-common/tests/integration/read_only_user.test.ts#L66

mshustov avatar Jun 11 '25 09:06 mshustov

If the driver doesn't work with the default settings for the read only user, for example, because the driver changes settings, we need to review the list of changed settings. Using readonly=1 user is a typical pattern in BI, when a UI tool provides only read access to a data store.

mshustov avatar Jun 12 '25 12:06 mshustov

Seems relate to https://github.com/ClickHouse/clickhouse-java/issues/2510

chernser avatar Sep 11 '25 20:09 chernser

Is there any progress on this? I stumbled upon this error running queries from readonly user with DBeaver, had to switch to DataGrip – it works.

TechGeorgii avatar Nov 13 '25 03:11 TechGeorgii

Good day, @TechGeorgii !

Would you put more details - version of JDBC and DBeaver, how to reproduce? We currently thinking that the issue is fixed. It was caused that we were using server settings and error tells that settings cannot be changed by readonly user.

Thanks!

chernser avatar Nov 13 '25 15:11 chernser

Good day, @TechGeorgii !

Would you put more details - version of JDBC and DBeaver, how to reproduce? We currently thinking that the issue is fixed. It was caused that we were using server settings and error tells that settings cannot be changed by readonly user.

Thanks!

After I updated JDBC driver to 0.9.4 the issued went away, so I guess old driver version caused this problem.

TechGeorgii avatar Nov 17 '25 11:11 TechGeorgii

Thank you @TechGeorgii !

chernser avatar Nov 17 '25 14:11 chernser