Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MinimumSecondsBetweenFailureNotifications settings may not work for SQLite storage #1734

Open
digrizzz opened this issue Mar 9, 2023 · 2 comments
Labels

Comments

@digrizzz
Copy link

digrizzz commented Mar 9, 2023

What happened:

WebHookFailureNotifier.IsNotifiedOnWindowTimeAsync() doesn't work correct with SQLite storage because of .ToLower() call inside query:

        private async Task<bool> IsNotifiedOnWindowTimeAsync(string livenessName, bool restore)
        {
#pragma warning disable RCS1155 // Use StringComparison when comparing strings.
            var lastNotification = await _db.Failures
                .Where(lf => lf.HealthCheckName.ToLower() == livenessName.ToLower())
                .OrderByDescending(lf => lf.LastNotified)
                .Take(1)
                .SingleOrDefaultAsync();
#pragma warning restore RCS1155 // Use StringComparison when comparing strings.

            return lastNotification != null
                &&
                lastNotification.IsUpAndRunning == restore
                &&
                (DateTime.UtcNow - lastNotification.LastNotified).TotalSeconds < _settings.MinimumSecondsBetweenFailureNotifications;
        }

What you expected to happen:

WebHookFailureNotifier.IsNotifiedOnWindowTimeAsync works correct

How to reproduce it (as minimally and precisely as possible):

  • use SQLite storage sample
  • set huge MinimumSecondsBetweenFailureNotifications (e.g. 3600)
  • add faulty healthcheck with name "АбВг" (e.g. which is always fail)
  • define webhook notification
  • notification will appear more often then expected 3600 seconds

Anything else we need to know?:

"related" issue in ef core repo: dotnet/efcore#27378

  • .NET Core version: .net7
  • Healthchecks version: 6.0.5
  • Operative system: Win10
  • Others:
@digrizzz
Copy link
Author

digrizzz commented Mar 9, 2023

my proposing solution: https://sqlite.org/forum/forumpost/d2f7daf09ea920e9

@sungam3r
Copy link
Collaborator

PR is welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants