influxdata / influxdata/influxdb-java

Influx db java client batch does not write to DB

Open
#378 20 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

help wanted kind/bug
Dominant language
Java
Stars
1.2k
Forks
469
PR merge metrics
No merged PRs in 30d

Description

I am trying to write points to influxDB using their Java client.
Batch is important to me.

If I use the influxDB.enableBatch with influxDB.write(Point) no data is inserted.
If I use the BatchPoints and influxDB.write(batchPoints) - data is inserted successfully.

Both code samples are taken from: https://github.com/influxdata/influxdb-java/tree/influxdb-java-2.7

    InfluxDB influxDB = InfluxDBFactory.connect(influxUrl, influxUser, influxPassword);
    influxDB.setDatabase(dbName);
    influxDB.setRetentionPolicy("autogen");

    // Flush every 2000 Points, at least every 100ms
    influxDB.enableBatch(2000, 100, TimeUnit.MILLISECONDS);
    influxDB.write(Point.measurement("cpu")
            .time(System.currentTimeMillis(), TimeUnit.MILLISECONDS)
            .addField("idle", 90L)
            .addField("user", 9L)
            .addField("system", 1L)
            .build());

    Query query = new Query("SELECT idle FROM cpu", dbName);
    QueryResult result = influxDB.query(query);

Returns nothing.

    BatchPoints batchPoints = BatchPoints.database(dbName).tag("async", "true").build();
    Point point1 = Point
            .measurement("cpu")
            .tag("atag", "test")
            .addField("idle", 90L)
            .addField("usertime", 9L)
            .addField("system", 1L)
            .build();
    batchPoints.point(point1);
    influxDB.write(batchPoints);
    Query query = new Query("SELECT * FROM cpu ", dbName);
    QueryResult result = influxDB.query(query);

This returns data successfully.

As mentioned, I need the first way to function.
How can I achieve that?

versions:
influxdb-1.3.6
influxdb-java:2.7

Thanks

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Java client's enableBatch path and reproduce the first code sample against InfluxDB 1.3.6, then compare its behavior with the working BatchPoints sample. Verify the fix by confirming that a point written through enableBatch is returned by the provided query after the batch flush interval.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.