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

why can not connet with pgAdmin4? #13058

Closed
penghuazhou opened this issue Oct 15, 2021 · 23 comments
Closed

why can not connet with pgAdmin4? #13058

penghuazhou opened this issue Oct 15, 2021 · 23 comments

Comments

@penghuazhou
Copy link
Contributor

penghuazhou commented Oct 15, 2021

version: shardingsphere-pxoxy 4.1.1

thow errors when use DBeaver or pgAdmin to connect, but it well to use pgsql.

企业微信截图_1aab503d-63f4-4c34-a576-2df2047ac63e

企业微信截图_a316f01b-2bb0-4148-b60d-ef72979846cb

[WARN ] 12:43:32.243 [ShardingSphere-5] c.zaxxer.hikari.pool.ProxyConnection - HikariPool-2 - Connection org.postgresql.jdbc.PgConnection@4bffc
0e marked as broken because of SQLSTATE(08006), ErrorCode(0)
org.postgresql.util.PSQLException: The server's client_encoding parameter was changed to UNICODE. The JDBC driver requires client_encoding to b
e UTF8 for correct operation.
at org.postgresql.core.v3.QueryExecutorImpl.receiveParameterStatus(QueryExecutorImpl.java:2604)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2219)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:308)
at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:441)
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:365)
at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:307)
at org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:293)
at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:270)
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:266)
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:1168)
at com.zaxxer.hikari.pool.ProxyStatement.execute(ProxyStatement.java:103)
at com.zaxxer.hikari.pool.HikariProxyStatement.execute(HikariProxyStatement.java)
at org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.wrapper.StatementExecutorWrapper.executeSQL(StatementExecutorWrap
per.java:130)
at org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.execute.callback.ProxySQLExecuteCallback.executeSQL(ProxySQLExecu
teCallback.java:82)
at org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.execute.callback.ProxySQLExecuteCallback.executeSQL(ProxySQLExecu
teCallback.java:77)
at org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.execute.callback.ProxySQLExecuteCallback.executeSQL(ProxySQLExecu
teCallback.java:46)
at org.apache.shardingsphere.sharding.execute.sql.execute.SQLExecuteCallback.execute0(SQLExecuteCallback.java:82)
at org.apache.shardingsphere.sharding.execute.sql.execute.SQLExecuteCallback.execute(SQLExecuteCallback.java:58)
at org.apache.shardingsphere.underlying.executor.engine.ExecutorEngine.lambda$asyncExecute$0(ExecutorEngine.java:110)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)

@RaigorJiang
Copy link
Contributor

Hi @penghuazhou
Can you try the latest version 5.0.0-beta? It may be improved.

@sandynz
Copy link
Contributor

sandynz commented Oct 16, 2021

Hi @penghuazhou , since psql works, according to PSQLException: The server's client_encoding parameter was changed to UNICODE. The JDBC driver requires client_encoding to be UTF8 for correct operation, could you check client_encoding in Dbeaver and set to UTF8 as exception recommended?

@RaigorJiang
Copy link
Contributor

@penghuazhou
Please try to set JDBC parameter allowEncodingChanges=true for your connection.

@tristaZero
Copy link
Contributor

@taojintianxia Hi It looks like night building can help users test conveniently.

@penghuazhou
Copy link
Contributor Author

@penghuazhou Please try to set JDBC parameter allowEncodingChanges=true for your connection.

@RaigorJiang
it return error 'did' now,and no error message in shardingsphere log.
企业微信截图_62301c46-5c8e-4f7d-bad0-7b7f7770d523

@RaigorJiang
Copy link
Contributor

Hi @penghuazhou Can you try the latest version 5.0.0-beta? It may be improved.

Have you try the latest version?

@penghuazhou
Copy link
Contributor Author

