futaotao5866
V2EX  ›  InfluxDB

使用 influxdb2.x 版本,并发插入数据数据丢失

  •  
  •   futaotao5866 · Nov 27, 2024 · 1854 views
    This topic created in 545 days ago, the information mentioned may be changed or developed.

    部分伪代码 @Override public void insert() { WriteApi writeApi = influxDBClient.makeWriteApi(); for (int i = 0; i < 10000; i++) { Demo demo = new Demo(); demo.setTime(Instant.now());

       writeApi.writeMeasurement("s100", "d", WritePrecision.NS, demo);
    }
    

    } 如果每插入一条休眠 1s ,那么可以全部插入数据不丢失 @Override public void insert() { WriteApi writeApi = influxDBClient.makeWriteApi(); for (int i = 0; i < 10000; i++) { Demo demo = new Demo(); demo.setTime(Instant.now());

       writeApi.writeMeasurement("s100", "d", WritePrecision.NS, demo);
       try {
                Thread.sleep(1);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
    }
    

    } influxdb 安装在虚拟机中 4C16G ,不清楚是自己哪里出了问题

    futaotao5866
        1
    futaotao5866  
    OP
       Nov 28, 2024
    问题已经定位解决,时间问题
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   4176 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 00:06 · PVG 08:06 · LAX 17:06 · JFK 20:06
    ♥ Do have faith in what you're doing.