Meituan-Dianping / Meituan-Dianping/Zebra

分库分表时RouterResult不是SingleTarget的情况下希望也打印路由出来的db和sql debug日志,方便调试

Open
#49 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
2.8k
Forks
705
PR merge metrics
No merged PRs in 30d

Description

com.dianping.zebra.shard.jdbc.ShardStatement#executeQueryByOriginal
此方法中isSingleTarget(routerTarget)情况下打印了db,sql日志;希望else情况下也将db、sql日志打印出来。谢谢!

if (LOGGER.isDebugEnabled()) {
						LOGGER.debug("db:" + targetedSql.getDatabaseName());
						LOGGER.debug("sql:" + executableSql);
					}
if (isSingleTarget(routerTarget)) {
			// if has only one sql,then serial execute it
			for (RouterTarget targetedSql : routerTarget.getSqls()) {
				for (String executableSql : targetedSql.getSqls()) {
					if (LOGGER.isDebugEnabled()) {
						LOGGER.debug("db:" + targetedSql.getDatabaseName());
						LOGGER.debug("sql:" + executableSql);
					}

					Connection conn = connection.getRealConnection(targetedSql.getDatabaseName(), autoCommit);
					Statement stmt = createStatement(conn);
					actualStatements.add(stmt);

					resultList.add(stmt.executeQuery(executableSql));
				}
			}
		}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at com.dianping.zebra.shard.jdbc.ShardStatement#executeQueryByOriginal and compare the existing debug logging in the isSingleTarget(routerTarget) branch with the other execution path. The change is complete when routed database names and executable SQL statements are also logged at debug level for non-single targets.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
database
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.