Skip to content

Commit b550e30

Browse files
committed
fix: end remote build metrics before falling back to CPU, log exception
Signed-off-by: owenhalpert <[email protected]>
1 parent 0a002b9 commit b550e30

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
1313
### Bug Fixes
1414
* [BUGFIX] Fix KNN Quantization state cache have an invalid weight threshold [#2666](https://github.com/opensearch-project/k-NN/pull/2666)
1515
* [BUGFIX] Fix enable rescoring when dimensions > 1000. [#2671](https://github.com/opensearch-project/k-NN/pull/2671)
16+
* [Remote Vector Index Build] End remote build metrics before falling back to CPU, exception logging
1617

1718
## [Unreleased 2.x](https://github.com/opensearch-project/k-NN/compare/2.19...2.x)
1819
### Features

src/main/java/org/opensearch/knn/index/codec/nativeindex/remote/RemoteIndexBuildStrategy.java

+5-7
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ public static boolean shouldBuildIndexRemotely(IndexSettings indexSettings, long
130130
@Override
131131
public void buildAndWriteIndex(BuildIndexParams indexInfo) throws IOException {
132132
metrics.startRemoteIndexBuildMetrics(indexInfo);
133-
boolean success = false;
134133
try {
135134
RepositoryContext repositoryContext = getRepositoryContext(indexInfo);
136135

@@ -147,11 +146,10 @@ public void buildAndWriteIndex(BuildIndexParams indexInfo) throws IOException {
147146
// 4. Download index file and write to indexOutput
148147
readFromRepository(indexInfo, repositoryContext, remoteBuildStatusResponse);
149148

150-
success = true;
149+
metrics.endRemoteIndexBuildMetrics(true);
151150
} catch (Exception e) {
151+
metrics.endRemoteIndexBuildMetrics(false);
152152
fallbackStrategy.buildAndWriteIndex(indexInfo);
153-
} finally {
154-
metrics.endRemoteIndexBuildMetrics(success);
155153
}
156154
}
157155

@@ -172,7 +170,7 @@ private void writeToRepository(RepositoryContext repositoryContext, BuildIndexPa
172170
);
173171
success = true;
174172
} catch (InterruptedException | IOException e) {
175-
log.debug("Repository write failed for vector field [{}]", indexInfo.getFieldName());
173+
log.debug("Repository write failed for vector field [{}]", indexInfo.getFieldName(), e);
176174
throw e;
177175
} finally {
178176
metrics.endRepositoryWriteMetrics(success);
@@ -200,7 +198,7 @@ private RemoteBuildResponse submitBuild(RepositoryContext repositoryContext, Bui
200198
success = true;
201199
return remoteBuildResponse;
202200
} catch (IOException e) {
203-
log.debug("Submit vector build failed for vector field [{}]", indexInfo.getFieldName());
201+
log.debug("Submit vector build failed for vector field [{}]", indexInfo.getFieldName(), e);
204202
throw e;
205203
} finally {
206204
metrics.endBuildRequestMetrics(success);
@@ -250,7 +248,7 @@ private void readFromRepository(
250248
);
251249
success = true;
252250
} catch (Exception e) {
253-
log.debug("Repository read failed for vector field [{}]", indexInfo.getFieldName());
251+
log.debug("Repository read failed for vector field [{}]", indexInfo.getFieldName(), e);
254252
throw e;
255253
} finally {
256254
metrics.endRepositoryReadMetrics(success);

0 commit comments

Comments
 (0)