Skip to Main Content

Berkeley DB Family

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Transactionally protected query contains an empty document

540783Oct 19 2006 — edited Oct 23 2006

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
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 20 2006
Added on Oct 19 2006
3 comments
612 views