@tristaZero @RaigorJiang
why I cannot connect to shardingsphere with go language framework gorm(https://gorm.io/zh_CN/docs/index.html)?I can connetc with go language framework go-pg, also I can connect it with pgsql. Do shardingSphere-proxy not suggest user go language?

version: shardingsphere-proxy 4.1.1, postpresql(database):14.0

[INFO ] 09:36:13.648 [nioEventLoopGroup-2-1] i.n.handler.logging.LoggingHandler - [id: 0xac2c2499, L:/0:0:0:0:0:0:0:0:3307] READ COMPLETE
line 1:0 no viable alternative at input ';'
line 1:0 mismatched input ';' expecting {SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, DROP, TRUNCATE, GRANT, REVOKE, SET, BEGIN, COMMIT, ROLLBACK, SAVEPOINT, CALL, START, RESET, SHOW}
[ERROR] 09:36:13.802 [pool-6-thread-1] o.a.s.s.f.c.CommandExecutorTask - Exception occur:
org.apache.shardingsphere.sql.parser.exception.SQLParsingException: Unsupported SQL of ;
at org.apache.shardingsphere.sql.parser.core.parser.SQLParserExecutor.execute(SQLParserExecutor.java:49)
at org.apache.shardingsphere.sql.parser.SQLParserEngine.parse0(SQLParserEngine.java:79)
at org.apache.shardingsphere.sql.parser.SQLParserEngine.parse(SQLParserEngine.java:61)
at org.apache.shardingsphere.shardingproxy.backend.text.TextProtocolBackendHandlerFactory.newInstance(TextProtocolBackendHandlerFactory.java:69)
at org.apache.shardingsphere.shardingproxy.frontend.postgresql.command.query.text.PostgreSQLComQueryExecutor.(PostgreSQLComQueryExecutor.java:65)
at org.apache.shardingsphere.shardingproxy.frontend.postgresql.command.PostgreSQLCommandExecutorFactory.newInstance(PostgreSQLCommandExecutorFactory.java:58)
at org.apache.shardingsphere.shardingproxy.frontend.postgresql.command.PostgreSQLCommandExecuteEngine.getCommandExecutor(PostgreSQLCommandExecuteEngine.java:60)
at org.apache.shardingsphere.shardingproxy.frontend.command.CommandExecutorTask.executeCommand(CommandExecutorTask.java:92)
at org.apache.shardingsphere.shardingproxy.frontend.command.CommandExecutorTask.run(CommandExecutorTask.java:71)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)

@RaigorJiang
Copy link
Contributor

RaigorJiang commented Oct 18, 2021

Hi @penghuazhou
What Proxy supports is a database protocol, not a programming language or framework.
If Proxy cannot be used normally, we need to analyze what the input SQL statement is, please do not provide information about a specific language or framework. This is not helpful to us.

In addition, compared to version 4.x, 5.0 has more support for SQL statements, which is why I ask you if you can try the new version.

@penghuazhou
Copy link
Contributor Author

@RaigorJiang , I use master code, It have a error message "'ServerManager' object has no attribute 'user_info'"

企业微信截图_18074d60-cd9e-442a-b6d3-fd7a02d07e26

企业微信截图_01890953-2504-4bb8-b884-a9418d1e5044

@RaigorJiang
Copy link
Contributor

@penghuazhou
Please adjust the log level of Proxy to DEBUG, and then observe the SQL received by Proxy.
This configuration is in logback.xml:

<logger name="org.apache.shardingsphere" level="debug" additivity="false">
        <appender-ref ref="console" />
    </logger>

And the key words of log: Execute packet type

@penghuazhou
Copy link
Contributor Author

@RaigorJiang

企业微信截图_2a2b365c-0299-4fcd-b810-adf826014850

