Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Always times out when accessing alias index #1453

Closed
al-niessner opened this issue Feb 21, 2025 · 4 comments
Closed

[BUG] Always times out when accessing alias index #1453

al-niessner opened this issue Feb 21, 2025 · 4 comments
Labels
bug Something isn't working

Comments

@al-niessner
Copy link
Contributor

al-niessner commented Feb 21, 2025

What is the bug?

I have two indices at AOSS: foo and bar. foo is a real index where data is stored and searched. bar is an alias index, which has no real data in it, that transfers all requests to foo and returns the results from foo as well. I know this works as I can use and exercise the alias with any set of queries using python. The Java SDK fails with a timeout (see below).

How can one reproduce the bug?

Create one real and one alias index at AOSS then try to query the two indices with the same search query using Java SDK2. Any search query will do. Mine are a field x equals value y.

What is the expected behavior?

I expect the alias index to behave identical to the real index as it does in python.

What is your host/environment?

Java 17, Linux.

Do you have any screenshots?

No, but here is the stack dump from the failing alias index query but the same query works with the real index:

java.net.SocketTimeoutException: Read timed out
	at java.base/sun.nio.ch.NioSocketImpl.timedRead(NioSocketImpl.java:278) ~[?:?]
	at java.base/sun.nio.ch.NioSocketImpl.implRead(NioSocketImpl.java:304) ~[?:?]
	at java.base/sun.nio.ch.NioSocketImpl.read(NioSocketImpl.java:346) ~[?:?]
	at java.base/sun.nio.ch.NioSocketImpl$1.read(NioSocketImpl.java:796) ~[?:?]
	at java.base/java.net.Socket$SocketInputStream.read(Socket.java:1099) ~[?:?]
	at java.base/sun.security.ssl.SSLSocketInputRecord.read(SSLSocketInputRecord.java:489) ~[?:?]
	at java.base/sun.security.ssl.SSLSocketInputRecord.readHeader(SSLSocketInputRecord.java:483) ~[?:?]
	at java.base/sun.security.ssl.SSLSocketInputRecord.bytesInCompletePacket(SSLSocketInputRecord.java:70) ~[?:?]
	at java.base/sun.security.ssl.SSLSocketImpl.readApplicationRecord(SSLSocketImpl.java:1461) ~[?:?]
	at java.base/sun.security.ssl.SSLSocketImpl$AppInputStream.read(SSLSocketImpl.java:1066) ~[?:?]
	at org.apache.http.impl.io.SessionInputBufferImpl.streamRead(SessionInputBufferImpl.java:137) ~[httpcore-4.4.16.jar:4.4.16]
	at org.apache.http.impl.io.SessionInputBufferImpl.fillBuffer(SessionInputBufferImpl.java:153) ~[httpcore-4.4.16.jar:4.4.16]
	at org.apache.http.impl.io.SessionInputBufferImpl.readLine(SessionInputBufferImpl.java:280) ~[httpcore-4.4.16.jar:4.4.16]
	at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:138) ~[httpclient-4.5.13.jar:4.5.13]
	at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:56) ~[httpclient-4.5.13.jar:4.5.13]
	at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:259) ~[httpcore-4.4.16.jar:4.4.16]
	at org.apache.http.impl.DefaultBHttpClientConnection.receiveResponseHeader(DefaultBHttpClientConnection.java:163) ~[httpcore-4.4.16.jar:4.4.16]
	at org.apache.http.impl.conn.CPoolProxy.receiveResponseHeader(CPoolProxy.java:157) ~[httpclient-4.5.13.jar:4.5.13]
	at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:273) ~[httpcore-4.4.16.jar:4.4.16]
	at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:125) ~[httpcore-4.4.16.jar:4.4.16]
	at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:272) ~[httpclient-4.5.13.jar:4.5.13]
	at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186) ~[httpclient-4.5.13.jar:4.5.13]
	at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185) ~[httpclient-4.5.13.jar:4.5.13]
	at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83) ~[httpclient-4.5.13.jar:4.5.13]
	at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56) ~[httpclient-4.5.13.jar:4.5.13]
	at software.amazon.awssdk.http.apache.internal.impl.ApacheSdkHttpClient.execute(ApacheSdkHttpClient.java:72) ~[apache-client-2.30.18.jar:?]
	at software.amazon.awssdk.http.apache.ApacheHttpClient.execute(ApacheHttpClient.java:252) ~[apache-client-2.30.18.jar:?]
	at software.amazon.awssdk.http.apache.ApacheHttpClient.access$500(ApacheHttpClient.java:103) ~[apache-client-2.30.18.jar:?]
	at software.amazon.awssdk.http.apache.ApacheHttpClient$1.call(ApacheHttpClient.java:229) ~[apache-client-2.30.18.jar:?]
	at org.opensearch.client.transport.aws.AwsSdk2Transport.executeSync(AwsSdk2Transport.java:435) ~[opensearch-java-2.20.0.jar:?]
	at org.opensearch.client.transport.aws.AwsSdk2Transport.performRequest(AwsSdk2Transport.java:217) ~[opensearch-java-2.20.0.jar:?]
	at org.opensearch.client.opensearch.OpenSearchClient.search(OpenSearchClient.java:1386) ~[opensearch-java-2.20.0.jar:?]

