Skip to content

Commit

Permalink
fix(influxdb): Modify influxDbWriter to address the memory issue (#986)
Browse files Browse the repository at this point in the history
During JVM profiling, I noticed the memory usage of the influxdb sink connector consistently increasing. Investigation revealed that the influxDbWriter wasn't closing properly, leading to the memory issue.

Co-authored-by: Omal <[email protected]>
  • Loading branch information
OmalCooray and Omal authored Sep 18, 2023
1 parent 81385c1 commit e8f6897
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,14 @@ class InfluxDbWriter(settings: InfluxSettings) extends DbWriter with StrictLoggi
.build(records)
.flatMap { batchPoints =>
logger.debug(s"Writing ${batchPoints.length} points to the database...")
for {
writer <- Try(influxDB.makeWriteApi())
writeRes <- Try(writer.writePoints(batchPoints.asJava))
} yield writeRes
}.map(_ => logger.debug("Writing complete")),
val writer = influxDB.makeWriteApi()
val writeAttempt = Try {
writer.writePoints(batchPoints.asJava)
}
writer.close()
writeAttempt
}
.map(_ => logger.debug("Writing complete")),
)
}

Expand Down

0 comments on commit e8f6897

Please sign in to comment.