MongoDB Trigger not firing

Hello. I have a problem with my mongoDB trigger on production. Somehow it doesn’t get fired on certain documents and i can’t figure out why. Mentioning that i have about 500K triggers firing every day. Is it a limitation or something? This doesn’t happen on my other enviornments.
Thanks!

Hi @Ciprian_Stanciu,

MongoDB Realm limits the execution of Trigger Functions to a rate of 1000 executions per second across all Triggers in an application. If additional Triggers fire beyond this threshold, MongoDB Realm adds their associated Function calls to a queue and executes the Function calls once capacity becomes available.

Are the triggers not happening on specific operations ir specific times?

Can you link the application.

Best
Pavel

Hello Pavel,

i’ve read about that threshold but i don’t think we have so many triggers happening per second. The triggers are not happening on specific documents from what i saw.
Here is a link to the application: https://cloud.mongodb.com/v2/5d19ce28553855145411eda4#clusters/detail/mongodb-stocks

Thanks!

@Ciprian_Stanciu What is the significance of those documents and what operations are expected to trigger the code?

Best
Pavle

Those documents are just some numeric values. The trigger should fire at every update/insert/replace and calculate a sum accoring to the values in the counters.

Here is an example of a document from the “stock” collection on which the trigger didn’t work yesterday, but today when there aren’t so many triggers it is working.

{"_id":{"$oid":"5dd354063e3fa30014cc6ed9"},"id":"017_11507636","entity":"017","product":"11507636","counters":[{"code":"c01","value":{"$numberInt":"1"}},{"code":"c04","value":{"$numberInt":"0"}},{"code":"c07","value":{"$numberInt":"0"}},{"code":"c08","value":{"$numberInt":"0"}},{"code":"c09","value":{"$numberInt":"0"}},{"code":"c12","value":{"$numberInt":"0"}},{"code":"c13","value":{"$numberInt":"0"}},{"code":"c14","value":{"$numberInt":"0"}},{"code":"c25","value":{"$numberInt":"0"}},{"code":"c26","value":{"$numberInt":"0"}},{"code":"c27","value":{"$numberInt":"0"}}],"last_modified":"2020-08-26T23:31:40.910393000Z"}