[alibaba/canal]canal TSDB 启动一直循环报错

2024-07-22 219 views
4
table meta tsdb info

canal.instance.tsdb.enable = true canal.instance.tsdb.dir = ${canal.file.data.dir:../conf}/${canal.instance.destination:}

canal.instance.tsdb.url = jdbc:h2:${canal.instance.tsdb.dir}/h2;CACHE_SIZE=1000;MODE=MYSQL;

canal.instance.tsdb.url = jdbc:mysql://10.16.14.14:3306/canal_tsdb

canal.instance.tsdb.spring.xml = classpath:spring/tsdb/h2-tsdb.xml

canal.instance.tsdb.spring.xml = classpath:spring/tsdb/mysql-tsdb.xml canal.instance.tsdb.dbUsername = root canal.instance.tsdb.dbPassword = root

dump snapshot interval, default 24 hour

canal.instance.tsdb.snapshot.interval = 24

purge snapshot expire , default 360 hour(15 days)

canal.instance.tsdb.snapshot.expire = 360

开启TSDB

一直有 2022-11-17 13:42:03.453 [canal-instance-scan-0] WARN com.alibaba.druid.pool.DruidDataSource - get connection timeout retry : 1 2022-11-17 13:42:05.313 [Druid-ConnectionPool-Create-277617834] ERROR com.alibaba.druid.pool.DruidDataSource - create connection RuntimeException java.lang.NullPointerException: null at java.util.Hashtable.put(Hashtable.java:459) ~[na:1.8.0_131] at java.util.Properties.setProperty(Properties.java:166) ~[na:1.8.0_131] at com.mysql.jdbc.NonRegisteringDriver.parseURL(NonRegisteringDriver.java:795) ~[mysql-connector-java-5.1.48.jar:5.1.48] at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:314) ~[mysql-connector-java-5.1.48.jar:5.1.48] at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1678) ~[druid-1.2.12.jar:1.2.12] at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1755) ~[druid-1.2.12.jar:1.2.12] at com.alibaba.druid.pool.DruidDataSource$CreateConnectionThread.run(DruidDataSource.java:2825) ~[druid-1.2.12.jar:1.2.12]

日志非常多,有谁遇到过吗?帮忙就是master

回答

7

地址,账号密码都确认了没有问题

5

这种问题自己本地debug一下就能确认了,没必要提issue

1

没调试出来问题,不过我换了个版本到没有这个问题了

9

这个锅不知道该给 druid 还是 mysql jdbc 驱动或者是 jdk。 原因是DruidAbstractDataSource会设置一个默认参数connectTimeout,类型是 int,后面赋值的时候竟然取不到。

// DruidAbstractDataSource 设置初始值

if (connectTimeout > 0) {
    if (isMySql) {
        physicalConnectProperties.put("connectTimeout", connectTimeout);
    } else if (isOracle) {
        physicalConnectProperties.put("oracle.net.CONNECT_TIMEOUT", connectTimeout);
    } else if (driver != null && "org.postgresql.Driver".equals(driver.getClass().getName())) {
        physicalConnectProperties.put("loginTimeout", connectTimeout);
        physicalConnectProperties.put("socketTimeout", connectTimeout);
    }
}
// NonRegisteringDriver.java

if (defaults != null) {
    Iterator<Object> propsIter = defaults.keySet().iterator();

    while (propsIter.hasNext()) {
        String key = propsIter.next().toString();
        if (!key.equals(NUM_HOSTS_PROPERTY_KEY)) {
            // 这里取不到 connectTimeout,property 是 null
            String property = defaults.getProperty(key);
            urlProps.setProperty(key, property);
        }
    }
}

看下这个测试程序就清楚了

String key = "key";
Properties p = new Properties();
p.put(key, 1000);

String property = p.getProperty(key);
Object property1 = p.get(key);
System.out.printf("getProperty => %s \n", property);
System.out.printf("get => %s \n", property1);
getProperty => null 
get => 1000