Skip to content

Commit

Permalink
[extension/filestorage] use correct bbolt options for compaction (#9134)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikołaj Świątek authored Apr 11, 2022
1 parent 439369e commit 83d292c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
[v0.0.1]: https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/v0.0.1
13 changes: 7 additions & 6 deletions extension/storage/filestorage/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 83d292c

Please sign in to comment.