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

A trace component is used to trace mycat execution deeply(窥探mycat异步执行的神器). #1335

Open
wants to merge 10 commits into
base: 1.5
Choose a base branch
from

Conversation

forchid
Copy link

@forchid forchid commented Jan 11, 2017

A component is used to trace mycat execution deeply, which includes basic trace
and frontend-or-backend connection trace, for debug intention and our high qualified
mycat server.

The tracer is disabled by default, and you can enable it by specifying
the system property {@code -Dmycat.trace.enabled=true} and setting log4j
debug level.

跟踪示例:

  1. 后端连接创建
    -- 后端连接tag - backend#hashCode-id
    01/12 02:45:01.364 DEBUG [BusinessExecutor2] (Tracer.java:159) -[backend#17b3295-0] created
    [backend#17b3295-0][BusinessExecutor2]> java.lang.Thread.run(Unknown Source)
    [backend#17b3295-0][BusinessExecutor2] > java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    [backend#17b3295-0][BusinessExecutor2] > java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    [backend#17b3295-0][BusinessExecutor2] > org.opencloudb.backend.PhysicalDatasource$1.run(PhysicalDatasource.java:342)
    [backend#17b3295-0][BusinessExecutor2] > org.opencloudb.mysql.nio.MySQLDataSource.createNewConnection(MySQLDataSource.java:51)
    [backend#17b3295-0][BusinessExecutor2] > org.opencloudb.mysql.nio.MySQLConnectionFactory.make(MySQLConnectionFactory.java:77)

  2. 前端认证跟踪
    -- 前端连接tag - fronend#hashCode-id
    -- 2.1 连接创建
    01/12 02:45:11.656 DEBUG [$_MyCatServer] (Tracer.java:159) -[fronend#1299f0a-0] created
    [fronend#1299f0a-0][$_MyCatServer]> org.opencloudb.net.NIOAcceptor.run(NIOAcceptor.java:91)
    [fronend#1299f0a-0][$_MyCatServer] > org.opencloudb.net.NIOAcceptor.accept(NIOAcceptor.java:110)
    [fronend#1299f0a-0][$_MyCatServer] > org.opencloudb.net.factory.FrontendConnectionFactory.make(FrontendConnectionFactory.java:48)
    -- 2.2 连接认证
    01/12 02:45:11.668 DEBUG [$_NIOREACTOR-0-RW] (Tracer.java:159) -[fronend#1299f0a-1] ServerConnection [id=1, schema=null, host=0:0:0:0:0:0:0:1, user=null,txIsolation=3, autocommit=true, schema=null]
    [fronend#1299f0a-1][$_NIOREACTOR-0-RW]> java.lang.Thread.run(Unknown Source)
    [fronend#1299f0a-1][$_NIOREACTOR-0-RW] > org.opencloudb.net.NIOReactor$RW.run(NIOReactor.java:100)
    [fronend#1299f0a-1][$_NIOREACTOR-0-RW] > org.opencloudb.net.AbstractConnection.asynRead(AbstractConnection.java:274)
    [fronend#1299f0a-1][$_NIOREACTOR-0-RW] > org.opencloudb.net.NIOSocketWR.asynRead(NIOSocketWR.java:186)
    [fronend#1299f0a-1][$_NIOREACTOR-0-RW] > org.opencloudb.net.AbstractConnection.onReadData(AbstractConnection.java:313)
    [fronend#1299f0a-1][$_NIOREACTOR-0-RW] > org.opencloudb.net.FrontendConnection.handle(FrontendConnection.java:417)
    [fronend#1299f0a-1][$_NIOREACTOR-0-RW] > org.opencloudb.net.FrontendConnection.rawHandle(FrontendConnection.java:435)
    [fronend#1299f0a-1][$_NIOREACTOR-0-RW] > org.opencloudb.net.handler.FrontendAuthenticator.handle(FrontendAuthenticator.java:61)

1. Mycat开发或调试时,ZkConfig先使用log4j,结果log4j先初始化了,而home
path在后面才初始化,导致${MYCAT_HOME}/logs/mycat.log变成了/logs/mycat.log。
在MycatStartup.java里static{}块里先初始化home path即可。

2. Mycat开发或调试时,conf目录下并没有log4j.xml,导致${MYCAT_HOME}/conf/log4j.xml
加载失败。改为从类路径加载log4j.xml(与部署时并不冲突)。
+ Trace buffer allocate & recycle.
+ Trace Frontend connection & MySQL backend connection, includes create,
take, 
  release and close.
+ Trace tx execution such as start, commit and rollback.
* fixbug one rollback multi-response and rollback not over(response
handler handed over
  RollbackReleaseHandler is incorrect) issues in RollbackNodeHandler,
and remove the class
  RollbackNodeHandler for success or fail(connection broken only) always
correct after 
  calling backend rollback() in RollbackReleaseHandler.
# update company set description=description where id=1;
--
-- select 1;
-- 
/***/
/**/
/*select 1; */
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