Giter VIP home page Giter VIP logo

Comments (4)

murh-lego avatar murh-lego commented on June 12, 2024

Ok it seems that migration couldn't be applied. Retries were invoked resulting in final message:

(Hangfire.SqlServer.SqlServerObjectsInstaller) Was unable to perform the Hangfire schema migration due to an exception. Ignore this message unless you've just installed or upgraded Hangfire.

Can I somehow manually invoke migration or perhaps increase the retries?

from hangfire.

murh-lego avatar murh-lego commented on June 12, 2024

Ended up writing my own runner which tries to perform installation and adding the jobs

IScheduledJobsStartupBootstrapper just bundels all those AddOrUpdate calls in one spot in some other assembly


public sealed class ScheduledJobsStartupRunner(
    IScheduledJobsStartupBootstrapper bootstrapper,
    SqlServerConnectionString connectionString,
    ILogger<ScheduledJobsStartupRunner> logger
) : BackgroundService
{
    protected override async Task ExecuteAsync(CancellationToken stoppingToken)
    {
        while (!stoppingToken.IsCancellationRequested)
        {
            try
            {
                SqlServerObjectsInstaller.Install(new SqlConnection(connectionString));

                bootstrapper.AddScheduledJobs();

                logger.LogInformation("Startup scheduled jobs added successfully!");
                break;
            }
            catch (Exception e)
            {
                logger.LogDebug(e, "Something went wrong bootstrapping scheduled jobs");
                logger.LogWarning("Could not bootstrap scheduled jobs, retrying");
                await Task.WhenAny(Task.Delay(TimeSpan.FromSeconds(5), stoppingToken));
            }
        }
    }
}

from hangfire.

odinserj avatar odinserj commented on June 12, 2024

Ok it seems that migration couldn't be applied. Retries were invoked resulting in final message:

Hm, do you have any ideas what was the exception? It should be logged if logging template includes exceptions.

from hangfire.

murh-lego avatar murh-lego commented on June 12, 2024

Ok it seems that migration couldn't be applied. Retries were invoked resulting in final message:

Hm, do you have any ideas what was the exception? It should be logged if logging template includes exceptions.

Yes, database wasn't available for some time and retries reached threshold. Eventually the db was up, but the service couldn't recover from it.

I've added resilient initializer to migrate db and add jobs that start from application startup life

from hangfire.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.