Product: Berkeley DBXML 2.2.13, transactional data store (multi threaded)
Language: C++ (Microsoft Visual Studio 2005)
While performing queries on a container. I sometimes get a document that reutrns an empty string when I call XmlDocument::getContent. All of my writes are transactionally protected and I am not deleting any doucments. The query that I perform returns certain documents if values in some elements meet some criteria. Since I am querying on this data, isn't it logical to assume that the returned document should contain some of the data that was used to find it in the query?
Thanks in advance for any help you can provide.
The environment is created using the following:
env = new DbEnv(0);
env->set_lk_detect(DB_LOCK_YOUNGEST);
env->setFlags(DB_DIRECT_LOG | DB_DIRECT_DB);
env->open(path,
DB_CREATE |
DB_INIT_TXN |
DB_INIT_LOG |
DB_INIT_LOCK |
DB_INIT_MPOOL |
DB_RECOVER |
DB_PRIVATE |
DB_THREAD,
0);
The container is opened with the following flags set:
DBXML_TRANSASCTIONAL | DB_THREAD | DB_CREATE
// Here is a sample of the function that I use to query the database
void MyClass::queryFunction(std::string queryString)
{
XmlTransaction txn;
int numRetry = 0;
while(numRetry < MAX_RETRY)
{
try
{
txn = xmlManager.createTransaction( DB_DEGREE_2 );
XmlQueryContext queryContext = xmlManager.createQueryContext();
XmlResults queryResults = xmlManager.query(txn,
queryString,
queryContext,
DB_DEGREE_2);
std::string docContents;
XmlDocument foundDoc;
foundDoc = xmlManager.createDocument();
while(queryResult.next(foundDoc))
{
//-----------------------------
// Sometimes this is null??????
//-----------------------------
foundDoc.getContent(docContents);
// do some stuff with the returned contents
}
txn.commmit;
return;
}
catch(XmlException& xe)
{
txn.abort();
if(xe.getExceptionCode() == DatabaseError &&
xe.getDbErrNo() == DB_LOCK_DEADLOCK)
{
numRetry++;
}
else
{
// Some error... assert
}
}
// More catch blocks...
}
// Too many retries, exit with error
}