+--------+-------------------------------------------------+----------------+
|00000000| 51 00 00 01 19 0a 53 45 4c 45 43 54 0a 20 20 20 |Q.....SELECT. |
|00000010| 20 64 62 2e 6f 69 64 20 61 73 20 64 69 64 2c 20 | db.oid as did, |
|00000020| 64 62 2e 64 61 74 6e 61 6d 65 2c 20 64 62 2e 64 |db.datname, db.d|
|00000030| 61 74 61 6c 6c 6f 77 63 6f 6e 6e 2c 0a 20 20 20 |atallowconn,. |
|00000040| 20 70 67 5f 65 6e 63 6f 64 69 6e 67 5f 74 6f 5f | pg_encoding_to_|
|00000050| 63 68 61 72 28 64 62 2e 65 6e 63 6f 64 69 6e 67 |char(db.encoding|
|00000060| 29 20 41 53 20 73 65 72 76 65 72 65 6e 63 6f 64 |) AS serverencod|
|00000070| 69 6e 67 2c 0a 20 20 20 20 68 61 73 5f 64 61 74 |ing,. has_dat|
|00000080| 61 62 61 73 65 5f 70 72 69 76 69 6c 65 67 65 28 |abase_privilege(|
|00000090| 64 62 2e 6f 69 64 2c 20 27 43 52 45 41 54 45 27 |db.oid, 'CREATE'|
|000000a0| 29 20 61 73 20 63 61 6e 63 72 65 61 74 65 2c 20 |) as cancreate, |
|000000b0| 64 61 74 6c 61 73 74 73 79 73 6f 69 64 2c 0a 20 |datlastsysoid,. |
|000000c0| 20 20 20 64 61 74 69 73 74 65 6d 70 6c 61 74 65 | datistemplate|
|000000d0| 0a 46 52 4f 4d 0a 20 20 20 20 70 67 5f 63 61 74 |.FROM. pg_cat|
|000000e0| 61 6c 6f 67 2e 70 67 5f 64 61 74 61 62 61 73 65 |alog.pg_database|
|000000f0| 20 64 62 0a 57 48 45 52 45 20 64 62 2e 64 61 74 | db.WHERE db.dat|
|00000100| 6e 61 6d 65 20 3d 20 63 75 72 72 65 6e 74 5f 64 |name = current_d|
|00000110| 61 74 61 62 61 73 65 28 29 00 |atabase(). |
+--------+-------------------------------------------------+----------------+
[DEBUG] 2021-10-18 16:57:14.694 [Connection-2-ThreadExecutor] o.a.s.p.f.p.c.PostgreSQLCommandExecutorFactory - Execute packet type: SIMPLE_QUERY, value: org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.text.PostgreSQLComQueryPacket@1224f7ac
[DEBUG] 2021-10-18 16:57:14.760 [nioEventLoopGroup-3-2] o.a.s.db.protocol.codec.PacketCodec - Write to client 34771aad :
+-------------------------------------------------+
| 0 1 2 3 4 5 6 7 8 9 a b c d e f |
+--------+-------------------------------------------------+----------------+
|00000000| 45 00 00 00 3e 53 45 52 52 4f 52 00 56 45 52 52 |E...>SERROR.VERR|
|00000010| 4f 52 00 43 35 38 30 30 30 00 4d 53 63 68 65 6d |OR.C58000.MSchem|
|00000020| 61 20 27 70 67 5f 63 61 74 61 6c 6f 67 27 20 64 |a 'pg_catalog' d|
|00000030| 6f 65 73 6e 27 74 20 65 78 69 73 74 2e 00 00 |oesn't exist... |
+--------+-------------------------------------------------+----------------+
[DEBUG] 2021-10-18 16:57:14.760 [nioEventLoopGroup-3-2] o.a.s.db.protocol.codec.PacketCodec - Write to client 34771aad :
+-------------------------------------------------+
| 0 1 2 3 4 5 6 7 8 9 a b c d e f |
+--------+-------------------------------------------------+----------------+
|00000000| 5a 00 00 00 05 49 |Z....I |
+--------+-------------------------------------------------+----------------+

@RaigorJiang
Copy link
Contributor

It seems that the connection has been successful, but the database and table information is incorrect, because the way Postgre obtains information is different from that of MySQL, and this part needs to be improved.

@RaigorJiang
Copy link
Contributor

But you can execute your own business SQL without worrying about whether the metadata is displayed correctly.

@penghuazhou
Copy link
Contributor Author

but I can not use pgadmin4,do you have a gui tools to connect to shardsphere-proxy?

@penghuazhou
Copy link
Contributor Author

penghuazhou commented Oct 18, 2021

@RaigorJiang but I can not use pgadmin4,do you have a gui tools(a postgresql database client tool) to connect to shardsphere-proxy?

@RaigorJiang
Copy link
Contributor

@penghuazhou
Copy link
Contributor Author

do you know why return "'pg_catalog' doesn't exist"? It exists in database

企业微信截图_eafdc4f7-c657-43f0-8e72-d9775c537904

|00000000| 45 00 00 00 3e 53 45 52 52 4f 52 00 56 45 52 52 |E...>SERROR.VERR|
|00000010| 4f 52 00 43 35 38 30 30 30 00 4d 53 63 68 65 6d |OR.C58000.MSchem|
|00000020| 61 20 27 70 67 5f 63 61 74 61 6c 6f 67 27 20 64 |a 'pg_catalog' d|
|00000030| 6f 65 73 6e 27 74 20 65 78 69 73 74 2e 00 00 |oesn't exist... |

@RaigorJiang
Copy link
Contributor

do you know why return "'pg_catalog' doesn't exist"? It exists in database

Because when you are using ShardingSphere-Proxy, the schema is what you defined in Proxy configuration.
Users cannot directly access the metadata of a physical database, because in a distributed database system, the information of a single database may not be complete.

However, access to metadata is very important to some SQL clients, so this part still needs support, and we are already sorting out related plans.

@penghuazhou
Copy link
Contributor Author

@RaigorJiang DataGrip:2021.1 can execute sql, but can not show databases message

企业微信截图_b8b7f112-55be-47ac-be76-b0b1a9568b0b

@RaigorJiang
Copy link
Contributor

Yes, because the way postgre queries schema and table metadata is different from MySQL, this is a known issue, and we will fix it later.

@penghuazhou
Copy link
Contributor Author

thanks

@tristaZero
Copy link
Contributor

@RaigorJiang This will be our next improvement for the next release? Do we have any plans?

@RaigorJiang
Copy link
Contributor

Yes, plans will be sorted out this week, so stay tuned~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants