Atlas App Service DB Trigger Blues

Has anyone had trouble with database triggers? I have this trigger for an insert that should be firing, and it has been always firing. All of the sudden it just stopped and I can’t really see why.

I’ve had similar troubles with triggers in the past. I’m going to implement this separately using a change stream listener through a MongoDB SDK. It’s a bit too worrisome to rely on something that will randomly stop working that I can’t really debug.

1 Like

Can you send a link to your trigger? Curious if we can help figure out what is going on?

1 Like

Sure be my guest! Link to trigger

Hi, so you are running into a problem in MongoDB actually so I dont think using Watch will be any better unfortunately. We actually just merged in a change that will go live next week to at least show you what is going on and alert you when this happens but I can give you the gist here.

MongoDB has a document size limit of 16MB but that also applies to ChangeEvents. The MongoDB server is currently working on a project to avoid or circumvent this limitation for Change Events, but the issue you are running into is that your ChangeEvent is 24MB:

mongodb change stream closed with error: (BSONObjectTooLarge) Executor error during getMore :: caused by :: BSONObj size: 23576300 (0x167BEEC) is invalid. Size must be between 0 and 16793600(16MB) }

What can you do from here? There are a few options:

  1. Try to keep your documents a bit smaller
  2. Limit the use of FullDocument / PreImage unless you really need it
  3. Use the “Projection” field in the trigger to filter out fields that are very large that you dont actually need or care about.

Option 3 is probably your best bet here to avoid the issue entirely. Sorry for you going through this but it will be more visible in the UI in a few days and we are working on a longer-term fix.


Ah okay I see thanks! Yeah having some message would be really nice haha so I don’t just feel like I’m crazy. Yeah this document is massive though…

You should often be able to see what kind of events in general don’t get fired by the trigger. That way we can also debug match statements.

Yup. The error message fix will be in production in a few days. The other thing you mention is actually a project we aim to do at some point (ie, show you the 10 most recent change events and whether your match expression would return true or false to them)