Hi Eric  and David,

Thanks a lot for suggestions. We are going to refactor the code and remove 
multi statement transaction from there.
It was written for a requirement where if any of the document load fails we had 
to roll back everything.

Regards,
Abhinav

From: [email protected] 
[mailto:[email protected]] On Behalf Of Erik Hennum
Sent: Tuesday, August 18, 2015 6:45 PM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] Server Message: SVC-EXTIME: 
xdmp:lock-for-update("/docs/0f04c4fb-6058-4758-92eb-f9cfa2ea18bc") -- Time 
limit exceeded.

Hi, Abhinav:

It looks like you are hitting the transaction time limit before committing the 
multi-statement transaction, so the transaction no longer exists for those 
writes.

It's not a good idea to build up huge transactions. In particular, the code 
that's trying to pool the multi-statement transactions might misunderstand the 
purpose of multi-statement transactions in MarkLogic.

Really, multi-statement transactions are for changes that must commit or fail 
together to leave the database in a consistent state.  The canonical examples 
are a balance transfer or the write and delete operations for a document move.

If the write for one document failed to write (maybe it had a bad format) and 
the rest wrote correctly, would that be preferable to having all writes fail?  
If so, you shouldn't use multi-statement transactions. Single document writes 
are still transactional without the explicit multi-statement transaction.

If you're using MarkLogic 8, you might also consider writing documents in bulk 
(typically of around 100 for optimal sized documents) for better performance.  
Bulk writes are also transactional.


Hoping that helps,


Erik Hennum
________________________________
From: 
[email protected]<mailto:[email protected]>
 [[email protected]] on behalf of 
[email protected]<mailto:[email protected]> 
[[email protected]]
Sent: Tuesday, August 18, 2015 5:05 AM
To: [email protected]<mailto:[email protected]>
Subject: Re: [MarkLogic Dev General] Server Message: SVC-EXTIME: 
xdmp:lock-for-update("/docs/0f04c4fb-6058-4758-92eb-f9cfa2ea18bc") -- Time 
limit exceeded.
Hi Team,
Just want add few more info. We are sometimes getting below errors as well.

Java Layer:
com.marklogic.client.FailedRequestException: Local message: transaction 
rollback failed: Bad Request. Server Message: XDMP-NOTXN: 
xdmp:xa-complete1(xs:unsignedLong("5231619190085809367"), 
xs:unsignedLong("13101616944000907690"), fn:false()) -- No transaction with 
identifier 13101616944000907690
       at 
com.marklogic.client.impl.JerseyServices.completeTransaction(JerseyServices.java:1488)
       at 
com.marklogic.client.impl.JerseyServices.rollbackTransaction(JerseyServices.java:1420)
       at 
com.marklogic.client.impl.TransactionImpl.rollback(TransactionImpl.java:70)


MarkLogic Log:
2015-08-18 15:39:24.551 Info: REST-ContentStore: Status 500: XDMP-NOTXN: 
xdmp:invoke("/MarkLogic/rest-api/lib/transaction-runner-update.xqy", 
(as:QName("", "method"), "PUT", as:QName("", "headers"), ...), <options 
xmlns="xdmp:eval"><transaction-id>13101616944000907690</transaction-id></options>)
 -- No transaction with identifier 13101616944000907690
2015-08-18 15:39:25.347 Info: REST-ContentStore: Status 500: XDMP-NOTXN: 
xdmp:xa-complete1(xs:unsignedLong("5231619190085809367"), 
xs:unsignedLong("13101616944000907690"), fn:false()) -- No transaction with 
identifier 13101616944000907690

Regards,
Abhinav
From: Mishra, Abhinav Kumar (Cognizant)
Sent: Tuesday, August 18, 2015 12:24 PM
To: [email protected]<mailto:[email protected]>
Subject: Server Message: SVC-EXTIME: 
xdmp:lock-for-update("/docs/0f04c4fb-6058-4758-92eb-f9cfa2ea18bc") -- Time 
limit exceeded.

Hi Team,
We are running into an issue, where in we are getting exception from MarkLogic 
as given below:

"write failed: Internal Server Error. Server Message: SVC-EXTIME: 
xdmp:lock-for-update("/docs/0f04c4fb-6058-4758-92eb-f9cfa2ea18bc") -- Time 
limit exceeded."

But In MarkLogic logs I don't see any log for the above statement. I have 
enabled log to debug mode on MarkLogic as well. We are not sure what is the 
exact reason of this failure.
I would really appreciate if you can provide some clues.

Now let me explain what we are doing..

We are saving xml documents to MarkLogic from a java based application. We have 
used MarkLogic' s OOTB REST Java Client API. It will internally use 
"/documents" service via PUT request.
I have highlighted the RESTServices.putDocument(..) method below which will 
actually put the documents to MarkLogic.
We are opening the transaction, saving document to MarkLogic and then closing 
the transaction.


Code snippet:

   //rest-user has all the privileges required to load the documents in 
MarkLogic.
      DatabaseClient client = DatabaseClientFactory.newClient("<somehost>", 
8004,rest-user, rest-user-password, Authentication.DIGEST);
      Transaction transaction = client.openTransaction();

        try {
          //Here we are sending following parameters from outside, "[String 
path, InputStream is, Transaction transaction, String collection]"
        //Where, path="/docs/0f04c4fb-6058-4758-92eb-f9cfa2ea18bc"
     // InputStream will have the xml document as a stream
    // transaction is the implementation of com.marklogic.clinet.Transaction
    // collection = "doc-versions"


         TransactionPoolableFactory transactionFactory = new 
TransactionPoolableFactory();
         GenericKeyedObjectPool<Transaction, DatabaseClient> transactionPool = 
new GenericKeyedObjectPool<Transaction, DatabaseClient>(transactionFactory);
         transactionPool.setTestOnReturn(true);
            DatabaseClient client = transactionPool.borrowObject(transaction);
            InputStreamHandle handle = new InputStreamHandle(is);
            DocumentMetadataHandle metadata = new DocumentMetadataHandle();
            metadata.getCollections().addAll(collection);
            DocumentManager<XMLReadHandle, XMLWriteHandle> docMgr = 
client.newXMLDocumentManager();
            docMgr.write(path, metadata, handle, transaction);
           transactionPool.returnObject(transaction, client);

       transaction.commit();
        try {
            DatabaseClient client = transactionPool.borrowObject(transaction);
            transactionPool.invalidateObject(transaction, client);
        } catch (Exception e) {
            throw new MarkLogicException(e.getMessage(), e);
        }

        } catch (Exception e) {
            e.printStackTrace();

                transaction.rollback();
        try {
            DatabaseClient client = transactionPool.borrowObject(transaction);
            transactionPool.invalidateObject(transaction, client);
       } catch (Exception e) {
            throw new MarkLogicException(e.getMessage(), e);
        }
        }


The highlighted "write" method is the implementation of DocumentManager 
interface, see the snippet below:

Interface:
package com.marklogic.client.document;

import com.marklogic.client.FailedRequestException;
import com.marklogic.client.ForbiddenUserException;
import com.marklogic.client.ResourceNotFoundException;
import com.marklogic.client.Transaction;
import com.marklogic.client.io.Format;
import com.marklogic.client.io.marker.AbstractReadHandle;
import com.marklogic.client.io.marker.AbstractWriteHandle;
import com.marklogic.client.io.marker.DocumentMetadataReadHandle;
import com.marklogic.client.io.marker.DocumentMetadataWriteHandle;
import com.marklogic.client.io.marker.DocumentPatchHandle;
import com.marklogic.client.util.RequestLogger;
import java.util.Set;

public abstract interface DocumentManager<R extends AbstractReadHandle, W 
extends AbstractWriteHandle> {
.....
.....
public abstract void write(String paramString,
                                                DocumentMetadataWriteHandle 
paramDocumentMetadataWriteHandle,
                                                W paramW, Transaction 
paramTransaction)
                                                throws 
ResourceNotFoundException, ForbiddenUserException,
                                                FailedRequestException;

.....
.....
....
.
}

Implementation:

package com.marklogic.client.impl;

import com.marklogic.client.DatabaseClientFactory.HandleFactoryRegistry;
import com.marklogic.client.FailedRequestException;
import com.marklogic.client.ForbiddenUserException;
import com.marklogic.client.ResourceNotFoundException;
import com.marklogic.client.Transaction;
import com.marklogic.client.document.DocumentDescriptor;
import com.marklogic.client.document.DocumentManager;
import com.marklogic.client.document.DocumentManager.Metadata;
import com.marklogic.client.document.DocumentMetadataPatchBuilder;
import com.marklogic.client.document.DocumentUriTemplate;
import com.marklogic.client.document.ServerTransform;
import com.marklogic.client.io.Format;
import com.marklogic.client.io.marker.AbstractReadHandle;
import com.marklogic.client.io.marker.AbstractWriteHandle;
import com.marklogic.client.io.marker.ContentHandle;
import com.marklogic.client.io.marker.DocumentMetadataReadHandle;
import com.marklogic.client.io.marker.DocumentMetadataWriteHandle;
import com.marklogic.client.io.marker.DocumentPatchHandle;
import com.marklogic.client.util.RequestParameters;
import java.util.HashSet;
import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

