MongoDB Atlas Trigger Scheduled erroring when Cluster is Paused

We have a simple test Trigger script that runs and errors when the our cluster is PAUSED.

exports = function () {
  console.log('STARTED');
  const db = context.services.get('my-cluster').db('database');
  const connections = db.collection('connections');
  connections.findOne(); // THIS ERRORS WITH TIMEOUT IF CLUSTER IS PAUSED
  console.log('FINISHED');
};

Within this function execution is there a way to check if the cluster is PAUSED?

Alternatively we could Disable/Enable triggers when we Pause/Resume?

Thoughts?

Hi

I got this problem. A trigger on a table for update / patch. when the cluster is disabled I don’t know why we got the error

“cannot open a changestream against a paused cluster”

Did you solve it?

Database Triggers work by opening a change stream on the cluster. If the cluster is paused, then the trigger cannot work because it cannot connect to the cluster.

Similarily, scheduled triggers do not need an unpaused cluster to work since they just execute on a CRON schedule, but if the function performs an action on the cluster (like a findOne) then it will fail if the cluster is paused.

For details on how to programmatically pause triggers when the cluster is paused, you can see our Admin API: MongoDB Atlas App Services Admin API

Yeah, but I got this problem with a database trigger which is supposed to get triggered when an update occurs on a document. What’s the aim to not disable it when the cluster is disabled, automatically? Now I have to implement a function that will get all the triggers, then disable each one before the function that disable the cluster. The same when the cluster go on, a new function to enable all the triggers. They are change stream but they are linked to a collection belonging a disabled cluster…

Unfortunately, we dont yet have the ability to be notified of changes to the cluster (though we are working on something related to that soon). Its not generally a common use case to be pausing and resuming a cluster a lot, but I will add this as feedback to potential projects on our roadmap.

Thank you so much, it could be very useful