oblogproxy icon indicating copy to clipboard operation
oblogproxy copied to clipboard

[Bug]: 查询全局变量时没有正确处理别名,导致获取不到server_id

Open lenmore opened this issue 1 year ago • 1 comments

Describe the bug

oblog proxy 版本: v4.2.0

这个问题在社区反馈过(https://ask.oceanbase.com/t/topic/35615629 ),没人跟进,只能来这再反馈一次。

背景是测试Maxwell抽取oblogproxy时,报错找不到server_id列。

2025-01-17 16:22:37 ERROR Maxwell - SQLException: Column 'server_id' not found.
java.sql.SQLException: Column 'server_id' not found.
        at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129) ~[mysql-connector-java-8.0.28.jar:8.0.28]
        at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97) ~[mysql-connector-java-8.0.28.jar:8.0.28]
        at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89) ~[mysql-connector-java-8.0.28.jar:8.0.28]
        at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:63) ~[mysql-connector-java-8.0.28.jar:8.0.28]
        at com.mysql.cj.jdbc.result.ResultSetImpl.findColumn(ResultSetImpl.java:584) ~[mysql-connector-java-8.0.28.jar:8.0.28]
        at com.mysql.cj.jdbc.result.ResultSetImpl.getLong(ResultSetImpl.java:862) ~[mysql-connector-java-8.0.28.jar:8.0.28]
        at com.mchange.v2.c3p0.impl.NewProxyResultSet.getLong(NewProxyResultSet.java:477) ~[c3p0-0.9.5.5.jar:0.9.5.5]
        at com.zendesk.maxwell.MaxwellContext.getServerID(MaxwellContext.java:473) ~[maxwell-1.41.2.jar:1.41.2]
        at com.zendesk.maxwell.MaxwellContext.<init>(MaxwellContext.java:133) ~[maxwell-1.41.2.jar:1.41.2]
        at com.zendesk.maxwell.Maxwell.<init>(Maxwell.java:44) ~[maxwell-1.41.2.jar:1.41.2]
        at com.zendesk.maxwell.Maxwell.main(Maxwell.java:322) [maxwell-1.41.2.jar:1.41.2]

看了maxwell的源码,maxwell在启动时会执行SQL获取server_id。

SELECT @@server_id as server_id

这个SQL返回的列名与MySQL不一致,与obproxy不开启binlog时也不一致。

开启了binlog的obproxy返回:

Image

未开启binlog的obproxy返回:

Image

mysql返回:

Image

直连 obbinlog instance实例查询

Image

基于以上可以确定是oblogproxy的bug。

我临时改了几行代码尝试修复了,供参考: https://github.com/lenmore/oblogproxy/commit/c798914977a5449344207fb5473046c655ae14c6

Environment

oblog proxy 版本: v4.2.0

Fast reproduce steps

SELECT @@server_id as server_id;
SELECT @@server_id as abc;

Expected behavior

No response

Actual behavior

No response

Additional context

No response

lenmore avatar Jan 17 '25 08:01 lenmore

感谢反馈!之前在论坛提问的时候,支持的同学可能没搞清楚问题。我们尽快修复一下

whhe avatar Jan 21 '25 06:01 whhe