Skip to content

InterruptedException causing error with properties #794

@sammefford

Description

@sammefford

I got the following error with the following code (from #779). The reason I log this against 3.0.8 is because while we don't have DMSDK in 3.0.8, some customers might be writing properties in a multithreaded env. And it appears that writing properties is interacting poorly with OkHttp. What I mean is it appears Okio throws InterruptedException and the com.sun.xml.internal.stream.writers.XMLStreamWriterImpl.flush method doesn't like that so it throws an error.

import com.marklogic.client.DatabaseClient;
import com.marklogic.client.DatabaseClientFactory;
import com.marklogic.client.DatabaseClientFactory.BasicAuthContext;
import com.marklogic.client.DatabaseClientFactory.DigestAuthContext;
import com.marklogic.client.io.DocumentMetadataHandle;
import com.marklogic.client.datamovement.DataMovementManager;
import com.marklogic.client.datamovement.JobTicket;
import com.marklogic.client.datamovement.WriteBatcher;
import com.icentris.util.CodeTimer;

public class Issue779DMSDK {
  public static void main(String[] args) {
    CodeTimer timer = new CodeTimer();
    timer.start();
    DatabaseClient databaseClient = DatabaseClientFactory.newClient("engrlab-129-192.engrlab.marklogic.com", 8012, new BasicAuthContext("admin", "admin"));
    DataMovementManager dataMovementManager = databaseClient.newDataMovementManager();

    WriteBatcher writeBatcher = dataMovementManager.newWriteBatcher()
      .withBatchSize(100)
      .withThreadCount(64);
    JobTicket jobTicket = dataMovementManager.startJob(writeBatcher);
    DocumentMetadataHandle meta = new DocumentMetadataHandle()
      .withCollections("Issue779DMSDK")
      .withProperty("testProp1", "testValue1");
    for ( int i=0; i < 100000; i++ ) {
      writeBatcher.addAs(i + ".txt", meta, "abc");
    }
    writeBatcher.flushAndWait();
    dataMovementManager.stopJob(jobTicket);
    dataMovementManager.release();
    databaseClient.release();
    timer.stop();
    System.out.println(CodeTimer.getTimingsReport());
  }
}
com.marklogic.client.MarkLogicIOException: Failed to serialize metadata
        at com.marklogic.client.io.DocumentMetadataHandle.sendMetadataImpl(DocumentMetadataHandle.java:801) ~[marklogic-client-api-5.0-SNAPSHOT.jar:na]
        at com.marklogic.client.io.DocumentMetadataHandle.write(DocumentMetadataHandle.java:574) ~[marklogic-client-api-5.0-SNAPSHOT.jar:na]
        at com.marklogic.client.impl.StreamingOutputImpl.writeTo(StreamingOutputImpl.java:58) ~[marklogic-client-api-5.0-SNAPSHOT.jar:na]
        at okhttp3.MultipartBody.writeOrCountBytes(MultipartBody.java:171) ~[okhttp-3.6.0.jar:na]
        at okhttp3.MultipartBody.writeTo(MultipartBody.java:113) ~[okhttp-3.6.0.jar:na]
        at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java:59) ~[okhttp-3.6.0.jar:na]
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92) ~[okhttp-3.6.0.jar:na]
        at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:45) ~[okhttp-3.6.0.jar:na]
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92) ~[okhttp-3.6.0.jar:na]
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67) ~[okhttp-3.6.0.jar:na]
        at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93) ~[okhttp-3.6.0.jar:na]
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92) ~[okhttp-3.6.0.jar:na]
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67) ~[okhttp-3.6.0.jar:na]
        at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93) ~[okhttp-3.6.0.jar:na]
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92) ~[okhttp-3.6.0.jar:na]
        at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:120) ~[okhttp-3.6.0.jar:na]
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92) ~[okhttp-3.6.0.jar:na]
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67) ~[okhttp-3.6.0.jar:na]
        at com.marklogic.client.impl.HTTPBasicAuthInterceptor.intercept(HTTPBasicAuthInterceptor.java:31) ~[marklogic-client-api-5.0-SNAPSHOT.jar:na]
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92) ~[okhttp-3.6.0.jar:na]
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67) ~[okhttp-3.6.0.jar:na]
        at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:179) ~[okhttp-3.6.0.jar:na]
        at okhttp3.RealCall.execute(RealCall.java:63) ~[okhttp-3.6.0.jar:na]
        at com.marklogic.client.impl.OkHttpServices.sendRequestOnce(OkHttpServices.java:677) ~[marklogic-client-api-5.0-SNAPSHOT.jar:na]
        at com.marklogic.client.impl.OkHttpServices.sendRequestOnce(OkHttpServices.java:670) ~[marklogic-client-api-5.0-SNAPSHOT.jar:na]
        at com.marklogic.client.impl.OkHttpServices.doPost(OkHttpServices.java:4006) ~[marklogic-client-api-5.0-SNAPSHOT.jar:na]
        at com.marklogic.client.impl.OkHttpServices.postResource(OkHttpServices.java:3303) ~[marklogic-client-api-5.0-SNAPSHOT.jar:na]
        at com.marklogic.client.impl.OkHttpServices.postBulkDocuments(OkHttpServices.java:3415) ~[marklogic-client-api-5.0-SNAPSHOT.jar:na]
        at com.marklogic.client.impl.DocumentManagerImpl.write(DocumentManagerImpl.java:613) ~[marklogic-client-api-5.0-SNAPSHOT.jar:na]
        at com.marklogic.client.impl.GenericDocumentImpl.write(GenericDocumentImpl.java:23) ~[marklogic-client-api-5.0-SNAPSHOT.jar:na]
        at com.marklogic.client.impl.DocumentManagerImpl.write(DocumentManagerImpl.java:605) ~[marklogic-client-api-5.0-SNAPSHOT.jar:na]
        at com.marklogic.client.impl.GenericDocumentImpl.write(GenericDocumentImpl.java:23) ~[marklogic-client-api-5.0-SNAPSHOT.jar:na]
        at com.marklogic.client.datamovement.impl.WriteBatcherImpl$BatchWriter.run(WriteBatcherImpl.java:1006) ~[marklogic-client-api-5.0-SNAPSHOT.jar:na]
        at com.marklogic.client.datamovement.impl.WriteBatcherImpl.retry(WriteBatcherImpl.java:479) [marklogic-client-api-5.0-SNAPSHOT.jar:na]
        at com.marklogic.client.datamovement.HostAvailabilityListener.processFailure(HostAvailabilityListener.java:157) ~[marklogic-client-api-5.0-SNAPSHOT.jar:na]
        at com.marklogic.client.datamovement.impl.WriteBatcherImpl.sendThrowableToListeners(WriteBatcherImpl.java:626) [marklogic-client-api-5.0-SNAPSHOT.jar:na]
        at com.marklogic.client.datamovement.impl.WriteBatcherImpl.lambda$newBatchWriteSet$2(WriteBatcherImpl.java:447) [marklogic-client-api-5.0-SNAPSHOT.jar:na]
        at com.marklogic.client.datamovement.impl.WriteBatcherImpl$BatchWriter.run(WriteBatcherImpl.java:1035) ~[marklogic-client-api-5.0-SNAPSHOT.jar:na]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[na:1.8.0_71]
        at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[na:1.8.0_71]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) ~[na:1.8.0_71]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) ~[na:1.8.0_71]
        at java.lang.Thread.run(Thread.java:745) ~[na:1.8.0_71]
Caused by: javax.xml.stream.XMLStreamException: java.io.InterruptedIOException: thread interrupted
        at com.sun.xml.internal.stream.writers.XMLStreamWriterImpl.flush(XMLStreamWriterImpl.java:399) ~[na:1.8.0_71]
        at com.marklogic.client.io.DocumentMetadataHandle.sendMetadataImpl(DocumentMetadataHandle.java:798) ~[marklogic-client-api-5.0-SNAPSHOT.jar:na]
        ... 42 common frames omitted
Caused by: java.io.InterruptedIOException: thread interrupted
        at okio.Timeout.throwIfReached(Timeout.java:146) ~[okio-1.11.0.jar:na]
        at okio.Okio$1.write(Okio.java:75) ~[okio-1.11.0.jar:na]
        at okio.AsyncTimeout$1.write(AsyncTimeout.java:179) ~[okio-1.11.0.jar:na]
        at okio.RealBufferedSink.flush(RealBufferedSink.java:216) ~[okio-1.11.0.jar:na]
        at okhttp3.internal.http1.Http1Codec$ChunkedSink.flush(Http1Codec.java:331) ~[okhttp-3.6.0.jar:na]
        at okio.RealBufferedSink.flush(RealBufferedSink.java:218) ~[okio-1.11.0.jar:na]
        at okio.RealBufferedSink$1.flush(RealBufferedSink.java:199) ~[okio-1.11.0.jar:na]
        at com.sun.xml.internal.stream.writers.UTF8OutputStreamWriter.flush(UTF8OutputStreamWriter.java:138) ~[na:1.8.0_71]
        at com.sun.xml.internal.stream.writers.XMLStreamWriterImpl.flush(XMLStreamWriterImpl.java:397) ~[na:1.8.0_71]
        ... 43 common frames omitted

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions