+
Skip to content

InfluxDB rejects write with field type mismatch #441

@wecassidy

Description

@wecassidy

If a logged parameter initially has an integer value and later changes to float, that will cause InfluxDB to reject all subsequent writes including that value. This is the error message in the linien-server log:

Jun 12 17:05:52 rp-f0ca2d env[14650]: linien_server.server           INFO     Starting logging
Jun 12 17:05:52 rp-f0ca2d env[14650]: Exception in thread Thread-10 (_logging_loop):
Jun 12 17:05:52 rp-f0ca2d env[14650]: Traceback (most recent call last):
Jun 12 17:05:52 rp-f0ca2d env[14650]:   File "/usr/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
Jun 12 17:05:52 rp-f0ca2d env[14650]:     self.run()
Jun 12 17:05:52 rp-f0ca2d env[14650]:   File "/usr/lib/python3.10/threading.py", line 953, in run
Jun 12 17:05:52 rp-f0ca2d env[14650]:     self._target(*self._args, **self._kwargs)
Jun 12 17:05:52 rp-f0ca2d env[14650]:   File "/usr/local/lib/python3.10/dist-packages/linien_server/influxdb.py", line 83, in _logging_loop
Jun 12 17:05:52 rp-f0ca2d env[14650]:     self.write_data(self.credentials, data)
Jun 12 17:05:52 rp-f0ca2d env[14650]:   File "/usr/local/lib/python3.10/dist-packages/linien_server/influxdb.py", line 120, in write_data
Jun 12 17:05:52 rp-f0ca2d env[14650]:     self.write_api.write(
Jun 12 17:05:52 rp-f0ca2d env[14650]:   File "/usr/local/lib/python3.10/dist-packages/influxdb_client/client/write_api.py", line 381, in write
Jun 12 17:05:52 rp-f0ca2d env[14650]:     results = list(map(write_payload, payloads.items()))
Jun 12 17:05:52 rp-f0ca2d env[14650]:   File "/usr/local/lib/python3.10/dist-packages/influxdb_client/client/write_api.py", line 379, in write_payload
Jun 12 17:05:52 rp-f0ca2d env[14650]:     return self._post_write(_async_req, bucket, org, final_string, payload[0])
Jun 12 17:05:52 rp-f0ca2d env[14650]:   File "/usr/local/lib/python3.10/dist-packages/influxdb_client/client/write_api.py", line 516, in _post_write
Jun 12 17:05:52 rp-f0ca2d env[14650]:     return self._write_service.post_write(org=org, bucket=bucket, body=body, precision=precision,
Jun 12 17:05:52 rp-f0ca2d env[14650]:   File "/usr/local/lib/python3.10/dist-packages/influxdb_client/service/write_service.py", line 60, in post_write
Jun 12 17:05:52 rp-f0ca2d env[14650]:     (data) = self.post_write_with_http_info(org, bucket, body, **kwargs)  # noqa: E501
Jun 12 17:05:52 rp-f0ca2d env[14650]:   File "/usr/local/lib/python3.10/dist-packages/influxdb_client/service/write_service.py", line 90, in post_write_with_http_info
Jun 12 17:05:52 rp-f0ca2d env[14650]:     return self.api_client.call_api(
Jun 12 17:05:52 rp-f0ca2d env[14650]:   File "/usr/local/lib/python3.10/dist-packages/influxdb_client/_sync/api_client.py", line 343, in call_api
Jun 12 17:05:52 rp-f0ca2d env[14650]:     return self.__call_api(resource_path, method,
Jun 12 17:05:52 rp-f0ca2d env[14650]:   File "/usr/local/lib/python3.10/dist-packages/influxdb_client/_sync/api_client.py", line 173, in __call_api
Jun 12 17:05:52 rp-f0ca2d env[14650]:     response_data = self.request(
Jun 12 17:05:52 rp-f0ca2d env[14650]:   File "/usr/local/lib/python3.10/dist-packages/influxdb_client/_sync/api_client.py", line 388, in request
Jun 12 17:05:52 rp-f0ca2d env[14650]:     return self.rest_client.POST(url,
Jun 12 17:05:52 rp-f0ca2d env[14650]:   File "/usr/local/lib/python3.10/dist-packages/influxdb_client/_sync/rest.py", line 311, in POST
Jun 12 17:05:52 rp-f0ca2d env[14650]:     return self.request("POST", url,
Jun 12 17:05:52 rp-f0ca2d env[14650]:   File "/usr/local/lib/python3.10/dist-packages/influxdb_client/_sync/rest.py", line 261, in request
Jun 12 17:05:52 rp-f0ca2d env[14650]:     raise ApiException(http_resp=r)
Jun 12 17:05:52 rp-f0ca2d env[14650]: influxdb_client.rest.ApiException: (422)
Jun 12 17:05:52 rp-f0ca2d env[14650]: Reason: Unprocessable Entity
Jun 12 17:05:52 rp-f0ca2d env[14650]: HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json; charset=utf-8', 'X-Influxdb-Build': 'OSS', 'X-Influxdb-Version': 'v2.7.11', 'X-Platform-Error-Code': 'unprocessable entity', 'Date': 'Thu, 12 Jun 2025 17:05:54 GMT', 'Content-Length': '232'})
Jun 12 17:05:52 rp-f0ca2d env[14650]: HTTP response body: {"code":"unprocessable entity","message":"failure writing points to database: partial write: field type conflict: input field \"sweep_center\" on measurement \"780 MTS lock\" is type float, already exists as type integer dropped=1"}

In my case sweep_center was 0 when I started logging for the first time. When I changed the sweep parameters logging started failing. Excluding sweep_center and sweep_amplitude from the logged parameters and restarting logging fixes the error.

I think the way to fix this is to make sure all fields are explicitly logged as the correct type from the beginning.

I am running linien v2.1.0 and InfluxDB v2.7.11.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载