yashmayya commented on code in PR #17028:
URL: https://github.com/apache/pinot/pull/17028#discussion_r2462181715
##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/startree/v2/builder/MultipleTreesBuilder.java:
##########
@@ -243,6 +269,28 @@ private static SingleTreeBuilder
getSingleTreeBuilder(StarTreeV2BuilderConfig bu
public void close() {
if (_separatorTempDir != null) {
try {
+ try {
+ if (_starTreeCreationFailed) {
+ LOGGER.error("Star-tree index creation failed, trying to reset the
older star-tree index and metadata");
+ FileUtils.moveFileToDirectory(new File(_separatorTempDir,
StarTreeV2Constants.INDEX_FILE_NAME),
+ _segmentDirectory,
+ false);
+ FileUtils.moveFileToDirectory(new File(_separatorTempDir,
StarTreeV2Constants.INDEX_MAP_FILE_NAME),
+ _segmentDirectory, false);
+
+ // Copy back the older star-tree related metadata
+ Iterator<String> keys = _existingStarTreeMetadata.getKeys();
+ while (keys.hasNext()) {
+ String key = keys.next();
+ Object value = _existingStarTreeMetadata.getProperty(key);
+ _metadataProperties.addProperty(MetadataKey.STAR_TREE_PREFIX +
key, value);
+ }
+ CommonsConfigurationUtils.saveToFile(_metadataProperties,
+ new File(_segmentDirectory,
V1Constants.MetadataKeys.METADATA_FILE_NAME));
+ }
+ } catch (Exception e) {
+ LOGGER.error("Could not reset the star-tree index state to the
previous one", e);
Review Comment:
Hm there's only two call-sites really for `MultipleTreesBuilder`, so IMO it
might just be cleaner and more readable to _not_ use the try-with-resources
pattern. Instead we can call the `close` method manually in a finally block,
where the exception can propagate freely.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]