Checks if TSDB can be closed.
(idleTimeout time.Duration)
| 668 | |
| 669 | // Checks if TSDB can be closed. |
| 670 | func (u *userTSDB) shouldCloseTSDB(idleTimeout time.Duration) tsdbCloseCheckResult { |
| 671 | if u.deletionMarkFound.Load() { |
| 672 | return tsdbTenantMarkedForDeletion |
| 673 | } |
| 674 | |
| 675 | if !u.isIdle(time.Now(), idleTimeout) { |
| 676 | return tsdbNotIdle |
| 677 | } |
| 678 | |
| 679 | // If head is not compacted, we cannot close this yet. |
| 680 | if u.Head().NumSeries() > 0 { |
| 681 | return tsdbNotCompacted |
| 682 | } |
| 683 | |
| 684 | // Ensure that all blocks have been shipped. |
| 685 | if oldest := u.getOldestUnshippedBlockTime(); oldest > 0 { |
| 686 | return tsdbNotShipped |
| 687 | } |
| 688 | |
| 689 | return tsdbIdle |
| 690 | } |
| 691 | |
| 692 | // TSDBState holds data structures used by the TSDB storage engine |
| 693 | type TSDBState struct { |
no test coverage detected