PartitionedTableAppender 如何判断已写入完成

避免在未写入完成时,其他线程写入同分区而造成的事务冲突:

 Exception caught in getHistory: Task [-2] come across exception : 127.0.0.1:8503 Server response: '<ChunkInTransaction>T       he openChunks operation failed because the chunk '/candle_db/202403M/6v' is currently locked and in use by transaction 3       5087. RefId:S00002

请先 登录 后评论

1 个回答

peter
        String dbPath = "dfs://test";
        String tableName = "pt";
        int threadCount = 10;
        DBConnectionPool connPool = new ExclusiveDBConnectionPool(host, port, username, password, threadCount, false, false);
        PartitionedTableAppender appender = new PartitionedTableAppender(dbPath, tableName, "symbol", connPool);
        BasicTable data = (BasicTable) conn.run("select * from t limit 10000");
        int rows = appender.append(data);
        System.out.println(rows + " rows inserted.");
        connPool.waitForThreadCompletion();

可以调用 waitForThreadCompletion() 进行同步等待。

请先 登录 后评论
  • 1 关注
  • 0 收藏,133 浏览
  • wfHuang 提出于 2024-03-08 17:37