From f1d18294346b9c93461e32cb8486b34889db663d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20=C5=9Awi=C4=85tek?= Date: Sun, 10 Apr 2022 18:05:08 +0200 Subject: [PATCH] [extension/filestorage] use correct bbolt options for compaction --- CHANGELOG.md | 3 ++- extension/storage/filestorage/client.go | 13 +++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a4250687cf3..10a0f39a62df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ ### 🧰 Bug fixes 🧰 +- `filestorageextension`: use correct bbolt options for compaction (#9134) - `hostmetricsreceiver`: Use cpu times for time delta in cpu.utilization calculation (#8857) - `dynatraceexporter`: Remove overly verbose stacktrace from certain logs (#8989) - `googlecloudexporter`: fix the `exporter.googlecloud.OTLPDirect` fature-gate, which was not applied when the flag was provided (#9116) @@ -2007,4 +2008,4 @@ First release of OpenTelemetry Collector Contrib. [v0.2.7]: https://github.com/open-telemetry/opentelemetry-collector-contrib/compare/v0.2.6...v0.2.7 [v0.2.6]: https://github.com/open-telemetry/opentelemetry-collector-contrib/compare/v0.0.5...v0.2.6 [v0.0.5]: https://github.com/open-telemetry/opentelemetry-collector-contrib/compare/v0.0.1...v0.0.5 -[v0.0.1]: https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/v0.0.1 \ No newline at end of file +[v0.0.1]: https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/v0.0.1 diff --git a/extension/storage/filestorage/client.go b/extension/storage/filestorage/client.go index 09ed200d1922..ff9a2f4d3ce0 100644 --- a/extension/storage/filestorage/client.go +++ b/extension/storage/filestorage/client.go @@ -31,13 +31,17 @@ type fileStorageClient struct { db *bbolt.DB } -func newClient(filePath string, timeout time.Duration) (*fileStorageClient, error) { - options := &bbolt.Options{ +func bboltOptions(timeout time.Duration) *bbolt.Options { + return &bbolt.Options{ Timeout: timeout, NoSync: true, NoFreelistSync: true, FreelistType: bbolt.FreelistMapType, } +} + +func newClient(filePath string, timeout time.Duration) (*fileStorageClient, error) { + options := bboltOptions(timeout) db, err := bbolt.Open(filePath, 0600, options) if err != nil { return nil, err @@ -121,10 +125,7 @@ func (c *fileStorageClient) Compact(ctx context.Context, compactionDirectory str } // use temporary file as compaction target - options := &bbolt.Options{ - Timeout: timeout, - NoSync: true, - } + options := bboltOptions(timeout) // cannot reuse newClient as db shouldn't contain any bucket db, err := bbolt.Open(file.Name(), 0600, options)