MCPcopy
hub / github.com/prometheus/prometheus / TestQueueFilledDeadlock

Function TestQueueFilledDeadlock

storage/remote/queue_manager_test.go:654–695  ·  view source on GitHub ↗

TestQueueFilledDeadlock makes sure the code does not deadlock in the case where a large scrape (> capacity + max samples per send) is appended at the same time as a batch times out according to the batch send deadline.

(t *testing.T)

Source from the content-addressed store, hash-verified

652// where a large scrape (> capacity + max samples per send) is appended at the
653// same time as a batch times out according to the batch send deadline.
654func TestQueueFilledDeadlock(t *testing.T) {
655 for _, protoMsg := range []remoteapi.WriteMessageType{remoteapi.WriteV1MessageType, remoteapi.WriteV2MessageType} {
656 t.Run(fmt.Sprint(protoMsg), func(t *testing.T) {
657 recs := testwal.GenerateRecords(recCase{
658 NoST: protoMsg == remoteapi.WriteV1MessageType, // RW1 does not support ST.
659 Series: 50, SamplesPerSeries: 1,
660 })
661
662 c := NewNopWriteClient()
663
664 cfg := testDefaultQueueConfig()
665 mcfg := config.DefaultMetadataConfig
666 cfg.MaxShards = 1
667 cfg.MaxSamplesPerSend = 10
668 cfg.Capacity = 20
669 flushDeadline := time.Second
670 batchSendDeadline := time.Millisecond
671 cfg.BatchSendDeadline = model.Duration(batchSendDeadline)
672
673 m := newTestQueueManager(t, cfg, mcfg, flushDeadline, c, protoMsg)
674 m.StoreSeries(recs.Series, 0)
675 m.Start()
676 defer m.Stop()
677
678 for range 100 {
679 done := make(chan struct{})
680 go func() {
681 time.Sleep(batchSendDeadline)
682 m.Append(recs.Samples)
683 done <- struct{}{}
684 }()
685 select {
686 case <-done:
687 case <-time.After(2 * time.Second):
688 t.Error("Deadlock between sending and appending detected")
689 pprof.Lookup("goroutine").WriteTo(os.Stdout, 1)
690 t.FailNow()
691 }
692 }
693 })
694 }
695}
696
697func TestReleaseNoninternedString(t *testing.T) {
698 for _, protoMsg := range []remoteapi.WriteMessageType{remoteapi.WriteV1MessageType, remoteapi.WriteV2MessageType} {

Callers

nothing calls this directly

Calls 12

GenerateRecordsFunction · 0.92
NewNopWriteClientFunction · 0.85
testDefaultQueueConfigFunction · 0.85
newTestQueueManagerFunction · 0.85
DurationMethod · 0.80
LookupMethod · 0.80
RunMethod · 0.65
StoreSeriesMethod · 0.65
AppendMethod · 0.65
ErrorMethod · 0.65
StartMethod · 0.45
StopMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…