@@ -837,6 +837,11 @@ func (s *Store) ServicesByNodeMeta(ws memdb.WatchSet, filters map[string]string)
837
837
results [service ] = append (results [service ], tag )
838
838
}
839
839
}
840
+
841
+ if len (ws ) >= s .watchLimit {
842
+ s .warnSoftLimitReached ("service by node meta" )
843
+ }
844
+
840
845
return idx , results , nil
841
846
}
842
847
@@ -905,6 +910,11 @@ func (s *Store) serviceNodes(ws memdb.WatchSet, serviceName string, connect bool
905
910
if err != nil {
906
911
return 0 , nil , fmt .Errorf ("failed parsing service nodes: %s" , err )
907
912
}
913
+
914
+ if len (ws ) >= s .watchLimit {
915
+ s .warnSoftLimitReached ("service %s" , serviceName )
916
+ }
917
+
908
918
return idx , results , nil
909
919
}
910
920
@@ -1446,7 +1456,16 @@ func (s *Store) ServiceChecksByNodeMeta(ws memdb.WatchSet, serviceName string,
1446
1456
}
1447
1457
ws .Add (iter .WatchCh ())
1448
1458
1449
- return s .parseChecksByNodeMeta (tx , ws , idx , iter , filters )
1459
+ idx , checks , err := s .parseChecksByNodeMeta (tx , ws , idx , iter , filters )
1460
+ if err != nil {
1461
+ return 0 , nil , err
1462
+ }
1463
+
1464
+ if len (ws ) >= s .watchLimit {
1465
+ s .warnSoftLimitReached ("service %s" , serviceName )
1466
+ }
1467
+
1468
+ return idx , checks , nil
1450
1469
}
1451
1470
1452
1471
// ChecksInState is used to query the state store for all checks
@@ -1780,7 +1799,17 @@ func (s *Store) NodeInfo(ws memdb.WatchSet, node string) (uint64, structs.NodeDu
1780
1799
return 0 , nil , fmt .Errorf ("failed node lookup: %s" , err )
1781
1800
}
1782
1801
ws .Add (nodes .WatchCh ())
1783
- return s .parseNodes (tx , ws , idx , nodes )
1802
+
1803
+ idx , nodeDump , err := s .parseNodes (tx , ws , idx , nodes )
1804
+ if err != nil {
1805
+ return 0 , nil , err
1806
+ }
1807
+
1808
+ if len (ws ) >= s .watchLimit {
1809
+ s .warnSoftLimitReached ("node %s" , node )
1810
+ }
1811
+
1812
+ return idx , nodeDump , nil
1784
1813
}
1785
1814
1786
1815
// NodeDump is used to generate a dump of all nodes. This call is expensive
@@ -1863,3 +1892,12 @@ func (s *Store) parseNodes(tx *memdb.Txn, ws memdb.WatchSet, idx uint64,
1863
1892
}
1864
1893
return idx , results , nil
1865
1894
}
1895
+
1896
+ func (s * Store ) warnSoftLimitReached (f string , a ... interface {}) {
1897
+ if s .watchLimitWarnCounter % 100000 > 0 {
1898
+ return
1899
+ }
1900
+
1901
+ s .logger .Printf ("[WARN] consul: exceeded soft watch limit of %d for %s, falling back to coarse grained watch" , s .watchLimit , fmt .Sprintf (f , a ... ))
1902
+ s .watchLimitWarnCounter ++
1903
+ }
0 commit comments