Skip to content

feat: support partial writes#365

Open
alespour wants to merge 21 commits intomainfrom
feat/partial-writes
Open

feat: support partial writes#365
alespour wants to merge 21 commits intomainfrom
feat/partial-writes

Conversation

@alespour
Copy link
Copy Markdown
Contributor

@alespour alespour commented Mar 10, 2026

Proposed Changes

Adds partial-write support with structured error details in InfluxDBPartialWriteException, including per-line line_number, error_message, and original_line so callers can decide whether to drop/retry/fix specific lines in a batch.

This also aligns write routing with the rollout contract:

  • Default write endpoint is now /api/v3/write_lp
  • acceptPartial defaults to true (server default behavior)
  • accept_partial=false is sent only when partial writes are explicitly disabled
  • New compatibility option useV2Api routes writes to /api/v2/write for Clustered/v2-compatible backends

Configuration surfaces now include:

  • Write option: acceptPartial, useV2Api
  • Client config / connection string keys: writeAcceptPartial, writeUseV2Api
  • Environment variables: INFLUX_WRITE_ACCEPT_PARTIAL, INFLUX_WRITE_USE_V2_API

Validation:

  • useV2Api=true with noSync=true is rejected before request dispatch.

See Partial writes in InfluxDB documentation.

  WriteOptions options = new WriteOptions.Builder().build(); // acceptPartial=true by default

  try {
      client.writeRecord(lp, options);
  } catch (InfluxDBPartialWriteException e) {
      for (InfluxDBPartialWriteException.LineError lineErr : e.lineErrors()) {
          System.out.printf(
                  "line %s failed: %s (%s)%n",
                  lineErr.lineNumber(),
                  lineErr.errorMessage(),
                  lineErr.originalLine()
          );
      }
  } catch (InfluxDBApiHttpException e) {
      System.out.println(e.getMessage());
  }

Optional v2 compatibility mode:

  WriteOptions v2Compat = new WriteOptions.Builder()
          .useV2Api(true)
          .build();

  client.writeRecord(lp, v2Compat);

Checklist

  • CHANGELOG.md updated
  • Rebased/mergeable
  • A test has been added if appropriate
  • Tests pass
  • Commit messages are conventional

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 10, 2026

Codecov Report

❌ Patch coverage is 95.20958% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.19%. Comparing base (73bfd98) to head (e2635b7).

Files with missing lines Patch % Lines
...va/com/influxdb/v3/client/internal/RestClient.java 92.77% 0 Missing and 6 partials ⚠️
...va/com/influxdb/v3/client/config/ClientConfig.java 96.15% 0 Missing and 1 partial ⚠️
...ava/com/influxdb/v3/client/write/WriteOptions.java 96.42% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #365      +/-   ##
==========================================
+ Coverage   87.90%   88.19%   +0.29%     
==========================================
  Files          20       21       +1     
  Lines        1397     1525     +128     
  Branches      241      275      +34     
==========================================
+ Hits         1228     1345     +117     
- Misses         81       82       +1     
- Partials       88       98      +10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@alespour alespour marked this pull request as ready for review March 10, 2026 09:55
@alespour alespour requested a review from Copilot March 10, 2026 09:56
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for InfluxDB 3 “partial writes” by introducing an acceptPartial write option (and corresponding config/env keys) and surfacing parsed, line-level write errors through a dedicated exception type.

Changes:

  • Add acceptPartial to WriteOptions and ClientConfig (incl. connection string, env, and system properties support).
  • Parse v3 write error responses to expose line-level error details via InfluxDBPartialWriteException.
  • Add/extend unit + integration tests and update README/CHANGELOG documentation.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/main/java/com/influxdb/v3/client/write/WriteOptions.java Adds acceptPartial option, builder support, safe accessor, and equality/hash updates.
src/main/java/com/influxdb/v3/client/config/ClientConfig.java Adds writeAcceptPartial config with parsing from connection string/env/system properties.
src/main/java/com/influxdb/v3/client/internal/InfluxDBClientImpl.java Uses v3 write endpoint when noSync or acceptPartial is enabled; adds accept_partial query param.
src/main/java/com/influxdb/v3/client/internal/RestClient.java Parses response bodies for line-level write errors and throws a structured partial-write exception.
src/main/java/com/influxdb/v3/client/InfluxDBPartialWriteException.java New exception type to expose line-level write failures to callers.
src/main/java/com/influxdb/v3/client/InfluxDBClient.java Documents the new config/env/system property key in client factory docs.
src/test/java/com/influxdb/v3/client/write/WriteOptionsTest.java Extends WriteOptions tests for equality/hash and config override behavior of acceptPartial.
src/test/java/com/influxdb/v3/client/config/ClientConfigTest.java Extends config parsing/toString/equality tests for writeAcceptPartial.
src/test/java/com/influxdb/v3/client/internal/RestClientTest.java Adds assertions around structured partial-write parsing and fallback behavior.
src/test/java/com/influxdb/v3/client/InfluxDBClientWriteTest.java Adds request-shape tests for accept_partial and v3/v2 behavior.
src/test/java/com/influxdb/v3/client/integration/E2ETest.java Adds E2E validation for accept-partial error handling and exception typing.
README.md Documents how to use acceptPartial and inspect InfluxDBPartialWriteException details.
CHANGELOG.md Adds changelog entry for partial write support.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/main/java/com/influxdb/v3/client/internal/RestClient.java
Comment thread src/main/java/com/influxdb/v3/client/internal/RestClient.java Outdated
Comment thread src/main/java/com/influxdb/v3/client/internal/InfluxDBClientImpl.java Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/main/java/com/influxdb/v3/client/internal/RestClient.java Outdated
Comment thread src/test/java/com/influxdb/v3/client/integration/E2ETest.java
Comment thread src/test/java/com/influxdb/v3/client/integration/E2ETest.java Outdated
@alespour alespour marked this pull request as draft March 17, 2026 09:17
@alespour alespour force-pushed the feat/partial-writes branch from 8bc0938 to f946fdb Compare April 20, 2026 12:44
@alespour alespour marked this pull request as ready for review April 20, 2026 14:12
@alespour alespour requested a review from Copilot April 20, 2026 14:12
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/main/java/com/influxdb/v3/client/internal/RestClient.java
Comment thread src/main/java/com/influxdb/v3/client/write/WriteOptions.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants