couchbase

Does couchbase eventing service stores events indefinitely?


I was following following link to learn about eventing service in couchbase server: https://docs.couchbase.com/server/current/eventing/eventing-example-data-enrichment.html

I have a couple of queries:

  1. In case #2 article asks us to undeploy the function created for case #1. why? is it because that function will also be triggered, and try to upsert same doc?
  2. In both the cases, article made some changes in db, then created/deployed the functions. Does it mean that couchbase stores all the mutation history somewhere, and as and when I create some eligible function, it gets automatically applied to all the existing mutations? I read in the docs, that couchbase doesn't store these mutations indefinitely, but didn't got much detail - like for how long, etc..
  3. If I had a scenario like this where I would like to run a certain function on all existing mutation ever occured in some collection, can I rely on couchbase to be storing all these mutations? Or should I look for some other solutioning?

Solution

  • In case #2 article asks us to undeploy the function created for case #1. why? is it because that function will also be triggered, and try to upsert same doc?

    Yes you would have infinite recursion (each function receiving update/mutations form the other function and so and so on).

    In both the cases, article made some changes in db, then created/deployed the functions. Does it mean that couchbase stores all the mutation history somewhere, and as and when I create some eligible function, it gets automatically applied to all the existing mutations? I read in the docs, that couchbase doesn't store these mutations indefinitely, but didn't got much detail - like for how long, etc..

    Couchbase typically stores deduped values i.e. the most recent. Thus if you run Eventing and add the same document key once a minute Evening will respond to each change. But is you undeploy eventing and redeploy it (from everything) it will start with the most recent deduped change to that key and then see the updates. Refer to https://docs.couchbase.com/server/current/eventing/eventing-faq.html#change-capture

    Now with that said there is a very new feature coming out called "Change Streams" where dedupe can be turned off BUT you will have a cutoff time or cutoff size in bytes to keep the full history.

    If I had a scenario like this where I would like to run a certain function on all existing mutation ever occured in some collection, can I rely on couchbase to be storing all these mutations? Or should I look for some other solutioning?

    Change streams will give you a "window" of time and/or size. Another why to do this might be to add a timestamp to a key and write things to another collection.