Skip to content

fix(outputs.parquet): Rotate on the age of the open file - #19559

Merged
skartikey merged 1 commit into
influxdata:masterfrom
81reap:parquet-08-rotate-on-file-age
Sep 21, 2026
Merged

skartikey merged 1 commit into
influxdata:masterfrom
81reap:parquet-08-rotate-on-file-age

Conversation

@81reap

@81reap 81reap commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Rotation compared against the file's modification time via os.Stat on every flush. Since the plugin writes through a buffered writer, the modification time only moves when the writer actually flushes to disk, so on a quiet stream it can sit unchanged until Close and push the rotation out.

If the file was removed underneath the agent, the stat failed and the metrics of that flush were rejected.

Now Telegraf records when the file was opened and rotates on that.

Checklist

Related issues

@telegraf-tiger telegraf-tiger Bot added fix pr to fix corresponding bug plugin/output 1. Request for new output plugins 2. Issues/PRs that are related to out plugins labels Aug 26, 2026
@81reap
81reap force-pushed the parquet-08-rotate-on-file-age branch 2 times, most recently from 40d151d to 12e2455 Compare September 6, 2026 05:08
@81reap
81reap marked this pull request as ready for review September 6, 2026 05:44

@srebhan srebhan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @81reap!

@srebhan srebhan added the ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review. label Sep 7, 2026
Comment thread plugins/outputs/parquet/parquet_test.go Outdated
Comment thread plugins/outputs/parquet/parquet.go Outdated
@81reap
81reap force-pushed the parquet-08-rotate-on-file-age branch from 12e2455 to e6b4a4e Compare September 8, 2026 03:53
@skartikey

Copy link
Copy Markdown
Contributor

@81reap #19560 is merged and this one now conflicts in parquet_test.go: both branches append tests at the end of the file, so keeping both sides resolves it. Please rebase onto master, and while you're there the description still needs the two corrections from my earlier comment (the mtime does not move until Close with buffered writes, and the stat error was a per-flush reject rather than a re-queue), since it becomes the commit message.

@81reap

81reap commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

i was mulling over your comments last night and i discovered that Telegraf already has the file rotation semantics for streamable files here (although it may be for logs, i still need to dig a little deeper after work)

https://github.com/influxdata/telegraf/blob/master/internal/rotate/file_writer.go

i'm also now questioning if this PR is the best way to solve for this. seems like file rotation should be a common module or design pattern that the rest of the application adopts when it needs it. that way we can standardise fixes for the edge cases you and I are calling out across the whole service

Comment thread plugins/outputs/parquet/README.md
Comment thread plugins/outputs/parquet/parquet_test.go Outdated
@skartikey

Copy link
Copy Markdown
Contributor

i was mulling over your comments last night and i discovered that Telegraf already has the file rotation semantics for streamable files here (although it may be for logs, i still need to dig a little deeper after work)

https://github.com/influxdata/telegraf/blob/master/internal/rotate/file_writer.go

i'm also now questioning if this PR is the best way to solve for this. seems like file rotation should be a common module or design pattern that the rest of the application adopts when it needs it. that way we can standardise fixes for the edge cases you and I are calling out across the whole service

internal/rotate won't fit here. It's an io.WriteCloser that rotates by renaming the file out from under a live byte stream, which only works for a format where any offset is a valid cut point. Parquet isn't one, the footer and metadata are written on Close, so renaming underneath the pqarrow writer leaves one file with no footer and one whose footer describes rows it doesn't have. That's why the plugin closes the writer and opens a new one instead.

There is a real shared concern in there (age tracking, the deleted-file case, archive limits) but a common module would have to be about lifecycle policy rather than the byte stream, and I'd rather not hold this fix for that. Happy to keep it narrow: rebase on #19558 once that lands and this one stays a small, correct fix.

@81reap
81reap force-pushed the parquet-08-rotate-on-file-age branch 2 times, most recently from 1dea414 to f206e51 Compare September 11, 2026 21:10
Comment thread plugins/outputs/parquet/parquet_test.go Outdated
Currently rotation compared against the file's modification time via os.Stat on every flush. Since plugins write through a buffered writer, file modificaiton time gets updated with every system flush.

If the file was removed underneath the agent, then the write would error and re-queue causing a sall in the pipeline.

Now telegraf records when the file was opned and rotates on that.
@81reap
81reap force-pushed the parquet-08-rotate-on-file-age branch from f206e51 to 985b551 Compare September 19, 2026 22:18
@telegraf-tiger

Copy link
Copy Markdown
Contributor

Download PR build artifacts for linux_amd64.tar.gz, darwin_arm64.tar.gz, and windows_amd64.zip.
Downloads for additional architectures and packages are available below.

⚠️ This pull request increases the Telegraf binary size by 6.33 % for linux amd64 (new size: 327.7 MB, nightly size 308.2 MB)

📦 Click here to get additional PR build artifacts

Artifact URLs

. DEB . RPM . TAR . GZ . ZIP
amd64.deb aarch64.rpm darwin_amd64.tar.gz windows_amd64.zip
arm64.deb armel.rpm darwin_arm64.tar.gz windows_arm64.zip
armel.deb armv6hl.rpm freebsd_amd64.tar.gz windows_i386.zip
armhf.deb i386.rpm freebsd_armv7.tar.gz
i386.deb ppc64le.rpm freebsd_i386.tar.gz
mips.deb riscv64.rpm linux_amd64.tar.gz
mipsel.deb s390x.rpm linux_arm64.tar.gz
ppc64el.deb x86_64.rpm linux_armel.tar.gz
riscv64.deb linux_armhf.tar.gz
s390x.deb linux_i386.tar.gz
linux_mips.tar.gz
linux_mipsel.tar.gz
linux_ppc64le.tar.gz
linux_riscv64.tar.gz
linux_s390x.tar.gz

@skartikey skartikey left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@81reap Thanks for the contribution!

@skartikey
skartikey merged commit 88c121b into influxdata:master Sep 21, 2026
29 checks passed
@github-actions github-actions Bot added this to the v1.40.1 milestone Sep 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix pr to fix corresponding bug plugin/output 1. Request for new output plugins 2. Issues/PRs that are related to out plugins ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants