Candidate DB subscription

Hello all, I need some clarification on reading data from candidate DB.
My requirement is as below, currently i have enabled candidate DB with confd implimentation , and running DB as writtable through candidate.

Now from application side i need to subscribe to candidate dB and whenever any edit config operation got performed on candidate , need to read the data (xpath and values) , similar way cdb_subscribe got triggered for edit config on running DB.

Is there any Direct confd API similar to cdb_subscribe to subscribe into candidate DB?
Two phase validation will help here? as per my understanding two phase validation is for running DB, or is it possible for candidate DB? went through example available on confd, but getting confused as here some callbacks are getting registered. is this really need this way to serve my requirement?
Kindly help me with the information and also if any example code kindly refer


Hi Kamala,

perhaps you can try maapi_diff_iterate. One option may be to create validation point on top of your datamodel you want to iterate and call maapi_diff_iterate from validation callback.



Hi @mnovak , Thanks for the reply,

below are my queries
1.If we use the validation point on top of data model, whenever edit config happened in candidate DB ,the validation callpoint will get invoked or only upon committing to running DB?
2. maapi_diff_iterate will iterate through all the paths under datamodel path where validation point been added right not only the edited paths, but need to fetch only xpaths which been modified via edit config similar to cdb_diff_iterate, is this possible with maapi_diff_iterate?


Hi @Kamala.V ,

  1. The validation point is part of transaction processing and with candidate it is invoked when commit starts. You can test it on small example.

  2. maapi_diff_iterate is not related to validation point, it will iterate over all changed (diff) paths.
    But you can invoke maapi_diff_iterate from validation point. This can be used if you want to check (or sort) changed configuration before transaction goes to commit phase.

Looking at your original question, maybe you can use also two phase subscription. See documentation to cdb_subscribe2. With two phase subscription you can still abort transaction in PREPARE phase, if something goes wrong. (Even though it is not primarily intended for validation I guess).


got it, Thanks @mnovak .
yes two phase subscription will serve my requirement.will check on it more.

one small query i have on two phase subscription is,
using netconf console interface performing
lock DB, edit-config and then unlock,
then using any cdb/maapi api can trigger commit operation? this is possible right?

or we need to follow lock,edit-config.commit and unlock always?


With two phase subscription, I suggest you do all validation and work in the PREPARE phase.
In the COMMIT phase you just do nothing. If you get ABORT flag, then you have to be prepared to revert everything you did in PREPARE phase (e.g. configuration of devices). But if you use ti just for validation, then probably nothing is needed. Also note, the ABORT receives only subscriber that successfully performed PREPARE phase.

Here is sequence diagram for two phase subscription and multiple subscribers.

You cannot perform commit operation with CDB API. You can do it with maapi, but I guess you need to be in the same transaction and you will not have transaction ID from netconf console. My guess is it will not work for sure for CLI, but I’m not sure when you edit candidate with NETCONF. Please, try.