From f38ffed084cdcfc288eb32b35f3f3f1e5f5425d9 Mon Sep 17 00:00:00 2001 From: Peng Huo Date: Mon, 10 Jul 2023 09:07:32 -0700 Subject: [PATCH] Guarantee datasource read api is strong consistent read (#1815) Signed-off-by: Peng Huo --- .../storage/OpenSearchDataSourceMetadataStorage.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/datasources/src/main/java/org/opensearch/sql/datasources/storage/OpenSearchDataSourceMetadataStorage.java b/datasources/src/main/java/org/opensearch/sql/datasources/storage/OpenSearchDataSourceMetadataStorage.java index f76e1ba9dc..d756f2e029 100644 --- a/datasources/src/main/java/org/opensearch/sql/datasources/storage/OpenSearchDataSourceMetadataStorage.java +++ b/datasources/src/main/java/org/opensearch/sql/datasources/storage/OpenSearchDataSourceMetadataStorage.java @@ -217,6 +217,8 @@ private List searchInDataSourcesIndex(QueryBuilder query) { searchSourceBuilder.query(query); searchSourceBuilder.size(DATASOURCE_QUERY_RESULT_SIZE); searchRequest.source(searchSourceBuilder); + // strongly consistent reads is requred. more info https://github.com/opensearch-project/sql/issues/1801. + searchRequest.preference("_primary"); ActionFuture searchResponseActionFuture; try (ThreadContext.StoredContext ignored = client.threadPool().getThreadContext() .stashContext()) { @@ -305,4 +307,4 @@ private void handleSigV4PropertiesEncryptionDecryption(Map prope encryptOrDecrypt(propertiesMap, isEncryption, list); } -} \ No newline at end of file +}