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)
| 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. |
| 654 | func 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 | |
| 697 | func TestReleaseNoninternedString(t *testing.T) { |
| 698 | for _, protoMsg := range []remoteapi.WriteMessageType{remoteapi.WriteV1MessageType, remoteapi.WriteV2MessageType} { |
nothing calls this directly
no test coverage detected
searching dependent graphs…