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

UseSlidingInvisibilityTimeout not working sometimes #381

Open
strigefleur opened this issue Dec 17, 2024 · 1 comment
Open

UseSlidingInvisibilityTimeout not working sometimes #381

strigefleur opened this issue Dec 17, 2024 · 1 comment

Comments

@strigefleur
Copy link

strigefleur commented Dec 17, 2024

Having configuration

InvisibilityTimeout = TimeSpan.FromMinutes(5),
UseSlidingInvisibilityTimeout = true,

I'd expect it to let long running jobs to execute without setting huge InvisibilityTimeout.

However under some circumstances (alas, can't reproduce intentionally) - like for a week it is fine and than just no - the task is interrupted after 5 minutes (InvisibilityTimeout I guess) with OperationCanceledException and then is tried to requeue (again sometimes there's also a warning about another worker that fetches the task).

Any ideas?

@strigefleur
Copy link
Author

strigefleur commented Dec 17, 2024

Looking at the source It has to be something with worker change

        string updateFetchAtSql = $@"
          UPDATE ""{_storage.Options.SchemaName}"".""jobqueue"" 
          SET ""fetchedat"" = NOW()
          WHERE ""id"" = @id AND ""fetchedat"" = @fetchedAt
          RETURNING ""fetchedat"" AS ""FetchedAt"";
        ";

        try
        {
          _storage.UseConnection(null, connection =>
          {
            FetchedAt = connection.ExecuteScalar<DateTime?>(updateFetchAtSql,
              new { queue = Queue, id = Id, fetchedAt = FetchedAt });
          });

          if (!FetchedAt.HasValue)
          {
            _logger.Warn(
              $"Background job identifier '{JobId}' was fetched by another worker, will not execute keep alive.");
          }

so that when fetchedat has changed externally there's.. what? something's wrong?
Why would the worker switch anyway?

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

No branches or pull requests

1 participant