Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade prometheus to latest main #5593

Merged
merged 11 commits into from
Oct 11, 2023

Conversation

yeya24
Copy link
Contributor

@yeya24 yeya24 commented Oct 7, 2023

What this PR does:

Upgrade Prometheus and Thanos library to latest main.

Which issue(s) this PR fixes:
Fixes #

Checklist

  • Tests updated
  • Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

Signed-off-by: Ben Ye <[email protected]>
yeya24 added 6 commits October 6, 2023 23:40
Signed-off-by: Ben Ye <[email protected]>
Signed-off-by: Ben Ye <[email protected]>
Signed-off-by: Ben Ye <[email protected]>
Signed-off-by: Ben Ye <[email protected]>
Signed-off-by: Ben Ye <[email protected]>
@yeya24
Copy link
Contributor Author

yeya24 commented Oct 7, 2023

==================
WARNING: DATA RACE
Read at 0x00c00161f2b8 by goroutine 41154:
  github.com/thanos-io/thanos/pkg/block/indexheader.(*parallelBucketReader).GetRange.func1()
      /__w/cortex/cortex/vendor/github.com/thanos-io/thanos/pkg/block/indexheader/parallel_bucket.go:73 +0x324
  golang.org/x/sync/errgroup.(*Group).Go.func1()
      /__w/cortex/cortex/vendor/golang.org/x/sync/errgroup/errgroup.go:75 +0x82

Previous write at 0x00c00161f2b8 by goroutine 41066:
  github.com/thanos-io/thanos/pkg/block/indexheader.(*parallelBucketReader).GetRange()
      /__w/cortex/cortex/vendor/github.com/thanos-io/thanos/pkg/block/indexheader/parallel_bucket.go:80 +0x25c
  github.com/thanos-io/thanos/pkg/block/indexheader.(*chunkedIndexReader).CopySymbols()
      /__w/cortex/cortex/vendor/github.com/thanos-io/thanos/pkg/block/indexheader/binary_reader.go:220 +0x1d4
  github.com/thanos-io/thanos/pkg/block/indexheader.WriteBinary()
      /__w/cortex/cortex/vendor/github.com/thanos-io/thanos/pkg/block/indexheader/binary_reader.go:104 +0x404
  github.com/thanos-io/thanos/pkg/block/indexheader.NewBinaryReader()
      /__w/cortex/cortex/vendor/github.com/thanos-io/thanos/pkg/block/indexheader/binary_reader.go:546 +0x506
  github.com/thanos-io/thanos/pkg/block/indexheader.(*ReaderPool).NewBinaryReader()
      /__w/cortex/cortex/vendor/github.com/thanos-io/thanos/pkg/block/indexheader/reader_pool.go:89 +0x21a
  github.com/thanos-io/thanos/pkg/store.(*BucketStore).addBlock()
      /__w/cortex/cortex/vendor/github.com/thanos-io/thanos/pkg/store/bucket.go:744 +0x747
  github.com/thanos-io/thanos/pkg/store.(*BucketStore).SyncBlocks.func1()
      /__w/cortex/cortex/vendor/github.com/thanos-io/thanos/pkg/store/bucket.go:621 +0x7b

Goroutine 41154 (running) created at:
  golang.org/x/sync/errgroup.(*Group).Go()
      /__w/cortex/cortex/vendor/golang.org/x/sync/errgroup/errgroup.go:72 +0x12e
  github.com/thanos-io/thanos/pkg/block/indexheader.(*parallelBucketReader).GetRange()
      /__w/cortex/cortex/vendor/github.com/thanos-io/thanos/pkg/block/indexheader/parallel_bucket.go:69 +0x236
  github.com/thanos-io/thanos/pkg/block/indexheader.(*chunkedIndexReader).CopySymbols()
      /__w/cortex/cortex/vendor/github.com/thanos-io/thanos/pkg/block/indexheader/binary_reader.go:220 +0x1d4
  github.com/thanos-io/thanos/pkg/block/indexheader.WriteBinary()
      /__w/cortex/cortex/vendor/github.com/thanos-io/thanos/pkg/block/indexheader/binary_reader.go:104 +0x404
  github.com/thanos-io/thanos/pkg/block/indexheader.NewBinaryReader()
      /__w/cortex/cortex/vendor/github.com/thanos-io/thanos/pkg/block/indexheader/binary_reader.go:546 +0x506
  github.com/thanos-io/thanos/pkg/block/indexheader.(*ReaderPool).NewBinaryReader()
      /__w/cortex/cortex/vendor/github.com/thanos-io/thanos/pkg/block/indexheader/reader_pool.go:89 +0x21a
  github.com/thanos-io/thanos/pkg/store.(*BucketStore).addBlock()
      /__w/cortex/cortex/vendor/github.com/thanos-io/thanos/pkg/store/bucket.go:744 +0x747
  github.com/thanos-io/thanos/pkg/store.(*BucketStore).SyncBlocks.func1()
      /__w/cortex/cortex/vendor/github.com/thanos-io/thanos/pkg/store/bucket.go:621 +0x7b

Goroutine 41066 (running) created at:
  github.com/thanos-io/thanos/pkg/store.(*BucketStore).SyncBlocks()
      /__w/cortex/cortex/vendor/github.com/thanos-io/thanos/pkg/store/bucket.go:619 +0x126
  github.com/cortexproject/cortex/pkg/storegateway.(*BucketStores).SyncBlocks.func1()
      /__w/cortex/cortex/pkg/storegateway/bucket_stores.go:171 +0x44
  github.com/cortexproject/cortex/pkg/storegateway.(*BucketStores).syncUsersBlocks.func2()
      /__w/cortex/cortex/pkg/storegateway/bucket_stores.go:242 +0x17c
==================
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0xba8a07]

goroutine 4[112](https://github.com/cortexproject/cortex/actions/runs/6443194007/job/17494849155?pr=5593#step:6:113)9 [running]:
github.com/thanos-io/thanos/pkg/runutil.CloseWithErrCapture(0xc00104dee8, {0x0, 0x0}, {0x27d1e4b, 0xc}, {0x0, 0x0, 0x0})
	/__w/cortex/cortex/vendor/github.com/thanos-io/thanos/pkg/runutil/runutil.go:[144](https://github.com/cortexproject/cortex/actions/runs/6443194007/job/17494849155?pr=5593#step:6:145) +0x307
github.com/thanos-io/thanos/pkg/block/indexheader.(*parallelBucketReader).GetRange.func1()
	/__w/cortex/cortex/vendor/github.com/thanos-io/thanos/pkg/block/indexheader/parallel_bucket.go:73 +0x3a6
golang.org/x/sync/errgroup.(*Group).Go.func1()
	/__w/cortex/cortex/vendor/golang.org/x/sync/errgroup/errgroup.go:75 +0x83
created by golang.org/x/sync/errgroup.(*Group).Go
	/__w/cortex/cortex/vendor/golang.org/x/sync/errgroup/errgroup.go:72 +0x12f
FAIL	github.com/cortexproject/cortex/pkg/storegateway	215.222s

Both issues should be fixed by thanos-io/thanos#6781

@yeya24
Copy link
Contributor Author

yeya24 commented Oct 7, 2023

	partId := 0
	for o := off; o < off+length; o += b.partitionSize {
		l := b.partitionSize
		if o+l > off+length {
			// Partial partition
			l = length - (int64(partId) * b.partitionSize)
		}

		partOff := o
		partLength := l
		part, err := b.createPart(partFilePrefix, partId, int(partLength))
		if err != nil {
			return nil, err
		}
		parts = append(parts, part)

		g.Go(func() error {
			rc, err := b.BucketReader.GetRange(gctx, name, partOff, partLength)
			defer runutil.CloseWithErrCapture(&err, rc, "close object")
			if err != nil {
				return errors.Wrap(err, fmt.Sprintf("get range part %v", partId))
			}
			if _, err := io.Copy(part, rc); err != nil {
				return errors.Wrap(err, fmt.Sprintf("get range part %v", partId))
			}
			return part.Flush()
		})
		partId += 1
	}

Looks like the issue is the partId here. We might read it inside the goroutine but change it outside the goroutine.

@yeya24 yeya24 marked this pull request as ready for review October 8, 2023 02:47
@yeya24 yeya24 requested review from alanprot and friedrichg October 8, 2023 02:47
Copy link
Member

@friedrichg friedrichg left a comment

Choose a reason for hiding this comment

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

So help me God

@yeya24
Copy link
Contributor Author

yeya24 commented Oct 10, 2023

Sorry for the large pr folks... I want to wait for a few days before merging it. Still need to figure out whether the new warnings affect us or not

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants