Repository: VictoriaMetrics/VictoriaMetrics
Pull request #2225 (2022-02-21 04:11:47)

build(deps): bump @mui/styles from 5.4.1 to 5.4.2 in /app/vmui/packages/vmui
Bumps [@mui/styles](https://github.com/mui/material-ui/tree/HEAD/packages/mui-styles) from 5.4.1 to 5.4.2.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/mui/material-ui/releases"><code>@​mui/styles</code>'s releases</a>.</em></p>
<blockquote>
<h2>v5.4.2</h2>
<p><em>Feb 15, 2022</em></p>
<p>A big thanks to the 16 contributors who made this release possible. Here are some highlights ✨:</p>
<ul>
<li>🛠 <a href="https://github.com/sydneyjodon-wk"><code>@​sydneyjodon-wk</code></a> improved propTypes of the ToggleButton components (<a href="https://github.com/mui/material-ui/tree/HEAD/packages/mui-styles/issues/30883">#30883</a>)</li>
<li>Several 🐛 bug fixes and 📚 documentation improvements</li>
</ul>
<h3><code>@mui/material@5.4.2</code></h3>
<ul>
<li>[Select] Allow customizing Select based on its variant (<a href="https://github.com/mui/material-ui/tree/HEAD/packages/mui-styles/issues/30788">#30788</a>) <a href="https://github.com/michaldudak"><code>@​michaldudak</code></a></li>
<li>[Portal] Re-export 'Portal' in material (<a href="https://github.com/mui/material-ui/tree/HEAD/packages/mui-styles/issues/31003">#31003</a>) <a href="https://github.com/liradb2000"><code>@​liradb2000</code></a></li>
<li>[ToggleButton] Add prop types for <code>onClick</code> and <code>onChange</code> (<a href="https://github.com/mui/material-ui/tree/HEAD/packages/mui-styles/issues/30883">#30883</a>) <a href="https://github.com/sydneyjodon-wk"><code>@​sydneyjodon-wk</code></a></li>
<li>[Typescript] Added TypeText declaration to the exports file (<a href="https://github.com/mui/material-ui/tree/HEAD/packages/mui-styles/issues/30890">#30890</a>) <a href="https://github.com/agauravdev"><code>@​agauravdev</code></a></li>
</ul>
<h3><code>@mui/system@5.4.2</code></h3>
<ul>
<li>[system] Fix broken behavior when breakpoints input are not ordered (<a href="https://github.com/mui/material-ui/tree/HEAD/packages/mui-styles/issues/30996">#30996</a>) <a href="https://github.com/mnajdova"><code>@​mnajdova</code></a></li>
</ul>
<h3><code>@mui/lab@5.0.0-alpha.69</code></h3>
<ul>
<li>[DatePicker] Fix passing clearable prop (<a href="https://github.com/mui/material-ui/tree/HEAD/packages/mui-styles/issues/30786">#30786</a>) <a href="https://github.com/alisasanib"><code>@​alisasanib</code></a></li>
</ul>
<h3><code>@mui/joy@5.0.0-alpha.15</code></h3>
<ul>
<li>[Joy] Improve variant customization experience (<a href="https://github.com/mui/material-ui/tree/HEAD/packages/mui-styles/issues/30878">#30878</a>) <a href="https://github.com/siriwatknp"><code>@​siriwatknp</code></a></li>
<li>[Joy] Make <code>sx</code> prop work in Joy (<a href="https://github.com/mui/material-ui/tree/HEAD/packages/mui-styles/issues/30955">#30955</a>) <a href="https://github.com/siriwatknp"><code>@​siriwatknp</code></a></li>
</ul>
<h3>Framer</h3>
<ul>
<li>[design] Remove framer components (<a href="https://github.com/mui/material-ui/tree/HEAD/packages/mui-styles/issues/30983">#30983</a>) <a href="https://github.com/mbrookes"><code>@​mbrookes</code></a></li>
<li>[design] Remove framer leftovers (<a href="https://github.com/mui/material-ui/tree/HEAD/packages/mui-styles/issues/31070">#31070</a>) <a href="https://github.com/michaldudak"><code>@​michaldudak</code></a></li>
</ul>
<h3>Docs</h3>
<ul>
<li>[docs] Update installation guide of the icons package (<a href="https://github.com/mui/material-ui/tree/HEAD/packages/mui-styles/issues/31026">#31026</a>) <a href="https://github.com/huyenltnguyen"><code>@​huyenltnguyen</code></a></li>
<li>[docs] Improve the indication for the legacy APIs (<a href="https://github.com/mui/material-ui/tree/HEAD/packages/mui-styles/issues/30995">#30995</a>) <a href="https://github.com/mnajdova"><code>@​mnajdova</code></a></li>
<li>[docs] Specify which props are added in the default <code>shouldForwardProp</code> option (<a href="https://github.com/mui/material-ui/tree/HEAD/packages/mui-styles/issues/30978">#30978</a>) <a href="https://github.com/mnajdova"><code>@​mnajdova</code></a></li>
<li>[docs] Fix layout shift on loading (<a href="https://github.com/mui/material-ui/tree/HEAD/packages/mui-styles/issues/31017">#31017</a>) <a href="https://github.com/oliviertassinari"><code>@​oliviertassinari</code></a></li>
<li>[docs] Increase scroll affordance in wide tables (<a href="https://github.com/mui/material-ui/tree/HEAD/packages/mui-styles/issues/30713">#30713</a>) <a href="https://github.com/danilo-leal"><code>@​danilo-leal</code></a></li>
<li>[docs] Fix look &amp; feel of the Masonry demos (<a href="https://github.com/mui/material-ui/tree/HEAD/packages/mui-styles/issues/30971">#30971</a>) <a href="https://github.com/oliviertassinari"><code>@​oliviertassinari</code></a></li>
<li>[docs] Improve Base component demos (<a href="https://github.com/mui/material-ui/tree/HEAD/packages/mui-styles/issues/30884">#30884</a>) <a href="https://github.com/danilo-leal"><code>@​danilo-leal</code></a></li>
<li>[docs] Use full product names (Material UI, MUI System) (<a href="https://github.com/mui/material-ui/tree/HEAD/packages/mui-styles/issues/30960">#30960</a>) <a href="https://github.com/oliviertassinari"><code>@​oliviertassinari</code></a></li>
<li>[docs] Prefer useEnhancedEffect to avoid server side warnings (<a href="https://github.com/mui/material-ui/tree/HEAD/packages/mui-styles/issues/30977">#30977</a>) <a href="https://github.com/mnajdova"><code>@​mnajdova</code></a></li>
<li>[docs] Fix force redirection to a different locale (<a href="https://github.com/mui/material-ui/tree/HEAD/packages/mui-styles/issues/30967">#30967</a>) <a href="https://github.com/oliviertassinari"><code>@​oliviertassinari</code></a></li>
<li>[docs] Add live Tailwind CSS demo (<a href="https://github.com/mui/material-ui/tree/HEAD/packages/mui-styles/issues/30966">#30966</a>) <a href="https://github.com/oliviertassinari"><code>@​oliviertassinari</code></a></li>
<li>[website] Add banner for promoting priority open roles (<a href="https://github.com/mui/material-ui/tree/HEAD/packages/mui-styles/issues/31076">#31076</a>) <a href="https://github.com/danilo-leal"><code>@​danilo-leal</code></a></li>
<li>[website] Open Full-stack Engineer role for studio (<a href="https://github.com/mui/material-ui/tree/HEAD/packages/mui-styles/issues/31038">#31038</a>) <a href="https://github.com/newguy-123"><code>@​newguy-123</code></a></li>
<li>[website] Minor security improvements (<a href="https://github.com/mui/material-ui/tree/HEAD/packages/mui-styles/issues/31062">#31062</a>) <a href="https://github.com/oliviertassinari"><code>@​oliviertassinari</code></a></li>
<li>[website] Improve title of open roles (<a href="https://github.com/mui/material-ui/tree/HEAD/packages/mui-styles/issues/30963">#30963</a>) <a href="https://github.com/DanailH"><code>@​DanailH</code></a></li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/mui/material-ui/blob/master/CHANGELOG.md"><code>@​mui/styles</code>'s changelog</a>.</em></p>
<blockquote>
<h2>5.4.2</h2>
<p><em>Feb 15, 2022</em></p>
<p>A big thanks to the 16 contributors who made this release possible. Here are some highlights ✨:</p>
<ul>
<li>🛠 <a href="https://github.com/sydneyjodon-wk"><code>@​sydneyjodon-wk</code></a> improved propTypes of the ToggleButton components (<a href="https://github.com/mui/material-ui/tree/HEAD/packages/mui-styles/issues/30883">#30883</a>)</li>
<li>Several 🐛 bug fixes and 📚 documentation improvements</li>
</ul>
<h3><code>@mui/material@5.4.2</code></h3>
<ul>
<li>[Select] Allow customizing Select based on its variant (<a href="https://github.com/mui/material-ui/tree/HEAD/packages/mui-styles/issues/30788">#30788</a>) <a href="https://github.com/michaldudak"><code>@​michaldudak</code></a></li>
<li>[Portal] Re-export 'Portal' in material (<a href="https://github.com/mui/material-ui/tree/HEAD/packages/mui-styles/issues/31003">#31003</a>) <a href="https://github.com/liradb2000"><code>@​liradb2000</code></a></li>
<li>[ToggleButton] Add prop types for <code>onClick</code> and <code>onChange</code> (<a href="https://github.com/mui/material-ui/tree/HEAD/packages/mui-styles/issues/30883">#30883</a>) <a href="https://github.com/sydneyjodon-wk"><code>@​sydneyjodon-wk</code></a></li>
<li>[Typescript] Added TypeText declaration to the exports file (<a href="https://github.com/mui/material-ui/tree/HEAD/packages/mui-styles/issues/30890">#30890</a>) <a href="https://github.com/agauravdev"><code>@​agauravdev</code></a></li>
</ul>
<h3><code>@mui/system@5.4.2</code></h3>
<ul>
<li>[system] Fix broken behavior when breakpoints input are not ordered (<a href="https://github.com/mui/material-ui/tree/HEAD/packages/mui-styles/issues/30996">#30996</a>) <a href="https://github.com/mnajdova"><code>@​mnajdova</code></a></li>
</ul>
<h3><code>@mui/lab@5.0.0-alpha.69</code></h3>
<ul>
<li>[DatePicker] Fix passing clearable prop (<a href="https://github.com/mui/material-ui/tree/HEAD/packages/mui-styles/issues/30786">#30786</a>) <a href="https://github.com/alisasanib"><code>@​alisasanib</code></a></li>
</ul>
<h3><code>@mui/joy@5.0.0-alpha.15</code></h3>
<ul>
<li>[Joy] Improve variant customization experience (<a href="https://github.com/mui/material-ui/tree/HEAD/packages/mui-styles/issues/30878">#30878</a>) <a href="https://github.com/siriwatknp"><code>@​siriwatknp</code></a></li>
<li>[Joy] Make <code>sx</code> prop work in Joy (<a href="https://github.com/mui/material-ui/tree/HEAD/packages/mui-styles/issues/30955">#30955</a>) <a href="https://github.com/siriwatknp"><code>@​siriwatknp</code></a></li>
</ul>
<h3>Framer</h3>
<ul>
<li>[design] Remove framer components (<a href="https://github.com/mui/material-ui/tree/HEAD/packages/mui-styles/issues/30983">#30983</a>) <a href="https://github.com/mbrookes"><code>@​mbrookes</code></a></li>
<li>[design] Remove framer leftovers (<a href="https://github.com/mui/material-ui/tree/HEAD/packages/mui-styles/issues/31070">#31070</a>) <a href="https://github.com/michaldudak"><code>@​michaldudak</code></a></li>
</ul>
<h3>Docs</h3>
<ul>
<li>[docs] Update installation guide of the icons package (<a href="https://github.com/mui/material-ui/tree/HEAD/packages/mui-styles/issues/31026">#31026</a>) <a href="https://github.com/huyenltnguyen"><code>@​huyenltnguyen</code></a></li>
<li>[docs] Improve the indication for the legacy APIs (<a href="https://github.com/mui/material-ui/tree/HEAD/packages/mui-styles/issues/30995">#30995</a>) <a href="https://github.com/mnajdova"><code>@​mnajdova</code></a></li>
<li>[docs] Specify which props are added in the default <code>shouldForwardProp</code> option (<a href="https://github.com/mui/material-ui/tree/HEAD/packages/mui-styles/issues/30978">#30978</a>) <a href="https://github.com/mnajdova"><code>@​mnajdova</code></a></li>
<li>[docs] Fix layout shift on loading (<a href="https://github.com/mui/material-ui/tree/HEAD/packages/mui-styles/issues/31017">#31017</a>) <a href="https://github.com/oliviertassinari"><code>@​oliviertassinari</code></a></li>
<li>[docs] Increase scroll affordance in wide tables (<a href="https://github.com/mui/material-ui/tree/HEAD/packages/mui-styles/issues/30713">#30713</a>) <a href="https://github.com/danilo-leal"><code>@​danilo-leal</code></a></li>
<li>[docs] Fix look &amp; feel of the Masonry demos (<a href="https://github.com/mui/material-ui/tree/HEAD/packages/mui-styles/issues/30971">#30971</a>) <a href="https://github.com/oliviertassinari"><code>@​oliviertassinari</code></a></li>
<li>[docs] Improve Base component demos (<a href="https://github.com/mui/material-ui/tree/HEAD/packages/mui-styles/issues/30884">#30884</a>) <a href="https://github.com/danilo-leal"><code>@​danilo-leal</code></a></li>
<li>[docs] Use full product names (Material UI, MUI System) (<a href="https://github.com/mui/material-ui/tree/HEAD/packages/mui-styles/issues/30960">#30960</a>) <a href="https://github.com/oliviertassinari"><code>@​oliviertassinari</code></a></li>
<li>[docs] Prefer useEnhancedEffect to avoid server side warnings (<a href="https://github.com/mui/material-ui/tree/HEAD/packages/mui-styles/issues/30977">#30977</a>) <a href="https://github.com/mnajdova"><code>@​mnajdova</code></a></li>
<li>[docs] Fix force redirection to a different locale (<a href="https://github.com/mui/material-ui/tree/HEAD/packages/mui-styles/issues/30967">#30967</a>) <a href="https://github.com/oliviertassinari"><code>@​oliviertassinari</code></a></li>
<li>[docs] Add live Tailwind CSS demo (<a href="https://github.com/mui/material-ui/tree/HEAD/packages/mui-styles/issues/30966">#30966</a>) <a href="https://github.com/oliviertassinari"><code>@​oliviertassinari</code></a></li>
<li>[website] Add banner for promoting priority open roles (<a href="https://github.com/mui/material-ui/tree/HEAD/packages/mui-styles/issues/31076">#31076</a>) <a href="https://github.com/danilo-leal"><code>@​danilo-leal</code></a></li>
<li>[website] Open Full-stack Engineer role for studio (<a href="https://github.com/mui/material-ui/tree/HEAD/packages/mui-styles/issues/31038">#31038</a>) <a href="https://github.com/newguy-123"><code>@​newguy-123</code></a></li>
<li>[website] Minor security improvements (<a href="https://github.com/mui/material-ui/tree/HEAD/packages/mui-styles/issues/31062">#31062</a>) <a href="https://github.com/oliviertassinari"><code>@​oliviertassinari</code></a></li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/mui/material-ui/commit/01371028b27156419923b362c4b0af92dc08b29f"><code>0137102</code></a> v5.4.2 (<a href="https://github.com/mui/material-ui/tree/HEAD/packages/mui-styles/issues/31074">#31074</a>)</li>
<li>See full diff in <a href="https://github.com/mui/material-ui/commits/v5.4.2/packages/mui-styles">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=@mui/styles&package-manager=npm_and_yarn&previous-version=5.4.1&new-version=5.4.2)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)


</details>

codecov[bot]: # [Codecov](https://codecov.io/gh/VictoriaMetrics/VictoriaMetrics/pull/2225?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=VictoriaMetrics) Report
> Merging [#2225](https://codecov.io/gh/VictoriaMetrics/VictoriaMetrics/pull/2225?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=VictoriaMetrics) (ef804fe) into [master](https://codecov.io/gh/VictoriaMetrics/VictoriaMetrics/commit/10590bde474990e84e0c9dcd6d50d87f884fa7a3?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=VictoriaMetrics) (10590bd) will **not change** coverage.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/VictoriaMetrics/VictoriaMetrics/pull/2225/graphs/tree.svg?width=650&height=150&src=pr&token=YND8dYVcXn&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=VictoriaMetrics)](https://codecov.io/gh/VictoriaMetrics/VictoriaMetrics/pull/2225?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=VictoriaMetrics)

```diff
@@           Coverage Diff           @@
##           master    #2225   +/-   ##
=======================================
  Coverage   60.54%   60.54%           
=======================================
  Files         240      240           
  Lines       40685    40685           
=======================================
  Hits        24633    24633           
  Misses      14413    14413           
  Partials     1639     1639           
```


| [Impacted Files](https://codecov.io/gh/VictoriaMetrics/VictoriaMetrics/pull/2225?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=VictoriaMetrics) | Coverage Δ | |
|---|---|---|
| [app/vmselect/promql/aggr\_incremental.go](https://codecov.io/gh/VictoriaMetrics/VictoriaMetrics/pull/2225/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=VictoriaMetrics#diff-YXBwL3Ztc2VsZWN0L3Byb21xbC9hZ2dyX2luY3JlbWVudGFsLmdv) | `81.62% <0.00%> (-2.72%)` | :arrow_down: |
| [lib/storage/storage.go](https://codecov.io/gh/VictoriaMetrics/VictoriaMetrics/pull/2225/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=VictoriaMetrics#diff-bGliL3N0b3JhZ2Uvc3RvcmFnZS5nbw==) | `67.64% <0.00%> (+0.28%)` | :arrow_up: |
| [lib/decimal/decimal.go](https://codecov.io/gh/VictoriaMetrics/VictoriaMetrics/pull/2225/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=VictoriaMetrics#diff-bGliL2RlY2ltYWwvZGVjaW1hbC5nbw==) | `94.01% <0.00%> (+0.74%)` | :arrow_up: |
| [lib/bloomfilter/filter.go](https://codecov.io/gh/VictoriaMetrics/VictoriaMetrics/pull/2225/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=VictoriaMetrics#diff-bGliL2Jsb29tZmlsdGVyL2ZpbHRlci5nbw==) | `100.00% <0.00%> (+2.00%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/VictoriaMetrics/VictoriaMetrics/pull/2225?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=VictoriaMetrics).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=VictoriaMetrics)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/VictoriaMetrics/VictoriaMetrics/pull/2225?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=VictoriaMetrics). Last update [affaf37...ef804fe](https://codecov.io/gh/VictoriaMetrics/VictoriaMetrics/pull/2225?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=VictoriaMetrics). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=VictoriaMetrics).


Patch:
diff --git a/app/vmalert/notifier/config_watcher.go b/app/vmalert/notifier/config_watcher.go
index 5cba98bd5..a49990151 100644
--- a/app/vmalert/notifier/config_watcher.go
+++ b/app/vmalert/notifier/config_watcher.go
@@ -73,35 +73,18 @@ func (cw *configWatcher) reload(path string) error {
 	}
 
 	// stop existing discovery
-	close(cw.syncCh)
-	cw.wg.Wait()
+	cw.mustStop()
 
 	// re-start cw with new config
 	cw.syncCh = make(chan struct{})
 	cw.cfg = cfg
-
-	cw.resetTargets()
 	return cw.start()
 }
 
-const (
-	addRetryBackoff = time.Millisecond * 100
-	addRetryCount   = 2
-)
-
 func (cw *configWatcher) add(typeK TargetType, interval time.Duration, labelsFn getLabels) error {
-	var targets []Target
-	var errors []error
-	var count int
-	for { // retry addRetryCount times if first discovery attempts gave no results
-		targets, errors = targetsFromLabels(labelsFn, cw.cfg, cw.genFn)
-		for _, err := range errors {
-			return fmt.Errorf("failed to init notifier for %q: %s", typeK, err)
-		}
-		if len(targets) > 0 || count >= addRetryCount {
-			break
-		}
-		time.Sleep(addRetryBackoff)
+	targets, errors := targetsFromLabels(labelsFn, cw.cfg, cw.genFn)
+	for _, err := range errors {
+		return fmt.Errorf("failed to init notifier for %q: %s", typeK, err)
 	}
 
 	cw.setTargets(typeK, targets)
@@ -215,7 +198,10 @@ func (cw *configWatcher) start() error {
 	return nil
 }
 
-func (cw *configWatcher) resetTargets() {
+func (cw *configWatcher) mustStop() {
+	close(cw.syncCh)
+	cw.wg.Wait()
+
 	cw.targetsMu.Lock()
 	for _, targets := range cw.targets {
 		for _, t := range targets {
@@ -224,6 +210,11 @@ func (cw *configWatcher) resetTargets() {
 	}
 	cw.targets = make(map[TargetType][]Target)
 	cw.targetsMu.Unlock()
+
+	for i := range cw.cfg.ConsulSDConfigs {
+		cw.cfg.ConsulSDConfigs[i].MustStop()
+	}
+	cw.cfg = nil
 }
 
 func (cw *configWatcher) setTargets(key TargetType, targets []Target) {
diff --git a/app/vmui/packages/vmui/package-lock.json b/app/vmui/packages/vmui/package-lock.json
index 71552ba0c..a8ceabb58 100644
--- a/app/vmui/packages/vmui/package-lock.json
+++ b/app/vmui/packages/vmui/package-lock.json
@@ -13,7 +13,7 @@
         "@mui/icons-material": "^5.4.2",
         "@mui/lab": "^5.0.0-alpha.68",
         "@mui/material": "^5.4.2",
-        "@mui/styles": "^5.4.1",
+        "@mui/styles": "^5.4.2",
         "@testing-library/jest-dom": "^5.16.2",
         "@testing-library/react": "^12.1.2",
         "@testing-library/user-event": "^13.5.0",
@@ -3329,15 +3329,15 @@
       }
     },
     "node_modules/@mui/styles": {
-      "version": "5.4.1",
-      "resolved": "https://registry.npmjs.org/@mui/styles/-/styles-5.4.1.tgz",
-      "integrity": "sha512-ekw2NBC06re0H9SvCA1XgtFcghB8AQdGPXD3mjIz5ik+X+LvR+f2TeoCpJpkKp7UQdcNn6uuYi6BO6irTiQhdw==",
+      "version": "5.4.2",
+      "resolved": "https://registry.npmjs.org/@mui/styles/-/styles-5.4.2.tgz",
+      "integrity": "sha512-BX75fNHmRF51yove9dBkH28gpSFjClOPDEnUwLTghPYN913OsqViS/iuCd61dxzygtEEmmeYuWfQjxu/F6vF5g==",
       "dependencies": {
         "@babel/runtime": "^7.17.0",
         "@emotion/hash": "^0.8.0",
-        "@mui/private-theming": "^5.4.1",
-        "@mui/types": "^7.1.1",
-        "@mui/utils": "^5.4.1",
+        "@mui/private-theming": "^5.4.2",
+        "@mui/types": "^7.1.2",
+        "@mui/utils": "^5.4.2",
         "clsx": "^1.1.1",
         "csstype": "^3.0.10",
         "hoist-non-react-statics": "^3.3.2",
@@ -21807,15 +21807,15 @@
       }
     },
     "@mui/styles": {
-      "version": "5.4.1",
-      "resolved": "https://registry.npmjs.org/@mui/styles/-/styles-5.4.1.tgz",
-      "integrity": "sha512-ekw2NBC06re0H9SvCA1XgtFcghB8AQdGPXD3mjIz5ik+X+LvR+f2TeoCpJpkKp7UQdcNn6uuYi6BO6irTiQhdw==",
+      "version": "5.4.2",
+      "resolved": "https://registry.npmjs.org/@mui/styles/-/styles-5.4.2.tgz",
+      "integrity": "sha512-BX75fNHmRF51yove9dBkH28gpSFjClOPDEnUwLTghPYN913OsqViS/iuCd61dxzygtEEmmeYuWfQjxu/F6vF5g==",
       "requires": {
         "@babel/runtime": "^7.17.0",
         "@emotion/hash": "^0.8.0",
-        "@mui/private-theming": "^5.4.1",
-        "@mui/types": "^7.1.1",
-        "@mui/utils": "^5.4.1",
+        "@mui/private-theming": "^5.4.2",
+        "@mui/types": "^7.1.2",
+        "@mui/utils": "^5.4.2",
         "clsx": "^1.1.1",
         "csstype": "^3.0.10",
         "hoist-non-react-statics": "^3.3.2",
diff --git a/app/vmui/packages/vmui/package.json b/app/vmui/packages/vmui/package.json
index 6258d6256..075d1f8b6 100644
--- a/app/vmui/packages/vmui/package.json
+++ b/app/vmui/packages/vmui/package.json
@@ -9,7 +9,7 @@
     "@mui/icons-material": "^5.4.2",
     "@mui/lab": "^5.0.0-alpha.68",
     "@mui/material": "^5.4.2",
-    "@mui/styles": "^5.4.1",
+    "@mui/styles": "^5.4.2",
     "@testing-library/jest-dom": "^5.16.2",
     "@testing-library/react": "^12.1.2",
     "@testing-library/user-event": "^13.5.0",
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md
index f1cae3d22..cdbaba37e 100644
--- a/docs/CHANGELOG.md
+++ b/docs/CHANGELOG.md
@@ -25,6 +25,7 @@ The following tip changes can be tested by building VictoriaMetrics components f
 * BUGFIX: reduce memory usage during the first three hours after the upgrade from versions older than v1.73.0. The memory usage spike was related to the need of in-memory caches' re-population after the upgrade because of the fix for [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1401). Now cache size limits are reduced in order to occupy less memory during the upgrade.
 * BUGFIX: fix a bug, which could significantly slow down requests to `/api/v1/labels` and `/api/v1/label/<label_name>/values`. These APIs are used by Grafana for auto-completion of label names and label values. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/2200).
 * BUGFIX: vmalert: add support for `$externalLabels` and `$externalURL` template vars in the same way as Prometheus does. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/2193).
+* BUGFIX: vmalert: make sure notifiers are discovered during initialization if they are configured via `consul_sd_configs`. Previously they could be discovered in 30 seconds (the default value for `-promscrape.consulSDCheckInterval` command-line flag) after the initialization. See [this pull request](https://github.com/VictoriaMetrics/VictoriaMetrics/pull/2202).
 * BUGFIX: update default value for `-promscrape.fileSDCheckInterval`, so it matches default duration used by Prometheus for checking for updates in `file_sd_configs`. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/2187). Thanks to @corporate-gadfly for the fix.
 
 
diff --git a/lib/promscrape/discovery/consul/watch.go b/lib/promscrape/discovery/consul/watch.go
index f5d60c4ea..8162998c9 100644
--- a/lib/promscrape/discovery/consul/watch.go
+++ b/lib/promscrape/discovery/consul/watch.go
@@ -42,7 +42,7 @@ type serviceWatcher struct {
 	stopCh       chan struct{}
 }
 
-// newConsulWatcher creates new watcher and start background service discovery for Consul.
+// newConsulWatcher creates new watcher and starts background service discovery for Consul.
 func newConsulWatcher(client *discoveryutils.Client, sdc *SDConfig, datacenter, namespace string) *consulWatcher {
 	baseQueryArgs := "?dc=" + url.QueryEscape(datacenter)
 	if sdc.AllowStale {
@@ -67,7 +67,10 @@ func newConsulWatcher(client *discoveryutils.Client, sdc *SDConfig, datacenter,
 		services:              make(map[string]*serviceWatcher),
 		stopCh:                make(chan struct{}),
 	}
-	go cw.watchForServicesUpdates()
+	initCh := make(chan struct{})
+	go cw.watchForServicesUpdates(initCh)
+	// wait for initialization to complete
+	<-initCh
 	return cw
 }
 
@@ -78,11 +81,57 @@ func (cw *consulWatcher) mustStop() {
 	// TODO: add ability to cancel blocking requests.
 }
 
+func (cw *consulWatcher) updateServices(serviceNames []string) {
+	var initWG sync.WaitGroup
+	// Start watchers for new services.
+	cw.servicesLock.Lock()
+	for _, serviceName := range serviceNames {
+		if _, ok := cw.services[serviceName]; ok {
+			// The watcher for serviceName already exists.
+			continue
+		}
+		sw := &serviceWatcher{
+			serviceName: serviceName,
+			stopCh:      make(chan struct{}),
+		}
+		cw.services[serviceName] = sw
+		cw.wg.Add(1)
+		serviceWatchersCreated.Inc()
+		initWG.Add(1)
+		go func() {
+			serviceWatchersCount.Inc()
+			sw.watchForServiceNodesUpdates(cw, &initWG)
+			serviceWatchersCount.Dec()
+			cw.wg.Done()
+		}()
+	}
+
+	// Stop watchers for removed services.
+	newServiceNamesMap := make(map[string]struct{}, len(serviceNames))
+	for _, serviceName := range serviceNames {
+		newServiceNamesMap[serviceName] = struct{}{}
+	}
+	for serviceName, sw := range cw.services {
+		if _, ok := newServiceNamesMap[serviceName]; ok {
+			continue
+		}
+		close(sw.stopCh)
+		delete(cw.services, serviceName)
+		serviceWatchersStopped.Inc()
+
+		// Do not wait for the watcher goroutine to exit, since this may take for up to maxWaitTime
+		// if it is blocked in Consul API request.
+	}
+	cw.servicesLock.Unlock()
+
+	// Wait for initialization to complete.
+	initWG.Wait()
+}
+
 // watchForServicesUpdates watches for new services and updates it in cw.
-func (cw *consulWatcher) watchForServicesUpdates() {
-	checkInterval := getCheckInterval()
-	ticker := time.NewTicker(checkInterval / 2)
-	defer ticker.Stop()
+//
+// watchForServicesUpdates closes the initCh once the initialization is complete and first discovery iteration is done.
+func (cw *consulWatcher) watchForServicesUpdates(initCh chan struct{}) {
 	index := int64(0)
 	clientAddr := cw.client.Addr()
 	f := func() {
@@ -95,51 +144,19 @@ func (cw *consulWatcher) watchForServicesUpdates() {
 			// Nothing changed.
 			return
 		}
-
-		cw.servicesLock.Lock()
-		// Start watchers for new services.
-		for _, serviceName := range serviceNames {
-			if _, ok := cw.services[serviceName]; ok {
-				// The watcher for serviceName already exists.
-				continue
-			}
-			sw := &serviceWatcher{
-				serviceName: serviceName,
-				stopCh:      make(chan struct{}),
-			}
-			cw.services[serviceName] = sw
-			cw.wg.Add(1)
-			serviceWatchersCreated.Inc()
-			go func() {
-				serviceWatchersCount.Inc()
-				sw.watchForServiceNodesUpdates(cw)
-				serviceWatchersCount.Dec()
-				cw.wg.Done()
-			}()
-		}
-		// Stop watchers for removed services.
-		newServiceNamesMap := make(map[string]struct{}, len(serviceNames))
-		for _, serviceName := range serviceNames {
-			newServiceNamesMap[serviceName] = struct{}{}
-		}
-		for serviceName, sw := range cw.services {
-			if _, ok := newServiceNamesMap[serviceName]; ok {
-				continue
-			}
-			close(sw.stopCh)
-			delete(cw.services, serviceName)
-			serviceWatchersStopped.Inc()
-
-			// Do not wait for the watcher goroutine to exit, since this may take for up to maxWaitTime
-			// if it is blocked in Consul API request.
-		}
-		cw.servicesLock.Unlock()
-
+		cw.updateServices(serviceNames)
 		index = newIndex
 	}
 
 	logger.Infof("started Consul service watcher for %q", clientAddr)
 	f()
+
+	// send signal that initialization is complete
+	close(initCh)
+
+	checkInterval := getCheckInterval()
+	ticker := time.NewTicker(checkInterval / 2)
+	defer ticker.Stop()
 	for {
 		select {
 		case <-ticker.C:
@@ -196,10 +213,9 @@ func (cw *consulWatcher) getBlockingServiceNames(index int64) ([]string, int64,
 }
 
 // watchForServiceNodesUpdates watches for Consul serviceNode changes for the given serviceName.
-func (sw *serviceWatcher) watchForServiceNodesUpdates(cw *consulWatcher) {
-	checkInterval := getCheckInterval()
-	ticker := time.NewTicker(checkInterval / 2)
-	defer ticker.Stop()
+//
+// watchForServiceNodesUpdates calls initWG.Done() once the initialization is complete and the first discovery iteration is done.
+func (sw *serviceWatcher) watchForServiceNodesUpdates(cw *consulWatcher, initWG *sync.WaitGroup) {
 	clientAddr := cw.client.Addr()
 	index := int64(0)
 	path := "/v1/health/service/" + sw.serviceName + cw.serviceNodesQueryArgs
@@ -227,6 +243,12 @@ func (sw *serviceWatcher) watchForServiceNodesUpdates(cw *consulWatcher) {
 	}
 
 	f()
+	// Notify caller that initialization is complete
+	initWG.Done()
+
+	checkInterval := getCheckInterval()
+	ticker := time.NewTicker(checkInterval / 2)
+	defer ticker.Stop()
 	for {
 		select {
 		case <-ticker.C:


Test patch:
diff --git a/app/vmalert/notifier/config_watcher_test.go b/app/vmalert/notifier/config_watcher_test.go
index 9107157b4..4120e75b2 100644
--- a/app/vmalert/notifier/config_watcher_test.go
+++ b/app/vmalert/notifier/config_watcher_test.go
@@ -9,9 +9,6 @@ import (
 	"os"
 	"sync"
 	"testing"
-	"time"
-
-	"github.com/VictoriaMetrics/VictoriaMetrics/lib/promscrape/discovery/consul"
 )
 
 func TestConfigWatcherReload(t *testing.T) {
@@ -31,6 +28,7 @@ static_configs:
 	if err != nil {
 		t.Fatalf("failed to start config watcher: %s", err)
 	}
+	defer cw.mustStop()
 	ns := cw.notifiers()
 	if len(ns) != 2 {
 		t.Fatalf("expected to have 2 notifiers; got %d %#v", len(ns), ns)
@@ -78,16 +76,11 @@ consul_sd_configs:
       - alertmanager
 `, consulSDServer.URL))
 
-	prevCheckInterval := *consul.SDCheckInterval
-	defer func() { *consul.SDCheckInterval = prevCheckInterval }()
-
-	*consul.SDCheckInterval = time.Millisecond * 100
-
 	cw, err := newWatcher(consulSDFile.Name(), nil)
 	if err != nil {
 		t.Fatalf("failed to start config watcher: %s", err)
 	}
-	time.Sleep(*consul.SDCheckInterval * 2)
+	defer cw.mustStop()
 
 	if len(cw.notifiers()) != 2 {
 		t.Fatalf("expected to get 2 notifiers; got %d", len(cw.notifiers()))
@@ -161,6 +154,7 @@ consul_sd_configs:
 	if err != nil {
 		t.Fatalf("failed to start config watcher: %s", err)
 	}
+	defer cw.mustStop()
 
 	const workers = 500
 	const iterations = 10