dremio mysql utf8mb4 union 字符编码问题三

以前说过此问题,但是在实际测试中发现一个比较有意思的问额,连接回收管理有问题,会造成连接一直创建不释放,然后的问题就是服务不稳定,之后通过jprofiler 验证发现就是连接一直不释放,创建的比较多

说明

jdbc 驱动切换还是应该谨慎一些,做好测试,当然使用好了连接池问题应该也不大,核心是dremio mysql 使用的mariadb 的datasource 代码上有bug,但是这个问题在低版本不出现,在新版本jdbc 驱动中就有问题了,大致说明下

  • dremio 的代码

原本是希望是带pool 的datasource,但是实际MariaDbDataSource 每次都是创建新的,在3.0.8版本似乎有pool 的效果,并不是每次都创建,但是新版本这个问题就很明显了,dremio 每次查询都会有新的,合理的是应该使用MariaDbPoolDataSource


private CloseableDataSource newDataSource() throws SQLException {
    ConnectionPoolDataSource source;
    try {
        source = (ConnectionPoolDataSource)ConstructorUtils.invokeConstructor(Class.forName("org.mariadb.jdbc.MariaDbDataSource"), new Object[0]);
    } catch (InvocationTargetException e) {
        Throwable cause = e.getCause();
        Throwables.throwIfInstanceOf(cause, SQLException.class);
        Throwables.throwIfUnchecked(cause);
        throw new RuntimeException("Cannot instantiate MySQL datasource", cause);
    } catch (ReflectiveOperationException e) {
        throw new RuntimeException("Cannot instantiate MySQL datasource", e);
    }

    return this.newDataSource(source);
}

参考资料

https://mariadb.com/docs/connectors/mariadb-connector-j/pool-datasource-implementation

posted on 2025-12-17 08:00  荣锋亮  阅读(4)  评论(0)    收藏  举报

导航