ConfD User Community

Problem using cdb.getObjects in upgrade phase

Hi, I’ve written a simple Java application to run in confd phase0 in order to get values from an existing list in cdb and doing the modifications needed via maapi to upgrade some values and I need to get the key values of the list without knowing them in advance.
The problem is that an EOF exception is raised when the cdbSession.getObjects of the given path is called.
the cdbSession.getNumberOfInstances is giving the correct number of entries for the same path.
Furthermore the SAME code is working if confD is started in phase2 (obviously using maapi.StartUserSession(…) instead of maapi.attachInit).
I face the same problem with any list I’ve tried no matter how many entries are containing.
I’m using confd 7.3.2.
Any hint / help would be appreciated, Lorenzo.

final String rootPath = "/A/list";

try ( Socket maapiSock = new Socket("localhost", Conf.PORT);
	  Socket cdbSock = new Socket("localhost", Conf.PORT) ){
	LOGGER.info("Start upgrade");
	Maapi maapi = new Maapi(maapiSock);
	int th = maapi.attachInit();
	Cdb cdb = new Cdb("upgrade", cdbSock);
	CdbSession cdbSession = cdb.startUpgradeSession(CdbDBType.CDB_RUNNING);
	
	int numObjects = cdbSession.getNumberOfInstances(rootPath);
    if (numObjects > 0) {
        List<ConfObject[]> objArrList = cdbSession.getObjects(1, 0, numObjects, rootPath);
		for (ConfObject[] objArr : objArrList) {
            ConfValue major = (ConfValue) objArr[0];
			....doing stuff
		}
	}

com.tailf.conf.ConfException: unexpected end of file
at com.tailf.conf.ConfInternal.readFill(ConfInternal.java:422) ~[cdbUpgrader.jar:?]
at com.tailf.conf.ConfInternal.termRead(ConfInternal.java:192) ~[cdbUpgrader.jar:?]
at com.tailf.conf.ConfInternal.requestTerm(ConfInternal.java:548) ~[cdbUpgrader.jar:?]
at com.tailf.cdb.Cdb.requestTerm(Cdb.java:853) ~[cdbUpgrader.jar:?]
at com.tailf.cdb.CdbSession.getObjects(CdbSession.java:1473) ~[cdbUpgrader.jar:?]
at com.tailf.cdb.CdbUpgradeSession.getObjects(CdbUpgradeSession.java:201) ~[cdbUpgrader.jar:?]

HI,
Check the developer log with DeveloperLogLevel set to “trace” in your confd.conf (or confd_dyncfg_init.xml if dynamic config is enabled) for details on what is happening on the ConfD side when the socket to your CDB session is disconnected.