Search in sources :

Example 1 with NotSerializableExceptionWrapper

use of org.elasticsearch.common.io.stream.NotSerializableExceptionWrapper in project elasticsearch by elastic.

the class ExceptionSerializationTests method testNotSerializableExceptionWrapper.

public void testNotSerializableExceptionWrapper() throws IOException {
    NotSerializableExceptionWrapper ex = serialize(new NotSerializableExceptionWrapper(new NullPointerException()));
    assertEquals("{\"type\":\"null_pointer_exception\",\"reason\":\"null_pointer_exception: null\"}", Strings.toString(ex));
    ex = serialize(new NotSerializableExceptionWrapper(new IllegalArgumentException("nono!")));
    assertEquals("{\"type\":\"illegal_argument_exception\",\"reason\":\"illegal_argument_exception: nono!\"}", Strings.toString(ex));
    class UnknownException extends Exception {

        UnknownException(final String message) {
            super(message);
        }
    }
    Exception[] unknowns = new Exception[] { new Exception("foobar"), new ClassCastException("boom boom boom"), new UnknownException("boom") };
    for (Exception t : unknowns) {
        if (randomBoolean()) {
            t.addSuppressed(new UnsatisfiedLinkError("suppressed"));
            t.addSuppressed(new NullPointerException());
        }
        Throwable deserialized = serialize(t);
        assertTrue(deserialized.getClass().toString(), deserialized instanceof NotSerializableExceptionWrapper);
        assertArrayEquals(t.getStackTrace(), deserialized.getStackTrace());
        assertEquals(t.getSuppressed().length, deserialized.getSuppressed().length);
        if (t.getSuppressed().length > 0) {
            assertTrue(deserialized.getSuppressed()[0] instanceof NotSerializableExceptionWrapper);
            assertArrayEquals(t.getSuppressed()[0].getStackTrace(), deserialized.getSuppressed()[0].getStackTrace());
            assertTrue(deserialized.getSuppressed()[1] instanceof NullPointerException);
        }
    }
}
Also used : NotSerializableExceptionWrapper(org.elasticsearch.common.io.stream.NotSerializableExceptionWrapper) IndexFormatTooNewException(org.apache.lucene.index.IndexFormatTooNewException) AlreadyClosedException(org.apache.lucene.store.AlreadyClosedException) ConnectTransportException(org.elasticsearch.transport.ConnectTransportException) IllegalShardRoutingStateException(org.elasticsearch.cluster.routing.IllegalShardRoutingStateException) ActionTransportException(org.elasticsearch.transport.ActionTransportException) SearchContextMissingException(org.elasticsearch.search.SearchContextMissingException) SnapshotException(org.elasticsearch.snapshots.SnapshotException) AccessDeniedException(java.nio.file.AccessDeniedException) SearchException(org.elasticsearch.search.SearchException) LockObtainFailedException(org.apache.lucene.store.LockObtainFailedException) RecoverFilesRecoveryException(org.elasticsearch.indices.recovery.RecoverFilesRecoveryException) ClusterBlockException(org.elasticsearch.cluster.block.ClusterBlockException) NotDirectoryException(java.nio.file.NotDirectoryException) DirectoryNotEmptyException(java.nio.file.DirectoryNotEmptyException) IOException(java.io.IOException) IndexTemplateMissingException(org.elasticsearch.indices.IndexTemplateMissingException) NoSuchFileException(java.nio.file.NoSuchFileException) FailedNodeException(org.elasticsearch.action.FailedNodeException) SearchParseException(org.elasticsearch.search.SearchParseException) URISyntaxException(java.net.URISyntaxException) AliasesNotFoundException(org.elasticsearch.rest.action.admin.indices.AliasesNotFoundException) RecoveryEngineException(org.elasticsearch.index.engine.RecoveryEngineException) CorruptIndexException(org.apache.lucene.index.CorruptIndexException) TimestampParsingException(org.elasticsearch.action.TimestampParsingException) RoutingMissingException(org.elasticsearch.action.RoutingMissingException) RepositoryException(org.elasticsearch.repositories.RepositoryException) AlreadyExpiredException(org.elasticsearch.index.AlreadyExpiredException) InvalidIndexTemplateException(org.elasticsearch.indices.InvalidIndexTemplateException) QueryShardException(org.elasticsearch.index.query.QueryShardException) FileSystemException(java.nio.file.FileSystemException) ShardLockObtainFailedException(org.elasticsearch.env.ShardLockObtainFailedException) IllegalIndexShardStateException(org.elasticsearch.index.shard.IllegalIndexShardStateException) EOFException(java.io.EOFException) FileNotFoundException(java.io.FileNotFoundException) SearchPhaseExecutionException(org.elasticsearch.action.search.SearchPhaseExecutionException) ActionNotFoundTransportException(org.elasticsearch.transport.ActionNotFoundTransportException) ParsingException(org.elasticsearch.common.ParsingException) FileSystemLoopException(java.nio.file.FileSystemLoopException) IndexFormatTooOldException(org.apache.lucene.index.IndexFormatTooOldException) FileAlreadyExistsException(java.nio.file.FileAlreadyExistsException) CircuitBreakingException(org.elasticsearch.common.breaker.CircuitBreakingException) AtomicMoveNotSupportedException(java.nio.file.AtomicMoveNotSupportedException)

