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

2 servers can still run the same job at the same time #141

Open
WayneUong opened this issue Dec 3, 2019 · 3 comments · May be fixed by #42
Open

2 servers can still run the same job at the same time #141

WayneUong opened this issue Dec 3, 2019 · 3 comments · May be fixed by #42

Comments

@WayneUong
Copy link

WayneUong commented Dec 3, 2019

I setup so 2 meteor apps sharing the same database. And most of the times, both apps can still run the same job at the same time. This package doesn't prevent the second server from starting the same job if the other server is not done. This happens when the 2nd server starts when the 1st still hasn't finished.

@TheGame2500
Copy link
Collaborator

TheGame2500 commented Dec 4, 2019

@WayneUong are you sure you are using littledata:synced-cron and not percolatestudio:synced-cron? There's been a migration at some point and percolatestudio:synced-cron is not maintained anymore. Seems like you're encountering the issue solved by #135

@WayneUong
Copy link
Author

WayneUong commented Dec 4, 2019

@TheGame2500 I use littledata:synced-cron. I did a quick test to confirm:

if (Meteor.isServer) {
    SyncedCron.add({
        name: 'Test',
        schedule: function (parser) {
            return parser.text('every 5 seconds');
        },
        job: function () {
            console.log('start');
            Meteor._sleepForMs(9999999);
            console.log('end')
        }
    });

    Meteor.startup(() => SyncedCron.start());
}

I have the first server running, let the cron job starts, then start the 2nd server, sharing the same db using MONGO_URL=mongodb://localhost:3001/meteor meteor --port 3002

The result is that the 2nd server starts the same job while the 1st is still not done. Meteor._sleepForMs(9999999); is to simulate a long running cron job.

Screen Shot 2019-12-04 at 10 10 30 AM

@WayneUong
Copy link
Author

@TheGame2500 Can you reproduce it?

@StorytellerCZ StorytellerCZ linked a pull request Sep 28, 2023 that will close this issue
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

Successfully merging a pull request may close this issue.

2 participants