@@ -792,6 +792,21 @@ type Options struct {
792
792
// virtual table rewrite compactions entirely. The default value is 0.30
793
793
// (rewrite when >= 30% of backing data is unreferenced).
794
794
VirtualTableRewriteUnreferencedFraction func () float64
795
+
796
+ // IteratorTracking configures periodic logging of iterators held open for
797
+ // too long.
798
+ IteratorTracking struct {
799
+ // PollInterval is the interval at which to log a report of long-lived iterators.
800
+ // If negative, disables iterator tracking.
801
+ //
802
+ // The default value is 5 minutes.
803
+ PollInterval time.Duration
804
+ // MaxAge is the age above which iterators are considered long-lived. If
805
+ // negative, disables iterator tracking.
806
+ //
807
+ // The default value is 1 minute.
808
+ MaxAge time.Duration
809
+ }
795
810
}
796
811
797
812
// Filters is a map from filter policy name to filter policy. It is used for
@@ -1644,6 +1659,12 @@ func (o *Options) EnsureDefaults() {
1644
1659
if o .Experimental .VirtualTableRewriteUnreferencedFraction == nil {
1645
1660
o .Experimental .VirtualTableRewriteUnreferencedFraction = func () float64 { return defaultVirtualTableUnreferencedFraction }
1646
1661
}
1662
+ if o .Experimental .IteratorTracking .PollInterval == 0 {
1663
+ o .Experimental .IteratorTracking .PollInterval = 5 * time .Minute
1664
+ }
1665
+ if o .Experimental .IteratorTracking .MaxAge == 0 {
1666
+ o .Experimental .IteratorTracking .MaxAge = time .Minute
1667
+ }
1647
1668
// TODO(jackson): Enable value separation by default once we have confidence
1648
1669
// in a default policy.
1649
1670
@@ -1786,6 +1807,13 @@ func (o *Options) String() string {
1786
1807
fmt .Fprintf (& buf , " secondary_cache_size_bytes=%d\n " , o .Experimental .SecondaryCacheSizeBytes )
1787
1808
fmt .Fprintf (& buf , " create_on_shared=%d\n " , o .Experimental .CreateOnShared )
1788
1809
1810
+ if o .Experimental .IteratorTracking .PollInterval != 0 {
1811
+ fmt .Fprintf (& buf , " iterator_tracking_poll_interval=%s\n " , o .Experimental .IteratorTracking .PollInterval )
1812
+ }
1813
+ if o .Experimental .IteratorTracking .MaxAge != 0 {
1814
+ fmt .Fprintf (& buf , " iterator_tracking_max_age=%s\n " , o .Experimental .IteratorTracking .MaxAge )
1815
+ }
1816
+
1789
1817
// Private options.
1790
1818
//
1791
1819
// These options are only encoded if true, because we do not want them to
@@ -2228,6 +2256,10 @@ func (o *Options) Parse(s string, hooks *ParseHooks) error {
2228
2256
var createOnSharedInt int64
2229
2257
createOnSharedInt , err = strconv .ParseInt (value , 10 , 64 )
2230
2258
o .Experimental .CreateOnShared = remote .CreateOnSharedStrategy (createOnSharedInt )
2259
+ case "iterator_tracking_poll_interval" :
2260
+ o .Experimental .IteratorTracking .PollInterval , err = time .ParseDuration (value )
2261
+ case "iterator_tracking_max_age" :
2262
+ o .Experimental .IteratorTracking .MaxAge , err = time .ParseDuration (value )
2231
2263
default :
2232
2264
if hooks != nil && hooks .SkipUnknown != nil && hooks .SkipUnknown (section + "." + key , value ) {
2233
2265
return nil
0 commit comments