Example 2 with NotSerializableExceptionWrapper

use of org.elasticsearch.common.io.stream.NotSerializableExceptionWrapper in project crate by crate.

the class BulkShardProcessor method executeRequests.

private void executeRequests() {
    try {
        executeLock.acquire();
        for (Iterator<Map.Entry<ShardId, Request>> it = requestsByShard.entrySet().iterator(); it.hasNext(); ) {
            if (failure.get() != null) {
                return;
            }
            Map.Entry<ShardId, Request> entry = it.next();
            final Request request = entry.getValue();
            final ShardId shardId = entry.getKey();
            requestExecutor.execute(request, new ActionListener<ShardResponse>() {

                @Override
                public void onResponse(ShardResponse response) {
                    processResponse(response);
                }

                @Override
                public void onFailure(Throwable t) {
                    t = SQLExceptions.unwrap(t, throwable -> throwable instanceof RuntimeException);
                    if (t instanceof ClassCastException || t instanceof NotSerializableExceptionWrapper) {
                        // this is caused by passing mixed argument types into a bulk upsert.
                        // it can happen after an valid request already succeeded and data was written.
                        // so never bubble, but rather mark all items of this request as failed.
                        markItemsAsFailedAndReleaseRetryLock(request, Optional.absent());
                        LOGGER.warn("ShardUpsert: {} items failed", t, request.items().size());
                        return;
                    }
                    processFailure(t, shardId, request, Optional.absent());
                }
            });
            it.remove();
        }
    } catch (InterruptedException e) {
        Thread.interrupted();
    } catch (Throwable e) {
        setFailure(e);
    } finally {
        requestItemCounter.set(0);
        executeLock.release();
    }
}
Also used : ShardRequest(io.crate.executor.transport.ShardRequest) BulkCreateIndicesRequest(org.elasticsearch.action.admin.indices.create.BulkCreateIndicesRequest) ShardId(org.elasticsearch.index.shard.ShardId) ShardResponse(io.crate.executor.transport.ShardResponse) NotSerializableExceptionWrapper(org.elasticsearch.common.io.stream.NotSerializableExceptionWrapper)

Aggregations

NotSerializableExceptionWrapper (org.elasticsearch.common.io.stream.NotSerializableExceptionWrapper)2 ShardRequest (io.crate.executor.transport.ShardRequest)1 ShardResponse (io.crate.executor.transport.ShardResponse)1 EOFException (java.io.EOFException)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1 AccessDeniedException (java.nio.file.AccessDeniedException)1 AtomicMoveNotSupportedException (java.nio.file.AtomicMoveNotSupportedException)1 DirectoryNotEmptyException (java.nio.file.DirectoryNotEmptyException)1 FileAlreadyExistsException (java.nio.file.FileAlreadyExistsException)1 FileSystemException (java.nio.file.FileSystemException)1 FileSystemLoopException (java.nio.file.FileSystemLoopException)1 NoSuchFileException (java.nio.file.NoSuchFileException)1 NotDirectoryException (java.nio.file.NotDirectoryException)1 CorruptIndexException (org.apache.lucene.index.CorruptIndexException)1 IndexFormatTooNewException (org.apache.lucene.index.IndexFormatTooNewException)1 IndexFormatTooOldException (org.apache.lucene.index.IndexFormatTooOldException)1 AlreadyClosedException (org.apache.lucene.store.AlreadyClosedException)1 LockObtainFailedException (org.apache.lucene.store.LockObtainFailedException)1