Skip to content

WriteAPI.Flush doesn't do what's expected #289

Open
@pabigot

Description

@pabigot

Steps to reproduce:

  1. Start a loop writing data once per second, with a WriteFailedCallback that detects loss of connection, prevents new data from being added, and tells the infrastructure to retry the send of data it's already been given.
  2. Restart the influxdb process, which causes a transient failure
  3. Logic in the application checks the client Ready/Health status and verifies that the server is back up, and re-enables writing after invoking w.Flush() to first send what's already queued.

Expected behavior:

Upon flush the pending data from queued retries will be written to the server and new data will be promptly written as specified by the FlushInterval.

Actual behavior:

New data is queued in individual batches until the original retryDelay elapses, possibly causing data loss when the number of queued batches exceeds RetryBufferLimit / RetryBatchSize (10 by default).

pre write 11 ... past write 11
2021/12/13 09:43:42.876083 influxdb2client I! sending batch
2021/12/13 09:43:42.878517 influxdb2client E! Write error: Post "http://tirzah.pab:8086/api/v2/write?bucket=sandbox&org=green-tirzah&precision=us": dial tcp 192.168.65.21:8086: connect: connection refused
Batch kept for retrying
2021/12/13 09:43:42.878537 Write failed: 0, counter,id=HACK/influx.go:2021-12-13T09:43:32 counter=10i 1639413821630922
: Post "http://tirzah.pab:8086/api/v2/write?bucket=sandbox&org=green-tirzah&precision=us": dial tcp 192.168.65.21:8086: connect: connection refused
2021/12/13 09:43:42.878544 influxdb2client D! Write proc: next wait for write is 8081ms
2021/12/13 09:43:42.878562 influxdb2client D! Write proc: received write request
2021/12/13 09:43:42.878569 influxdb2client D! Write proc: taking batch from retry queue
2021/12/13 09:43:42.878572 influxdb2client W! Write proc: cannot write yet, storing batch to queue
2021/12/13 09:43:42.878596 WriteError: *fmt.wrapError write failed (attempts 1): Post "http://tirzah.pab:8086/api/v2/write?bucket=sandbox&org=green-tirzah&precision=us": dial tcp 192.168.65.21:8086: connect: connection refused true
2021/12/13 09:43:43.631849 influxdb2client I! HTTP GET req to http://tirzah.pab:8086/health
Status: &domain.HealthCheck{
    Checks: &[]domain.HealthCheck{
    },
    Commit:  &"657e1839de",
    Message: &"ready for queries and writes",
    Name:    "influxdb",
    Status:  "pass",
    Version: &"2.1.1",
}
Past flush
pre write 12 ... past write 12
2021/12/13 09:43:43.875926 influxdb2client I! sending batch
2021/12/13 09:43:43.875953 influxdb2client D! Write proc: received write request
2021/12/13 09:43:43.875957 influxdb2client D! Write proc: taking batch from retry queue
2021/12/13 09:43:43.875962 influxdb2client W! Write proc: cannot write yet, storing batch to queue
pre write 13 ... past write 13
2021/12/13 09:43:44.876353 influxdb2client I! sending batch
2021/12/13 09:43:44.876390 influxdb2client D! Write proc: received write request
2021/12/13 09:43:44.876394 influxdb2client D! Write proc: taking batch from retry queue
2021/12/13 09:43:44.876398 influxdb2client W! Write proc: cannot write yet, storing batch to queue
pre write 14 ... past write 14
2021/12/13 09:43:45.876116 influxdb2client I! sending batch
2021/12/13 09:43:45.876153 influxdb2client D! Write proc: received write request
2021/12/13 09:43:45.876167 influxdb2client D! Write proc: taking batch from retry queue
2021/12/13 09:43:45.876175 influxdb2client W! Write proc: cannot write yet, storing batch to queue

Specifications:

  • Client Version: 2.6.0
  • InfluxDB Version: 2.1.1
  • Platform: Linux go 1.17

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions