Dp Transaction callback invoked for all other transactions too

My application has mulitple dps with its own transaction cb registered . I see tcbs are being invoked for all transactions .

I had put some print statement in init(), commit(), abort() in my tcb implementation, and it is getting printed even when the transactions are happening for other dps. It doesn’t cause any error.

so If there are 3 tcbs each registered as part of 3 dps. would all three of them get called everytime there is any transaction ?

Within the same client application process (or the same thread), there is only one set of transaction callbacks that can be registered with a given daemon context and they will be shared by all your data provider callpoints that are registered with the same daemon context.

If you would like to have different transaction callbacks for each of your data provider callpoints, you will need to write separate applications (or multiple threads) for each of them.

when the tcbs are registered in different threads, would tcbs in all threads be invoked for any transaction ?

No, only the transaction callbacks associated with the data provider callbacks through the same daemon context for that transaction.

Sorry I was not clear while asking the question :

This is my tcb
class TransCbs(object):
Transaction callback needed by confd

def __init__(self, workersocket,maapisocket):
    self._workersocket = workersocket
    self._maapisocket = maapisocket

def cb_init(self, tctx):
        maapi.attach(self._maapisocket, 0, tctx)
        dp.trans_set_fd(tctx, self._workersocket)
        print(" TRANS CALLBACK INIT DONE")
        print("Transaction handle is %s" %(tctx.th))
        return _confd.CONFD_OK

def cb_finish(self, tctx):
    maapi.detach(self._maapisocket, tctx)
    return _confd.CONFD_OK

def cb_abort(self, tctx):
  print "Transaction is being aborted"
  return _confd.CONFD_OK

def cb_commit(self, tctx):
   print "Transaction is being committed"
   return _confd.CONFD_OK

So all the above print statements are getting printed for any transaction that happed. The data callbacks are invoked correctly.
So do the tcb methods get invoked for any transaction, or is it a bug in my code ?

Yes, all of the transaction callbacks for configuration data will always be invoked for all transactions. This isn’t a bug in your code.

The intention with the transaction callback is that it allows you to orchestrate transactions with multiple sources of data (external data i.e not CDB), ConfD implements a two-phase commit protocol towards all data sources that participate in a transaction. Thus so you have the possibility e.g from a prepare callback abort the transaction.

Thank you Waitai for answering my queries.