Skip to content

Commit

Permalink
Fixed windows compatibility issue, when storage gateway syncs index f…
Browse files Browse the repository at this point in the history
…iles to local disk.

Signed-off-by: henrikschristensen <51989221+henrikschristensen@users.noreply.github.com>
  • Loading branch information
henrikschristensen committed Feb 19, 2024
1 parent 70c8eb6 commit 70da760
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -12,6 +12,7 @@ We use *breaking :warning:* to mark changes that are not backward compatible (re

### Fixed

- [#7148](https://github.com/thanos-io/thanos/pull/7148) Store Gateway: Fix windows compatibility in index-header sync.
- [#7083](https://github.com/thanos-io/thanos/pull/7083) Store Gateway: Fix lazy expanded postings with 0 length failed to be cached.
- [#7080](https://github.com/thanos-io/thanos/pull/7080) Receive: race condition in handler Close() when stopped early
- [#7132](https://github.com/thanos-io/thanos/pull/7132) Documentation: fix broken helm installation instruction
Expand Down
5 changes: 4 additions & 1 deletion pkg/block/indexheader/binary_reader.go
Expand Up @@ -13,6 +13,7 @@ import (
"io"
"math"
"os"
"path"
"path/filepath"
"sort"
"sync"
Expand Down Expand Up @@ -154,6 +155,8 @@ func WriteBinary(ctx context.Context, bkt objstore.BucketReader, id ulid.ULID, f
}

if tmpFilename != "" {
// On windows renaming an open file will result in access denied error
bw.writer.Close()
// Create index-header in atomic way, to avoid partial writes (e.g during restart or crash of store GW).
return nil, os.Rename(tmpFilename, filename)
}
Expand All @@ -170,7 +173,7 @@ type chunkedIndexReader struct {
}

func newChunkedIndexReader(ctx context.Context, bkt objstore.BucketReader, id ulid.ULID) (*chunkedIndexReader, int, error) {
indexFilepath := filepath.Join(id.String(), block.IndexFilename)
indexFilepath := path.Join(id.String(), block.IndexFilename)
attrs, err := bkt.Attributes(ctx, indexFilepath)
if err != nil {
return nil, 0, errors.Wrapf(err, "get object attributes of %s", indexFilepath)
Expand Down

0 comments on commit 70da760

Please sign in to comment.