Do you have any additional context?

When I say the same query, I literally mean the same but the name for index(name) is different. Not two different blocks of code. Just change the name variable value for the two tests.

I hope this ground has been covered already with a simple solution but neither google nor searching this bug list yielded anything helpful to me - does not mean the information is not there but that I was not able to find it quickly.

@Xtansia
Copy link
Collaborator

Xtansia commented Feb 23, 2025

Hi @al-niessner,
Thank you for your report. It would be helpful if you could provide a full code example that reproduces the issue for you.
I've attempted to reproduce it myself using the below code and am not experiencing the issue:

var credentials = AwsSessionCredentials.builder()
                .accessKeyId("...")
                .secretAccessKey("...")
                .sessionToken("...")
                .build();
        var transportOptions = AwsSdk2TransportOptions.builder().setCredentials(() -> credentials).build();
        var transport = new AwsSdk2Transport(ApacheHttpClient.create(), ".....ap-southeast-2.aoss.amazonaws.com", "aoss", Region.AP_SOUTHEAST_2, transportOptions);
        var client = new OpenSearchClient(transport);

        final var indexName = "repro-index";
        final var aliasName = "repro-alias";

        LOGGER.info("Bulk indexing documents");
        ArrayList<BulkOperation> ops = new ArrayList<>();
        IndexData doc1 = new IndexData("Document 1", "The text of document 1");
        ops.add(new BulkOperation.Builder().index(IndexOperation.of(io -> io.index(indexName).id("id1").document(doc1))).build());
        IndexData doc2 = new IndexData("Document 2", "The text of document 2");
        ops.add(new BulkOperation.Builder().index(IndexOperation.of(io -> io.index(indexName).id("id2").document(doc2))).build());
        IndexData doc3 = new IndexData("Document 3", "The text of document 3");
        ops.add(new BulkOperation.Builder().index(IndexOperation.of(io -> io.index(indexName).id("id3").document(doc3))).build());

        BulkRequest.Builder bulkReq = new BulkRequest.Builder().index(indexName).operations(ops);
        BulkResponse bulkResponse = client.bulk(bulkReq.build());
        LOGGER.info("Bulk response items: {}", bulkResponse.items().size());

        client.indices().updateAliases(u -> u.actions(a -> a.add(aa -> aa.index(indexName).alias(aliasName))));

        Thread.sleep(10000);

        var search = client.search(s -> s.index(indexName).query(q -> q.term(t -> t.field("text").value(v -> v.stringValue("document")))), IndexData.class);
        LOGGER.info("Search response: {}", search.hits().hits().size());

        search = client.search(s -> s.index(aliasName).query(q -> q.term(t -> t.field("text").value(v -> v.stringValue("document")))), IndexData.class);
        LOGGER.info("Search response: {}", search.hits().hits().size());

@al-niessner
Copy link
Contributor Author

Working... It will take me some time but will come back with a test or ah-ha as my mistake.

@al-niessner
Copy link
Contributor Author

al-niessner commented Mar 12, 2025

@Xtansia

Sorry for the long delay. I misrepresented the search a bit. Here is my actual search:

SearchRequest.Builder().aggregations("duplicates",
        new Aggregation.Builder().terms(
            new TermsAggregation.Builder().field("filename").minDocCount(2).size(page_size).build())
        .build());

The virtual database (alias index) points at many real databases. Each of these can contain millions of items. The search is looking for any entries that have the same filename because they are supposed to be unique. Works on a real index but not a virtual. Still working at making a smaller test set.

@al-niessner
Copy link
Contributor Author

@Xtansia

Aggregates take a long time over the very large databases. Fixed it with socketTimeout() on http client. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants