This discussion is archived
6 Replies Latest reply: Nov 20, 2012 9:33 AM by Lucas Vogel RSS

Oracle dbxml2.5.16:crash with query execute()

970139 Newbie
Currently Being Moderated
Hi,

I encountered following crash while using DBXML 25.16 with C++ in multi-threaded environment:

#0 0x0fa28704 in DbXml::NsDomElement::NsDomElement(DbXml::NsNode*, DbXml::NsDoc*) () from /usr/MotoAgent/thirdparty/lib/libdbxml-2.5.so
#1 0x0fa29928 in DbXml::NsDomElement::getElemParent() () from /usr/MotoAgent/thirdparty/lib/libdbxml-2.5.so
#2 0x0fa01b50 in DbXml::ElementDescendantAxis::nextNode(DynamicContext*) () from /usr/MotoAgent/thirdparty/lib/libdbxml-2.5.so
#3 0x0f9ff6cc in DbXml::DbXmlAxis::next(DynamicContext*) () from /usr/MotoAgent/thirdparty/lib/libdbxml-2.5.so
#4 0x0fad68d0 in DbXml::SortingStepIterator::next(DynamicContext*) () from /usr/MotoAgent/thirdparty/lib/libdbxml-2.5.so
#5 0x0fac5f98 in DbXml::DecisionPointIterator::next(DynamicContext*) () from /usr/MotoAgent/thirdparty/lib/libdbxml-2.5.so
#6 0x0fabcef0 in DbXml::QueryPlanToASTResult::next(DynamicContext*) () from /usr/MotoAgent/thirdparty/lib/libdbxml-2.5.so
#7 0x0f31e958 in ResultImpl::nextOrTail(Result&, DynamicContext*) () from /usr/MotoAgent/thirdparty/lib/libxqilla.so.5
#8 0x0f31ea48 in ResultImpl::next(DynamicContext*) () from /usr/MotoAgent/thirdparty/lib/libxqilla.so.5
#9 0x0fb49644 in DbXml::LazyDIResults::next(DbXml::XmlValue&) () from /usr/MotoAgent/thirdparty/lib/libdbxml-2.5.so
#10 0x0fb739fc in DbXml::XmlResults::next(DbXml::XmlValue&) () from /usr/MotoAgent/thirdparty/lib/libdbxml-2.5.so
#11 0x0fb43798 in DbXml::ValueResults::init(DbXml::XmlResults&) () from /usr/MotoAgent/thirdparty/lib/libdbxml-2.5.so
#12 0x0fb48ebc in DbXml::ValueResults::ValueResults(DbXml::Results*, DbXml::XmlManager&, DbXml::Transaction*) () from /usr/MotoAgent/thirdparty/lib/libdbxml-2.5.so
#13 0x0fb4cb48 in DbXml::QueryExpression::execute(DbXml::Transaction*, DbXml::Value*, DbXml::XmlQueryContext&, unsigned int) ()
from /usr/MotoAgent/thirdparty/lib/libdbxml-2.5.so
#14 0x0fb725a4 in DbXml::XmlQueryExpression::execute(DbXml::XmlTransaction&, DbXml::XmlQueryContext&, unsigned int) const () from /usr/MotoAgent/thirdparty/lib/libdbxml-2.5.so


Any patch or workaround to get rid of this issue?
  • 1. Re: Oracle dbxml2.5.16:crash with query execute()
    Lucas Vogel Newbie
    Currently Being Moderated
    Can you post the query as well as the exception? The call stack helps, but the other two pieces of information would help even more.

    Thanks
  • 2. Re: Oracle dbxml2.5.16:crash with query execute()
    970139 Newbie
    Currently Being Moderated
    my program crashed without any execption.
    I'm running multiple queries from mutiple threads to simualte a scenaio seen in production environment and got his crash 3 times.
    I've 9 threads running where 5 threads are reading one XML entry in one document and 1 thread is adding entry into smae document and 2 threads trying to delete the XML entries from the same document. The last thread is reading metadata.

    3 crashes with same crash signature seen in reading thread. Below is the code which does perform query:

    int performQuery(DbXml::XmlManager *&m_manager_, string & p_queryResult,
    const string & p_query,
    const map < string, string > *p_pExternalValues)
    {
    // Check the input params
    if (p_query.empty())
    {
    cout << ("Empty XQuery/XQueryUpdate expression");
    return MA_GENERAL_ERROR;
    }

    u_int32_t my_txn_flags = DB_READ_COMMITTED | DB_TXN_NOSYNC |
    DB_TXN_NOWAIT;
    if (p_queryResult == C_BDBXML_PERFORM_UPDATE)
    {
    my_txn_flags = DB_TXN_SYNC | DB_TXN_NOWAIT;
    }


    XmlResults my_results;
    int retry_count = 0;
    XmlTransaction my_txn;
    while (retry_count < C_BDBXML_MAX_RETRIES)
    {
    try
    {

    // The query context
    XmlQueryContext my_qc = m_manager_->createQueryContext();

    my_qc.setEvaluationType(XmlQueryContext::Eager);
    // Set external variables
    if (p_pExternalValues != NULL)
    {
    map < string, string >::const_iterator it;
    for (it = p_pExternalValues->begin();
    it != p_pExternalValues->end(); ++it)
    {
    my_qc.setVariableValue(it->first, it->second);

    // cout << "external " << it->first << " " << it->second << endl;
    }
    }

    // Start transaction
    my_txn = m_manager_->createTransaction(my_txn_flags);

    // Compile the query
    XmlQueryExpression my_query_expr =
    m_manager_->prepare(my_txn, p_query, my_qc);

    // Perform the query
    my_results = my_query_expr.execute(my_txn, my_qc, 0);


    // If the method is performing XQuery, parse the results
    if (p_queryResult != C_BDBXML_PERFORM_UPDATE)
    {
    p_queryResult.clear();

    // Parse the results
    XmlValue my_value;
    while (my_results.next(my_value))
    {
    p_queryResult += my_value.asString();
    }
    }
    my_txn.commit();
    return CNEOMI_SUCCESS;
    }
    catch(const XmlException & xe)
    {
    bool ret = handleXmlException(xe, my_txn, retry_count);
    if(ret != CNEOMI_SUCCESS)
    {
    CL_LOG_ERROR_STREAM("Failed to execute the XQuery: " <<
    p_query);
    if(ret != CNEOMI_SUCCESS)
    {
    CL_LOG_ERROR_STREAM("Failed to execute the XQuery: " <<
    p_query);

    return ret;
    }
    }
    }

    CL_LOG_ERROR("Exceeded retry limit. Giving up");
    return 2;
    }


    And here is my read xquery that crashed:

    string docid = string("dbxml:/ma.dbxml/") + (char *)arg;

    string query = string("declare variable $self as xs:string external;doc($self)//*//*:") + "clAgentClientOperation";
    map<string,string> myexternalValues;
    myexternalValues.insert(make_pair<string,string>("self",
    docid));
    string queryResult;
    performQuery(myManager,queryResult,
    query,
    &myexternalValues);
  • 3. Re: Oracle dbxml2.5.16:crash with query execute()
    970139 Newbie
    Currently Being Moderated
    my program crashed without any execption.
    I'm running multiple queries from mutiple threads to simualte a scenaio seen in production environment and got his crash 3 times.
    I've 9 threads running where 5 threads are reading one XML entry in one document and 1 thread is adding entry into smae document and 2 threads trying to delete the XML entries from the same document. The last thread is reading metadata.

    3 crashes with same crash signature seen in reading thread. Below is the code which does perform query:

    int performQuery(DbXml::XmlManager *&m_manager_, string & p_queryResult,
    const string & p_query,
    const map < string, string > *p_pExternalValues)
    {
    // Check the input params
    if (p_query.empty())
    {
    cout << ("Empty XQuery/XQueryUpdate expression");
    return MA_GENERAL_ERROR;
    }

    u_int32_t my_txn_flags = DB_READ_COMMITTED | DB_TXN_NOSYNC |
    DB_TXN_NOWAIT;
    if (p_queryResult == C_BDBXML_PERFORM_UPDATE)
    {
    my_txn_flags = DB_TXN_SYNC | DB_TXN_NOWAIT;
    }


    XmlResults my_results;
    int retry_count = 0;
    XmlTransaction my_txn;
    while (retry_count < C_BDBXML_MAX_RETRIES)
    {
    try
    {

    // The query context
    XmlQueryContext my_qc = m_manager_->createQueryContext();

    my_qc.setEvaluationType(XmlQueryContext::Eager);
    // Set external variables
    if (p_pExternalValues != NULL)
    {
    map < string, string >::const_iterator it;
    for (it = p_pExternalValues->begin();
    it != p_pExternalValues->end(); ++it)
    {
    my_qc.setVariableValue(it->first, it->second);

    // cout << "external " << it->first << " " << it->second << endl;
    }
    }

    // Start transaction
    my_txn = m_manager_->createTransaction(my_txn_flags);

    // Compile the query
    XmlQueryExpression my_query_expr =
    m_manager_->prepare(my_txn, p_query, my_qc);

    // Perform the query
    my_results = my_query_expr.execute(my_txn, my_qc, 0);


    // If the method is performing XQuery, parse the results
    if (p_queryResult != C_BDBXML_PERFORM_UPDATE)
    {
    p_queryResult.clear();

    // Parse the results
    XmlValue my_value;
    while (my_results.next(my_value))
    {
    p_queryResult += my_value.asString();
    }
    }
    my_txn.commit();
    return CNEOMI_SUCCESS;
    }
    catch(const XmlException & xe)
    {
    bool ret = handleXmlException(xe, my_txn, retry_count);
    if(ret != CNEOMI_SUCCESS)
    {
    CL_LOG_ERROR_STREAM("Failed to execute the XQuery: " <<
    p_query);
    if(ret != CNEOMI_SUCCESS)
    {
    CL_LOG_ERROR_STREAM("Failed to execute the XQuery: " <<
    p_query);

    return ret;
    }
    }
    }

    CL_LOG_ERROR("Exceeded retry limit. Giving up");
    return 2;
    }


    And here is my read xquery that crashed:

    string docid = string("dbxml:/ma.dbxml/") + (char *)arg;

    string query = string("declare variable $self as xs:string external;doc($self)//*//*:") + "clAgentClientOperation";
    map<string,string> myexternalValues;
    myexternalValues.insert(make_pair<string,string>("self",
    docid));
    string queryResult;
    performQuery(myManager,queryResult,
    query,
    &myexternalValues);
  • 4. Re: Oracle dbxml2.5.16:crash with query execute()
    Bogdan Coman Journeyer
    Currently Being Moderated
    I was wondering, does the container verify successfully after the issue occurs?

    http://docs.oracle.com/cd/E17276_01/html/api_reference/C/db_verify.html

    Bogdan Coman
  • 5. Re: Oracle dbxml2.5.16:crash with query execute()
    970139 Newbie
    Currently Being Moderated
    Hi,

    Thank you very much for your reply. Yes, db_verify is successful after this crash.

    Is there any fix for this issue?

    Thanks and Regards,
    Vasu
  • 6. Re: Oracle dbxml2.5.16:crash with query execute()
    Lucas Vogel Newbie
    Currently Being Moderated
    I'd say that, given that it's still difficult to tell what exactly the issue is, there probably isn't a fix for it, or at least not one that comes to mind immediately. It looks like you're reaching the upper limits of what you can achieve with that many threads reading, writing and updating a single document simultaneously.

    Things you might want to try:

    - creating an in-memory copy of the document you're operating on and using strict xerces/xqilla or another approach to the operations you're performing on the document.

    - refactoring your database so that everything you're trying to operate on isn't contained in one single, monolithic document within the database. Find the element that repeats the most frequently within your document and break it down into multiple documents containing that element within the database. Think of it as "XML database normalization" - while you can insert a single, huge document into an XML database and perform operations on it, it kind of defeats the purpose of having a database in the first place if you're not optimizing your storage (and, subsequently, your indexing/optimization/query/etc.) capabilities.

    Neither suggestion is ideal from an application maintenance perspective, but hopefully your application architecture allows for modification/optimization of the database operations without having a large imprint on the rest of the application itself...

    Hope this helps!

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points