[SERVER-2573] Ability to schedule javascript functions to run @ cron like intervals on the server Created: 16/Feb/11  Updated: 19/Aug/19  Resolved: 24/Jun/15

Status: Closed
Project: Core Server
Component/s: Usability
Affects Version/s: None
Fix Version/s: None

Type: New Feature Priority: Major - P3
Reporter: Ryan Nitz Assignee: Unassigned
Resolution: Won't Fix Votes: 10
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Participants:
Case:

 Description   

It would be nice to be able to schedule tasks/javascript functions to run inside mongo at fixed intervals (via the drivers).

This would make random jobs easier to code. Currently, I'm executing code that a cron calls via HTTP and this results in a bit of unnecessary framework code in my application.

Most databases support scheduled stored proc execution.

The ability to configure the scheduled proc so that it runs in parallel on shards, would be very handy too

E.g.

Once per minute, I would like to run:

  • * * * * updateHostClusterIds

// Syntax may be off a bit

function updateHostClusterIds(currentTime, shardId) {
db.clusters.find().forEach( function(cluster) {
db.hosts.update({ _id: { $in :

{ cluster.hostIds }

}}, { $set: { clusterId : cluster._id }}, false, true);
});
}



 Comments   
Comment by Ian Whalen (Inactive) [ 24/Jun/15 ]

As per Eliot's previous comment, this is not something that we currently plan to include in MongoDB.

Comment by Derick Qua [ 10/Dec/11 ]

This is a feature that I am kind of looking for as well---but not for running MR jobs (use cron, ActiveBatch, etc for those). There are specific tasks of the DB admin kind that I periodically need to run. Currently, these are either JS or pymongo and executed by cron(1) since I have no other options. It works, but it does not sit well with me. Why?

Mongo security: in one way or another, I have to store an admin login (id and credentials) "somewhere" the scripts being executed can get to them and pass them on to MongoDB to authenticate. Filesystem ACL, platform-specific secure storage (etc) are simply not a readily workable nor sufficiently secure solution.

What I'd like to see is the ability for an authenticated user to be able to internally upload/schedule JS code to run at specific intervals or schedules and do so in the security context of the script's owner (or perhaps, in the superuser case, designate a specific context). Being "all internal" to the database, the authentication issue is greatly diminished (assuming implementation is rock solid).

Comment by Gerhard Balthasar [ 17/Feb/11 ]

Would be a nice feature for long-running MapReduce Jobs, e.g. statistical data mining once a day. Should be full viewable and configurable per JS console and per driver imho.

Comment by Eliot Horowitz (Inactive) [ 16/Feb/11 ]

Not sure this is something that belonds in a db

Generated at Thu Feb 08 03:00:25 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.