hs-web / hsweb-framework

hsweb (haʊs wɛb) 是一个基于spring-boot 2.x开发 ,首个使用全响应式编程的企业级后台管理系统基础项目。
http://hsweb.me
Apache License 2.0
8.33k stars 3.05k forks source link

[请教] 连接 doris 发生异常 #220

Closed MoonBottle closed 1 year ago

MoonBottle commented 1 year ago

环境

java: 1.8.0_131 hsweb: 4.0.16

问题说明

我使用 r2dbc-mysql 创建了一个连接 doris,在使用中发现发生了下面的异常

Unknown system variable 'innodb_lock_wait_timeout'

debug 发现是下面的 sql 报错,估计是事务导致的,想问下有什么方法,让 r2dbc-mysql 创建的连接,不走事务么?

SELECT @@transaction_isolation AS i,@@innodb_lock_wait_timeout AS l,@@version_comment AS v,@@system_time_zone AS s,@@time_zone AS t
zhou-hao commented 1 year ago

不建议直接使用mysql驱动连接Doris。 用restful试试?

MoonBottle commented 1 year ago

restful 我没有找到查询的,只看到一个 Stream Load 导入的 api

我想实现在程序里查询和增量写入数据到 doris,下面是我现在在尝试的测试代码

如果不行的话我是不是要起动一个代理服务连接 doris,暴露 restful 接口来供程序调用

    @Bean
    public R2dbcEntityTemplate r2dbcEntityTemplate( ) {
        MySqlConnectionConfiguration configuration = MySqlConnectionConfiguration.builder()
                .host("172.26.6.144")
                .port(9030)
                .user("root")
                .database("demo")
                .build();
        ConnectionFactory connectionFactory = MySqlConnectionFactory.from(configuration);
        return new R2dbcEntityTemplate(connectionFactory);
    }

UserService

@RequiredArgsConstructor
@Service
public class UserService implements CommandLineRunner {

    private final R2dbcEntityTemplate r2dbcEntityTemplate;

    @Override
    public void run(String... args) throws Exception {
         extracted().subscribe();
    }

    @Transactional(propagation = Propagation.NOT_SUPPORTED)
    public Flux<ExampleTbl> extracted() {
         return r2dbcEntityTemplate.select(ExampleTbl.class)
                .all()
                .doOnNext(el -> System.out.println(JSON.toJSONString(el)));
    }
}
MoonBottle commented 1 year ago

抱歉抱歉,我没仔细阅读文档,找到 restful 接口了。 不过还是想请教下,为什么不建议 myql 驱动直连 doris 呢?

zhou-hao commented 1 year ago

抱歉抱歉,我没仔细阅读文档,找到 restful 接口了。

不过还是想请教下,为什么不建议 myql 驱动直连 doris 呢?

doris只是适配了mysql协议,但是不一定完全适配了。个人觉得走restful应该更靠谱吧。

MoonBottle commented 1 year ago

有道理,多谢周佬指教!