abstract class DocumentManagerImpl<R extends AbstractReadHandle, W extends 
AbstractWriteHandle>
                                extends AbstractLoggingManager implements 
DocumentManager<R, W> {
                private static final Logger logger = LoggerFactory
                                                
.getLogger(DocumentManagerImpl.class);
                private final Set<DocumentManager.Metadata> processedMetadata;
                private RESTServices services;
                private Format contentFormat;
                private DatabaseClientFactory.HandleFactoryRegistry 
handleRegistry;
                private ServerTransform readTransform;
                private ServerTransform writeTransform;
                private String forestName;

                DocumentManagerImpl(RESTServices services, Format 
contentFormat) {
                                HashSet metadata = new HashSet();
                                metadata.add(DocumentManager.Metadata.ALL);
                                this.processedMetadata = metadata;

                                this.services = services;
                                this.contentFormat = contentFormat;
                }

                RESTServices getServices() {
                                return this.services;
                }

                void setServices(RESTServices services) {
                                this.services = services;
                }

                DatabaseClientFactory.HandleFactoryRegistry getHandleRegistry() 
{
                                return this.handleRegistry;
                }

.....
.....
....
.

public void write(String uri, DocumentMetadataWriteHandle metadataHandle,
                                                W contentHandle, Transaction 
transaction)
                                                throws 
ResourceNotFoundException, ForbiddenUserException,
                                                FailedRequestException {
                                write(uri, metadataHandle, contentHandle, null, 
transaction,
                                                                
getWriteParams());
                }

.....
.....
public void write(DocumentDescriptor desc,
                                                DocumentMetadataWriteHandle 
metadataHandle, W contentHandle,
                                                ServerTransform transform, 
Transaction transaction,
                                                RequestParameters extraParams) 
throws ResourceNotFoundException,
                                                ForbiddenUserException, 
FailedRequestException {
                                if (desc == null) {
                                                throw new 
IllegalArgumentException(
                                                                                
"Writing document with null identifier");
                                }
                                if (logger.isInfoEnabled()) {
                                                logger.info("Writing content 
for {}", desc.getUri());
                                }
                                if (metadataHandle != null) {
                                                HandleImplementation 
metadataBase = HandleAccessor.checkHandle(
                                                                                
metadataHandle, "metadata");
                                                Format metadataFormat = 
metadataBase.getFormat();
                                                if ((metadataFormat == null)
                                                                                
|| ((metadataFormat != Format.JSON) && (metadataFormat != Format.XML))) {
                                                                if 
(logger.isWarnEnabled())
                                                                                
logger.warn("Unsupported metadata format {}, using XML",
                                                                                
                                metadataFormat.name());
                                                                
metadataBase.setFormat(Format.XML);
                                                }
                                }

                                checkContentFormat(contentHandle);

                                this.services.putDocument(
                                                                
this.requestLogger,
                                                                desc,
                                                                (transaction == 
null) ? null : transaction.getTransactionId(),
                                                                (metadataHandle 
!= null) ? this.processedMetadata : null,
                                                                
mergeTransformParameters((transform != null) ? transform
                                                                                
                : getWriteTransform(), extraParams), metadataHandle,
                                                                contentHandle);
                }
....
.

}

Regards,
Abhinav
This e-mail and any files transmitted with it are for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
If you are not the intended recipient(s), please reply to the sender and 
destroy all copies of the original message. Any unauthorized review, use, 
disclosure, dissemination, forwarding, printing or copying of this email, 
and/or any action taken in reliance on the contents of this e-mail is strictly 
prohibited and may be unlawful. Where permitted by applicable law, this e-mail 
and other e-mail communications sent to and from Cognizant e-mail addresses may 
be monitored.
This e-mail and any files transmitted with it are for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
If you are not the intended recipient(s), please reply to the sender and 
destroy all copies of the original message. Any unauthorized review, use, 
disclosure, dissemination, forwarding, printing or copying of this email, 
and/or any action taken in reliance on the contents of this e-mail is strictly 
prohibited and may be unlawful. Where permitted by applicable law, this e-mail 
and other e-mail communications sent to and from Cognizant e-mail addresses may 
be monitored.
_______________________________________________
General mailing list
[email protected]
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to