由于 PolarDB-X 的元数据存储在 MetaDB 中,我们需要使用 mysql -h127.0.0.1 -P4886 -uroot -padmin -D polardbx_meta_db_polardbx -e "select passwd_enc from storage_info where inst_kind=2" 查看 metaDbPasswd。执行出现如下异常,官方文档提供的 root/admin 的账号无法连接到 some-dn-and-gms 容器提供的 MySQL 服务。
1 2
mysql: [Warning] Using a password on the command line interface can be insecure. ERROR 1045 (28000): Access denied for user 'root'@'192.168.65.1' (using password: YES)
2024-09-02 08:12:44.168 [main] ERROR com.alibaba.polardbx.CobarConfig - [] Failed to init cobar server. com.alibaba.polardbx.common.exception.TddlRuntimeException: ERR-CODE: [PXC-10001][ERR_X_PROTOCOL_CLIENT] XDataSource to my_polarx#1c31783e@127.0.0.1:32886 Failed to init new TCP. XClientPool to my_polarx#1c31783e@127.0.0.1:32886 now 0 TCP(0 aging), 0 sessions(0 running, 0 idle), 0 waiting connection. at com.alibaba.polardbx.rpc.compatible.XDataSource.getConnection(XDataSource.java:210) at com.alibaba.polardbx.gms.metadb.MetaDbDataSource.initTsoServicesX(MetaDbDataSource.java:139) at com.alibaba.polardbx.gms.metadb.MetaDbDataSource.initXDataSourceByJdbcProps(MetaDbDataSource.java:202) at com.alibaba.polardbx.gms.metadb.MetaDbDataSource.initMetaDbDataSource(MetaDbDataSource.java:213) at com.alibaba.polardbx.gms.metadb.MetaDbDataSource.doInit(MetaDbDataSource.java:135) at com.alibaba.polardbx.common.model.lifecycle.AbstractLifecycle.init(AbstractLifecycle.java:43) at com.alibaba.polardbx.gms.metadb.MetaDbDataSource.getInstance(MetaDbDataSource.java:530) at com.alibaba.polardbx.gms.util.MetaDbUtil.getConnection(MetaDbUtil.java:53) at com.alibaba.polardbx.gms.metadb.schema.SchemaChangeAccessor.create(SchemaChangeAccessor.java:79) at com.alibaba.polardbx.gms.metadb.schema.SchemaChangeAccessor.doInit(SchemaChangeAccessor.java:75) at com.alibaba.polardbx.common.model.lifecycle.AbstractLifecycle.init(AbstractLifecycle.java:43) at com.alibaba.polardbx.gms.metadb.schema.SchemaChangeManager.doInit(SchemaChangeManager.java:62) at com.alibaba.polardbx.common.model.lifecycle.AbstractLifecycle.init(AbstractLifecycle.java:43) at com.alibaba.polardbx.gms.metadb.schema.SchemaChangeManager.getInstance(SchemaChangeManager.java:55) at com.alibaba.polardbx.config.loader.ServerLoader.initPolarDbXComponents(ServerLoader.java:222) at com.alibaba.polardbx.config.loader.ServerLoader.load(ServerLoader.java:191) at com.alibaba.polardbx.config.loader.ServerLoader.doInit(ServerLoader.java:96) at com.alibaba.polardbx.common.model.lifecycle.AbstractLifecycle.init(AbstractLifecycle.java:43) at com.alibaba.polardbx.CobarConfig.initCobarConfig(CobarConfig.java:80) at com.alibaba.polardbx.CobarConfig.<init>(CobarConfig.java:61) at com.alibaba.polardbx.CobarServer.<init>(CobarServer.java:154) at com.alibaba.polardbx.CobarServer.<clinit>(CobarServer.java:108) at com.alibaba.polardbx.server.TddlLauncher.main(TddlLauncher.java:126) Caused by: com.alibaba.polardbx.common.exception.TddlNestableRuntimeException: Failed to init new TCP. XClientPool to my_polarx#1c31783e@127.0.0.1:32886 now 0 TCP(0 aging), 0 sessions(0 running, 0 idle), 0 waiting connection. at com.alibaba.polardbx.rpc.pool.XConnectionManager.getConnection(XConnectionManager.java:514) at com.alibaba.polardbx.rpc.compatible.XDataSource.getConnection(XDataSource.java:193) ... 22 common frames omitted Caused by: com.alibaba.polardbx.common.exception.TddlNestableRuntimeException: Failed to init new TCP. at com.alibaba.polardbx.rpc.pool.XClientPool.getConnection(XClientPool.java:491) at com.alibaba.polardbx.rpc.pool.XClientPool.getConnection(XClientPool.java:287) at com.alibaba.polardbx.rpc.pool.XConnectionManager.getConnection(XConnectionManager.java:502) ... 23 common frames omitted Caused by: com.alibaba.polardbx.common.exception.TddlRuntimeException: ERR-CODE: [PXC-10001][ERR_X_PROTOCOL_CLIENT] XClientPool to my_polarx#1c31783e@127.0.0.1:32886 connect fail. at com.alibaba.polardbx.rpc.pool.XClientPool.getConnection(XClientPool.java:474) ... 25 common frames omitted 2024-09-02 08:12:44.171 [main] ERROR com.alibaba.polardbx.server.TddlLauncher - [] ## Something goes wrong when starting up the tddl server: java.lang.ExceptionInInitializerError at com.alibaba.polardbx.server.TddlLauncher.main(TddlLauncher.java:126) Caused by: ERR-CODE: [PXC-10001][ERR_X_PROTOCOL_CLIENT] XDataSource to my_polarx#1c31783e@127.0.0.1:32886 Failed to init new TCP. XClientPool to my_polarx#1c31783e@127.0.0.1:32886 now 0 TCP(0 aging), 0 sessions(0 running, 0 idle), 0 waiting connection. at com.alibaba.polardbx.rpc.compatible.XDataSource.getConnection(XDataSource.java:210) at com.alibaba.polardbx.gms.metadb.MetaDbDataSource.initTsoServicesX(MetaDbDataSource.java:139) at com.alibaba.polardbx.gms.metadb.MetaDbDataSource.initXDataSourceByJdbcProps(MetaDbDataSource.java:202) at com.alibaba.polardbx.gms.metadb.MetaDbDataSource.initMetaDbDataSource(MetaDbDataSource.java:213) at com.alibaba.polardbx.gms.metadb.MetaDbDataSource.doInit(MetaDbDataSource.java:135) at com.alibaba.polardbx.common.model.lifecycle.AbstractLifecycle.init(AbstractLifecycle.java:43) at com.alibaba.polardbx.gms.metadb.MetaDbDataSource.getInstance(MetaDbDataSource.java:530) at com.alibaba.polardbx.gms.util.MetaDbUtil.getConnection(MetaDbUtil.java:53) at com.alibaba.polardbx.gms.metadb.schema.SchemaChangeAccessor.create(SchemaChangeAccessor.java:79) at com.alibaba.polardbx.gms.metadb.schema.SchemaChangeAccessor.doInit(SchemaChangeAccessor.java:75) at com.alibaba.polardbx.common.model.lifecycle.AbstractLifecycle.init(AbstractLifecycle.java:43) at com.alibaba.polardbx.gms.metadb.schema.SchemaChangeManager.doInit(SchemaChangeManager.java:62) at com.alibaba.polardbx.common.model.lifecycle.AbstractLifecycle.init(AbstractLifecycle.java:43) at com.alibaba.polardbx.gms.metadb.schema.SchemaChangeManager.getInstance(SchemaChangeManager.java:55) at com.alibaba.polardbx.config.loader.ServerLoader.initPolarDbXComponents(ServerLoader.java:222) at com.alibaba.polardbx.config.loader.ServerLoader.load(ServerLoader.java:191) at com.alibaba.polardbx.config.loader.ServerLoader.doInit(ServerLoader.java:96) at com.alibaba.polardbx.common.model.lifecycle.AbstractLifecycle.init(AbstractLifecycle.java:43) at com.alibaba.polardbx.CobarConfig.initCobarConfig(CobarConfig.java:80) at com.alibaba.polardbx.CobarConfig.<init>(CobarConfig.java:61) at com.alibaba.polardbx.CobarServer.<init>(CobarServer.java:154) at com.alibaba.polardbx.CobarServer.<clinit>(CobarServer.java:108) ... 1 more Caused by: Failed to init new TCP. XClientPool to my_polarx#1c31783e@127.0.0.1:32886 now 0 TCP(0 aging), 0 sessions(0 running, 0 idle), 0 waiting connection. at com.alibaba.polardbx.rpc.pool.XConnectionManager.getConnection(XConnectionManager.java:514) at com.alibaba.polardbx.rpc.compatible.XDataSource.getConnection(XDataSource.java:193) ... 22 more Caused by: Failed to init new TCP. at com.alibaba.polardbx.rpc.pool.XClientPool.getConnection(XClientPool.java:491) at com.alibaba.polardbx.rpc.pool.XClientPool.getConnection(XClientPool.java:287) at com.alibaba.polardbx.rpc.pool.XConnectionManager.getConnection(XConnectionManager.java:502) ... 23 more Caused by: ERR-CODE: [PXC-10001][ERR_X_PROTOCOL_CLIENT] XClientPool to my_polarx#1c31783e@127.0.0.1:32886 connect fail. at com.alibaba.polardbx.rpc.pool.XClientPool.getConnection(XClientPool.java:474) ... 25 more
0 [main] DEBUG Sigar - no libsigar-universal64-macosx.dylib in java.library.path org.hyperic.sigar.SigarException: no libsigar-universal64-macosx.dylib in java.library.path at org.hyperic.sigar.Sigar.loadLibrary(Sigar.java:172) at org.hyperic.sigar.Sigar.<clinit>(Sigar.java:100) at com.alibaba.polardbx.executor.handler.LogicalShowHtcHandler.<clinit>(LogicalShowHtcHandler.java:48) at com.alibaba.polardbx.repo.mysql.handler.CommandHandlerFactoryMyImp.<init>(CommandHandlerFactoryMyImp.java:397) at com.alibaba.polardbx.repo.mysql.spi.MyRepository.doInit(MyRepository.java:62) at com.alibaba.polardbx.common.model.lifecycle.AbstractLifecycle.init(AbstractLifecycle.java:43) at com.alibaba.polardbx.repo.mysql.spi.RepositoryFactoryMyImp.buildRepository(RepositoryFactoryMyImp.java:34) at com.alibaba.polardbx.executor.repo.RepositoryHolder.getOrCreateRepository(RepositoryHolder.java:54) at com.alibaba.polardbx.executor.common.TopologyHandler.createOne(TopologyHandler.java:279) at com.alibaba.polardbx.matrix.config.MatrixConfigHolder.initGroups(MatrixConfigHolder.java:844) at com.alibaba.polardbx.matrix.config.MatrixConfigHolder.doInit(MatrixConfigHolder.java:172) at com.alibaba.polardbx.common.model.lifecycle.AbstractLifecycle.init(AbstractLifecycle.java:43) at com.alibaba.polardbx.matrix.jdbc.TDataSource.doInit(TDataSource.java:201) at com.alibaba.polardbx.common.model.lifecycle.AbstractLifecycle.init(AbstractLifecycle.java:43) at com.alibaba.polardbx.matrix.jdbc.utils.TDataSourceInitUtils.initDataSource(TDataSourceInitUtils.java:33) at com.alibaba.polardbx.config.loader.AppLoader.loadSchema(AppLoader.java:121) at com.alibaba.polardbx.config.loader.GmsAppLoader.loadApp(GmsAppLoader.java:72) at com.alibaba.polardbx.config.loader.BaseAppLoader.loadApps(BaseAppLoader.java:90) at com.alibaba.polardbx.config.loader.GmsAppLoader.initDbUserPrivsInfo(GmsAppLoader.java:55) at com.alibaba.polardbx.config.loader.GmsClusterLoader.initClusterAppInfo(GmsClusterLoader.java:363) at com.alibaba.polardbx.config.loader.GmsClusterLoader.loadPolarDbXCluster(GmsClusterLoader.java:234) at com.alibaba.polardbx.config.loader.GmsClusterLoader.loadCluster(GmsClusterLoader.java:213) at com.alibaba.polardbx.config.loader.GmsClusterLoader.doInit(GmsClusterLoader.java:178) at com.alibaba.polardbx.common.model.lifecycle.AbstractLifecycle.init(AbstractLifecycle.java:43) at com.alibaba.polardbx.CobarConfig.doInit(CobarConfig.java:145) at com.alibaba.polardbx.common.model.lifecycle.AbstractLifecycle.init(AbstractLifecycle.java:43) at com.alibaba.polardbx.CobarServer.doInit(CobarServer.java:213) at com.alibaba.polardbx.common.model.lifecycle.AbstractLifecycle.init(AbstractLifecycle.java:43) at com.alibaba.polardbx.server.TddlLauncher.main(TddlLauncher.java:128)
Caused by: java.lang.AssertionError: bad type null at org.apache.calcite.plan.volcano.Dumpers.provenanceRecurse(Dumpers.java:116) at org.apache.calcite.plan.volcano.Dumpers.provenance(Dumpers.java:79) at org.apache.calcite.plan.volcano.VolcanoPlanner.findBestExp(VolcanoPlanner.java:537) at com.alibaba.polardbx.optimizer.core.planner.Planner.getCheapestFractionalPlan(Planner.java:1412) at com.alibaba.polardbx.optimizer.core.planner.Planner.optimizeByCBO(Planner.java:1324) at com.alibaba.polardbx.optimizer.core.planner.Planner.optimizeByPlanEnumerator(Planner.java:1239) at com.alibaba.polardbx.optimizer.core.planner.Planner.sqlRewriteAndPlanEnumerate(Planner.java:1186) at com.alibaba.polardbx.optimizer.core.planner.Planner.optimize(Planner.java:1160) at com.alibaba.polardbx.optimizer.core.planner.Planner.getPlan(Planner.java:945) at com.alibaba.polardbx.optimizer.core.planner.Planner.doBuildPlan(Planner.java:474) at com.alibaba.polardbx.optimizer.core.planner.Planner.doBuildPlan(Planner.java:510) at com.alibaba.polardbx.optimizer.core.planner.Planner.doPlan(Planner.java:2699) at com.alibaba.polardbx.optimizer.core.planner.Planner.plan(Planner.java:375) at com.alibaba.polardbx.optimizer.core.planner.Planner.plan(Planner.java:347) at com.alibaba.polardbx.optimizer.core.planner.Planner.planAfterProcessing(Planner.java:342) at com.alibaba.polardbx.optimizer.core.planner.Planner.plan(Planner.java:311) at com.alibaba.polardbx.optimizer.core.planner.Planner.plan(Planner.java:278) at com.alibaba.polardbx.repo.mysql.handler.LogicalShowTablesMyHandler.handle(LogicalShowTablesMyHandler.java:95) at com.alibaba.polardbx.executor.handler.HandlerCommon.handlePlan(HandlerCommon.java:153) at com.alibaba.polardbx.executor.AbstractGroupExecutor.executeInner(AbstractGroupExecutor.java:74) at com.alibaba.polardbx.executor.AbstractGroupExecutor.execByExecPlanNode(AbstractGroupExecutor.java:52) at com.alibaba.polardbx.executor.TopologyExecutor.execByExecPlanNode(TopologyExecutor.java:50) at com.alibaba.polardbx.transaction.TransactionExecutor.execByExecPlanNode(TransactionExecutor.java:141) at com.alibaba.polardbx.executor.ExecutorHelper.executeByCursor(ExecutorHelper.java:170) at com.alibaba.polardbx.executor.ExecutorHelper.execute(ExecutorHelper.java:92) at com.alibaba.polardbx.executor.ExecutorHelper.execute(ExecutorHelper.java:84) at com.alibaba.polardbx.executor.PlanExecutor.execByExecPlanNodeByOne(PlanExecutor.java:223) at com.alibaba.polardbx.executor.PlanExecutor.execute(PlanExecutor.java:91) at com.alibaba.polardbx.matrix.jdbc.TConnection.executeQuery(TConnection.java:737) at com.alibaba.polardbx.matrix.jdbc.TConnection.executeSQL(TConnection.java:510) ... 19 common frames omitted
/** * @param data requests on one connection must be processed sequentially */ @Override synchronizedpublicvoidhandle(byte[] data) { source.buildMDC(); source.setPacketId((byte) (0 & 0xff)); source.setLastActiveTime(System.nanoTime()); source.setSqlBeginTimestamp(System.currentTimeMillis());
switch (data[4]) { case Commands.COM_INIT_DB: commandCount.doInitDB(); source.initDB(data); break; case Commands.COM_PING: commandCount.doPing(); source.ping(); break; case Commands.COM_QUIT: commandCount.doQuit(); source.close(); break; case Commands.COM_QUERY: commandCount.doQuery(); // 调用父类 FrontendConnection#query 方法 source.query(data); break; ... }
/** * Separate execute(sql, ec) into two parts: plan and execute. If it's * writing into broadcast table and has no transaction, a new transaction * will be open. */ private ResultCursor executeQuery(ByteString sql, ExecutionContext executionContext, AtomicBoolean trxPolicyModified) { ... // 获取元数据快照 finallong[] metaVersions = MdlContext.snapshotMetaVersions();
finalParametersoriginParams= executionContext.getParams().clone(); // 获取执行计划 ExecutionPlanplan= Planner.getInstance().plan(sql, executionContext); ... // 如果元数据变更则重建执行计划 if (trxPolicyModified != null) { trxPolicyModified.set(updateTransactionAndConcurrentPolicy(plan, executionContext)); if (PlanManagerUtil.canOptByForcePrimary(plan, executionContext) && executionContext.isTsoTransaction()) { // If this plan can be optimized, rebuild plan. plan = rebuildPlan(sql, executionContext, originParams, false); } } ... // 调用执行器执行 ResultCursorresultCursor= executor.execute(plan, executionContext); // 更新表统计信息 updateTableStatistic(plan, resultCursor, executionContext); return resultCursor; }