yashmayya commented on code in PR #17028:
URL: https://github.com/apache/pinot/pull/17028#discussion_r2445615091
##########
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:
> how about we throw the exception if it fails at this stage - that way
segment build fails and we can't query this segment and won't see
inconsistencies?
Yeah that sounds like a better idea actually 👍
--
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]