loki4j / loki-logback-appender

Fast and lightweight implementation of Logback appender for Grafana Loki
https://loki4j.github.io/loki-logback-appender/
BSD 2-Clause "Simplified" License
314 stars 27 forks source link

Sometime log may have a unvalid unicode string, runEncodeLoop will enter dead loop #161

Closed Asa-Dong closed 1 year ago

Asa-Dong commented 1 year ago

https://github.com/loki4j/loki-logback-appender/blob/f1c533ef0992f241501e5368c78575a65c2d4488/loki-client/src/main/java/com/github/loki4j/pkg/dslplatform/json/RawJsonWriter.java#L295

https://github.com/loki4j/loki-logback-appender/blob/fb4ad04bab31dd41614b0b07fc7a3817929138c8/loki-client/src/main/java/com/github/loki4j/client/pipeline/DefaultPipeline.java#L244


error info

16:11:33,379 |-ERROR in com.github.loki4j.client.pipeline.DefaultPipeline@78e2ac5a - Error occurred while serializing batch #1d20c881334a0 (DRAIN, 23 records, 7 streams, est. size 9,025 bytes) java.lang.IllegalArgumentException: Unknown unicode codepoint in string! d83d
    at java.lang.IllegalArgumentException: Unknown unicode codepoint in string! d83d
    at  at com.github.loki4j.pkg.dslplatform.json.RawJsonWriter.writeQuotedString(RawJsonWriter.java:295)
    at  at com.github.loki4j.pkg.dslplatform.json.RawJsonWriter.writeString(RawJsonWriter.java:122)
    at  at com.github.loki4j.client.writer.JsonWriter.record(JsonWriter.java:100)
    at  at com.github.loki4j.client.writer.JsonWriter.stream(JsonWriter.java:74)
    at  at com.github.loki4j.client.writer.JsonWriter.nextStream(JsonWriter.java:62)
    at  at com.github.loki4j.client.writer.JsonWriter.serializeBatch(JsonWriter.java:25)
    at  at com.github.loki4j.client.pipeline.DefaultPipeline.writeBatch(DefaultPipeline.java:227)
    at  at com.github.loki4j.client.pipeline.DefaultPipeline.encodeStep(DefaultPipeline.java:208)
    at  at com.github.loki4j.client.pipeline.DefaultPipeline.runEncodeLoop(DefaultPipeline.java:173)
    at  at com.github.loki4j.client.pipeline.DefaultPipeline.lambda$start$3(DefaultPipeline.java:111)
    at  at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at  at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at  at java.base/java.lang.Thread.run(Thread.java:833)
16:11:35,755 |-ERROR in com.github.loki4j.client.pipeline.DefaultPipeline@78e2ac5a - Error occurred while serializing batch #1d20c881334a0 (DRAIN, 23 records, 7 streams, est. size 9,025 bytes) java.lang.IllegalArgumentException: Unknown unicode codepoint in string! d83d
    at java.lang.IllegalArgumentException: Unknown unicode codepoint in string! d83d
    at  at com.github.loki4j.pkg.dslplatform.json.RawJsonWriter.writeQuotedString(RawJsonWriter.java:295)
    at  at com.github.loki4j.pkg.dslplatform.json.RawJsonWriter.writeString(RawJsonWriter.java:122)
    at  at com.github.loki4j.client.writer.JsonWriter.record(JsonWriter.java:100)
    at  at com.github.loki4j.client.writer.JsonWriter.stream(JsonWriter.java:74)
    at  at com.github.loki4j.client.writer.JsonWriter.nextStream(JsonWriter.java:62)
    at  at com.github.loki4j.client.writer.JsonWriter.serializeBatch(JsonWriter.java:25)
    at  at com.github.loki4j.client.pipeline.DefaultPipeline.writeBatch(DefaultPipeline.java:227)
    at  at com.github.loki4j.client.pipeline.DefaultPipeline.encodeStep(DefaultPipeline.java:208)
    at  at com.github.loki4j.client.pipeline.DefaultPipeline.runEncodeLoop(DefaultPipeline.java:173)
    at  at com.github.loki4j.client.pipeline.DefaultPipeline.lambda$start$3(DefaultPipeline.java:111)
    at  at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at  at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at  at java.base/java.lang.Thread.run(Thread.java:833)
.....

--

Tks, best wishes

nehaev commented 1 year ago

Hi @Asa-Dong. Thanks for reporting this! I was able to reproduce the issue, it will be fixed shortly.