You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by "wirybeaver (via GitHub)" <gi...@apache.org> on 2023/05/11 18:04:58 UTC

[GitHub] [pinot] wirybeaver opened a new pull request, #10758: [Draft] Add a new controller endpoint for segment deletion with a time window

wirybeaver opened a new pull request, #10758:
URL: https://github.com/apache/pinot/pull/10758

   Implement the proposal in the issue [#10740](https://github.com/apache/pinot/issues/10740)
   
   reuse the getSegments to get segment list with [start, end) time window and pass the segment list into the existing deleteSegmentsInternal function.


-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] GSharayu commented on a diff in pull request #10758: Add a new controller endpoint for segment deletion with a time window

Posted by "GSharayu (via GitHub)" <gi...@apache.org>.
GSharayu commented on code in PR #10758:
URL: https://github.com/apache/pinot/pull/10758#discussion_r1228803682


##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSegmentRestletResource.java:
##########
@@ -884,6 +865,47 @@ public SuccessResponse deleteSegments(
     }
   }
 
+  @DELETE
+  @Consumes(MediaType.APPLICATION_JSON)
+  @Produces(MediaType.APPLICATION_JSON)
+  @Path("/segments/{tableName}/select")
+  @Authenticate(AccessType.DELETE)
+  @ApiOperation(value = "Delete select segments. An optional 'excludeReplacedSegments' parameter is used to get the"
+      + " list of segments which has not yet been replaced (determined by segment lineage entries) and can be queried"
+      + " from the table. The value is false by default.",
+      // TODO: more and more filters can be added later on, like excludeErrorSegments, excludeConsumingSegments, etc.
+      notes = "List all segments")
+  public SuccessResponse deleteSegmentsWithTimeWindow(
+      @ApiParam(value = "Name of the table", required = true) @PathParam("tableName") String tableName,
+      @ApiParam(value = "OFFLINE|REALTIME") @QueryParam("type") String tableTypeStr,
+      @ApiParam(value = "Whether to keep replaced segments, which have been replaced"
+          + " specified in the segment lineage entries and cannot be queried from the table, false by default")
+      @QueryParam("excludeReplacedSegments") @DefaultValue("false") boolean excludeReplacedSegments,
+      @ApiParam(value = "Start timestamp (inclusive)") @QueryParam("startTimestamp") @DefaultValue("")
+          String startTimestampStr,
+      @ApiParam(value = "End timestamp (exclusive)") @QueryParam("endTimestamp") @DefaultValue("")
+          String endTimestampStr,
+      @ApiParam(value = "Whether to keep segments overlapping with the [start, end) from deletion, true by default")
+      @QueryParam("excludeOverlapping") @DefaultValue("true") boolean excludeOverlapping,

Review Comment:
   Should this value be false by default?



-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] wirybeaver commented on a diff in pull request #10758: Add a new controller endpoint for segment deletion with a time window

Posted by "wirybeaver (via GitHub)" <gi...@apache.org>.
wirybeaver commented on code in PR #10758:
URL: https://github.com/apache/pinot/pull/10758#discussion_r1230150645


##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSegmentRestletResource.java:
##########
@@ -884,6 +865,47 @@ public SuccessResponse deleteSegments(
     }
   }
 
+  @DELETE
+  @Consumes(MediaType.APPLICATION_JSON)
+  @Produces(MediaType.APPLICATION_JSON)
+  @Path("/segments/{tableName}/select")
+  @Authenticate(AccessType.DELETE)
+  @ApiOperation(value = "Delete select segments. An optional 'excludeReplacedSegments' parameter is used to get the"
+      + " list of segments which has not yet been replaced (determined by segment lineage entries) and can be queried"
+      + " from the table. The value is false by default.",
+      // TODO: more and more filters can be added later on, like excludeErrorSegments, excludeConsumingSegments, etc.
+      notes = "List all segments")
+  public SuccessResponse deleteSegmentsWithTimeWindow(
+      @ApiParam(value = "Name of the table", required = true) @PathParam("tableName") String tableName,
+      @ApiParam(value = "OFFLINE|REALTIME") @QueryParam("type") String tableTypeStr,
+      @ApiParam(value = "Whether to keep replaced segments, which have been replaced"
+          + " specified in the segment lineage entries and cannot be queried from the table, false by default")
+      @QueryParam("excludeReplacedSegments") @DefaultValue("false") boolean excludeReplacedSegments,
+      @ApiParam(value = "Start timestamp (inclusive)") @QueryParam("startTimestamp") @DefaultValue("")
+          String startTimestampStr,
+      @ApiParam(value = "End timestamp (exclusive)") @QueryParam("endTimestamp") @DefaultValue("")
+          String endTimestampStr,
+      @ApiParam(value = "Whether to keep segments overlapping with the [start, end) from deletion, true by default")
+      @QueryParam("excludeOverlapping") @DefaultValue("true") boolean excludeOverlapping,

Review Comment:
   Rephrase the ApiParam value. keep segments -> ignore segments for deletion.



##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSegmentRestletResource.java:
##########
@@ -1130,4 +1152,38 @@ private SuccessResponse updateZKTimeIntervalInternal(String tableNameWithType) {
       }
       return new SuccessResponse("Successfully updated time interval zk metadata for table: " + tableNameWithType);
   }
+
+  public List<Pair<TableType, List<String>>> selectSegments(

Review Comment:
   getSelectedSegments() has annotation Deprecated. The getSegments() is refactored with this util function.



-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] wirybeaver commented on a diff in pull request #10758: Add a new controller endpoint for segment deletion with a time window

Posted by "wirybeaver (via GitHub)" <gi...@apache.org>.
wirybeaver commented on code in PR #10758:
URL: https://github.com/apache/pinot/pull/10758#discussion_r1253978437


##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSegmentRestletResource.java:
##########
@@ -884,6 +865,52 @@ public SuccessResponse deleteSegments(
     }
   }
 
+  @DELETE
+  @Consumes(MediaType.APPLICATION_JSON)
+  @Produces(MediaType.APPLICATION_JSON)
+  @Path("/segments/{tableName}/select")

Review Comment:
   @snleee  Thanks for your suggestion. From the perspective of safety, since it's a delete api, my hunt is to enforce users MUST input non-empty startTime and endTime, which will break the compatibility that delete all segment if no filter is provides. That's another reason to have different PATH. User would know they are doing a dangerous operation if they use `DELETE /segments/{tableName}` meanwhile `DELETE /segments/{tableName}/choose` has a safety guard even though they forgot to add the timestamp.
   
   I am OK to add filters into `DELETE /segments/{tableName}` and remove `DELETE /segments/{tableName}/choose` if you thought the lack of prevention of missing time window is not a major concern.



-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] tibrewalpratik17 commented on a diff in pull request #10758: [Draft] Add a new controller endpoint for segment deletion with a time window

Posted by "tibrewalpratik17 (via GitHub)" <gi...@apache.org>.
tibrewalpratik17 commented on code in PR #10758:
URL: https://github.com/apache/pinot/pull/10758#discussion_r1209169401


##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSegmentRestletResource.java:
##########
@@ -884,6 +865,45 @@ public SuccessResponse deleteSegments(
     }
   }
 
+  @DELETE
+  @Consumes(MediaType.APPLICATION_JSON)
+  @Produces(MediaType.APPLICATION_JSON)
+  @Path("/segments/{tableName}/select")
+  @Authenticate(AccessType.DELETE)
+  @ApiOperation(value = "Delete select segments. An optional 'excludeReplacedSegments' parameter is used to get the"
+      + " list of segments which has not yet been replaced (determined by segment lineage entries) and can be queried"
+      + " from the table. The value is false by default.",
+      // TODO: more and more filters can be added later on, like excludeErrorSegments, excludeConsumingSegments, etc.
+      notes = "List all segments")
+  public SuccessResponse deleteSegmentsWithTimeWindow(
+      @ApiParam(value = "Name of the table", required = true) @PathParam("tableName") String tableName,
+      @ApiParam(value = "OFFLINE|REALTIME") @QueryParam("type") String tableTypeStr,
+      @ApiParam(value = "Whether to keep replaced segments, which have been replaced"
+          + " specified in the segment lineage entries and cannot be queried from the table, false by default")
+      @QueryParam("excludeReplacedSegments") @DefaultValue("false") boolean excludeReplacedSegments,
+      @ApiParam(value = "Start timestamp (inclusive)") @QueryParam("startTimestamp") @DefaultValue("")
+          String startTimestampStr,
+      @ApiParam(value = "End timestamp (exclusive)") @QueryParam("endTimestamp") @DefaultValue("")
+          String endTimestampStr,
+      @ApiParam(value = "Whether to keep segments overlapping with the [start, end) from deletion, true by default")
+      @QueryParam("excludeOverlapping") @DefaultValue("true") boolean excludeOverlapping,
+      @ApiParam(value = "Retention period for the table segments (e.g. 12h, 3d); If not set, the retention period "
+          + "will default to the first config that's not null: the table config, then to cluster setting, then '7d'. "
+          + "Using 0d or -1d will instantly delete segments without retention")
+      @QueryParam("retention") String retentionPeriod) {
+    int numSegments = 0;
+    for(Pair<TableType, List<String>> tableTypeSegments : selectSegments(tableName, tableTypeStr, excludeReplacedSegments, startTimestampStr, endTimestampStr, excludeOverlapping)) {
+      List<String> segments = tableTypeSegments.getValue();
+      numSegments += segments.size();
+      if(segments.isEmpty()) {
+        continue;
+      }
+      String tableNameWithType = getExistingTable(tableName, segments.get(0));

Review Comment:
   You can use this instead:
   `tableTypeSegments.getKey().tableNameWithType(tableName)`
   This will not make any Helix calls.



-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] Jackie-Jiang commented on pull request #10758: Add a new controller endpoint for segment deletion with a time window

Posted by "Jackie-Jiang (via GitHub)" <gi...@apache.org>.
Jackie-Jiang commented on PR #10758:
URL: https://github.com/apache/pinot/pull/10758#issuecomment-1641546168

   Thanks for the contribution! Can you help also update the pinot documentation for this new API?


-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] wirybeaver commented on a diff in pull request #10758: Add a new controller endpoint for segment deletion with a time window

Posted by "wirybeaver (via GitHub)" <gi...@apache.org>.
wirybeaver commented on code in PR #10758:
URL: https://github.com/apache/pinot/pull/10758#discussion_r1255234310


##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSegmentRestletResource.java:
##########
@@ -884,6 +865,52 @@ public SuccessResponse deleteSegments(
     }
   }
 
+  @DELETE
+  @Consumes(MediaType.APPLICATION_JSON)
+  @Produces(MediaType.APPLICATION_JSON)
+  @Path("/segments/{tableName}/select")

Review Comment:
   @snleee Just a gentle reminder for your thoughts.



-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] deemoliu commented on a diff in pull request #10758: Add a new controller endpoint for segment deletion with a time window

Posted by "deemoliu (via GitHub)" <gi...@apache.org>.
deemoliu commented on code in PR #10758:
URL: https://github.com/apache/pinot/pull/10758#discussion_r1246999981


##########
pinot-controller/src/test/java/org/apache/pinot/controller/api/PinotSegmentRestletResourceTest.java:
##########
@@ -165,6 +166,39 @@ public void testSegmentCrcApi()
     checkCrcRequest(rawTableName, segmentMetadataTable, 9);
   }
 
+  @Test
+  public void testDeleteSegmentsWithTimeWindow()
+      throws Exception {
+    // Adding table and segment
+    String rawTableName = "deleteWithTimeWindowTestTable";
+    String offlineTableName = TableNameBuilder.OFFLINE.tableNameWithType(rawTableName);

Review Comment:
   can you add a test case that timeindow covers both realtime and offline table 



-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] snleee commented on a diff in pull request #10758: Add a new controller endpoint for segment deletion with a time window

Posted by "snleee (via GitHub)" <gi...@apache.org>.
snleee commented on code in PR #10758:
URL: https://github.com/apache/pinot/pull/10758#discussion_r1248355285


##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSegmentRestletResource.java:
##########
@@ -884,6 +865,52 @@ public SuccessResponse deleteSegments(
     }
   }
 
+  @DELETE
+  @Consumes(MediaType.APPLICATION_JSON)
+  @Produces(MediaType.APPLICATION_JSON)
+  @Path("/segments/{tableName}/select")

Review Comment:
   @wirybeaver We deprecated `GET /segments/{tableName}/select` over `GET /segments`. (We added the annotation). 
   
   Can we add these filters to `DELETE /segments` API?



-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] wirybeaver commented on a diff in pull request #10758: Add a new controller endpoint for segment deletion with a time window

Posted by "wirybeaver (via GitHub)" <gi...@apache.org>.
wirybeaver commented on code in PR #10758:
URL: https://github.com/apache/pinot/pull/10758#discussion_r1262804192


##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSegmentRestletResource.java:
##########
@@ -884,6 +865,52 @@ public SuccessResponse deleteSegments(
     }
   }
 
+  @DELETE
+  @Consumes(MediaType.APPLICATION_JSON)
+  @Produces(MediaType.APPLICATION_JSON)
+  @Path("/segments/{tableName}/select")

Review Comment:
   Will have a cosmetic change.use `DELETE /segments/{tableName}/choose` instead of `DELETE /segments/{tableName}/select`



-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] wirybeaver commented on a diff in pull request #10758: Add a new controller endpoint for segment deletion with a time window

Posted by "wirybeaver (via GitHub)" <gi...@apache.org>.
wirybeaver commented on code in PR #10758:
URL: https://github.com/apache/pinot/pull/10758#discussion_r1228753300


##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSegmentRestletResource.java:
##########
@@ -1130,4 +1152,38 @@ private SuccessResponse updateZKTimeIntervalInternal(String tableNameWithType) {
       }
       return new SuccessResponse("Successfully updated time interval zk metadata for table: " + tableNameWithType);
   }
+
+  public List<Pair<TableType, List<String>>> selectSegments(

Review Comment:
   yeah, I forgot to change it to private



-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] deemoliu commented on a diff in pull request #10758: Add a new controller endpoint for segment deletion with a time window

Posted by "deemoliu (via GitHub)" <gi...@apache.org>.
deemoliu commented on code in PR #10758:
URL: https://github.com/apache/pinot/pull/10758#discussion_r1245918886


##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSegmentRestletResource.java:
##########
@@ -884,6 +865,52 @@ public SuccessResponse deleteSegments(
     }
   }
 
+  @DELETE
+  @Consumes(MediaType.APPLICATION_JSON)
+  @Produces(MediaType.APPLICATION_JSON)
+  @Path("/segments/{tableName}/select")
+  @Authenticate(AccessType.DELETE)
+  @ApiOperation(value = "Delete select segments. An optional 'excludeReplacedSegments' parameter is used to get the"

Review Comment:
   select --> selected segments



##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSegmentRestletResource.java:
##########
@@ -884,6 +865,52 @@ public SuccessResponse deleteSegments(
     }
   }
 
+  @DELETE
+  @Consumes(MediaType.APPLICATION_JSON)
+  @Produces(MediaType.APPLICATION_JSON)
+  @Path("/segments/{tableName}/select")
+  @Authenticate(AccessType.DELETE)
+  @ApiOperation(value = "Delete select segments. An optional 'excludeReplacedSegments' parameter is used to get the"
+      + " list of segments which has not yet been replaced (determined by segment lineage entries) and can be queried"
+      + " from the table. The value is false by default.",
+      // TODO: more and more filters can be added later on, like excludeErrorSegments, excludeConsumingSegments, etc.
+      notes = "List all segments")
+  public SuccessResponse deleteSegmentsWithTimeWindow(
+      @ApiParam(value = "Name of the table", required = true) @PathParam("tableName") String tableName,
+      @ApiParam(value = "OFFLINE|REALTIME") @QueryParam("type") String tableTypeStr,

Review Comment:
   should this be required? do we have a default value for this? 
   if not, how does it work for hybrid tables?



-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] snleee commented on a diff in pull request #10758: Add a new controller endpoint for segment deletion with a time window

Posted by "snleee (via GitHub)" <gi...@apache.org>.
snleee commented on code in PR #10758:
URL: https://github.com/apache/pinot/pull/10758#discussion_r1261943671


##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSegmentRestletResource.java:
##########
@@ -884,6 +865,52 @@ public SuccessResponse deleteSegments(
     }
   }
 
+  @DELETE
+  @Consumes(MediaType.APPLICATION_JSON)
+  @Produces(MediaType.APPLICATION_JSON)
+  @Path("/segments/{tableName}/select")

Review Comment:
   @wirybeaver sorry for the late response on this. 
   
   The current behavior for `DELETE /segments/{tableName}` API is already to delete all segments in the table.
   
   Adding filter (start, end) means that we will delete the segments matching the filter. I think that we are keeping the backward compatibility and not break any behavior?
   
   Am I missing something?



-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] tibrewalpratik17 commented on a diff in pull request #10758: Add a new controller endpoint for segment deletion with a time window

Posted by "tibrewalpratik17 (via GitHub)" <gi...@apache.org>.
tibrewalpratik17 commented on code in PR #10758:
URL: https://github.com/apache/pinot/pull/10758#discussion_r1228721254


##########
pinot-controller/src/test/java/org/apache/pinot/controller/api/PinotSegmentRestletResourceTest.java:
##########
@@ -165,6 +165,30 @@ public void testSegmentCrcApi()
     checkCrcRequest(rawTableName, segmentMetadataTable, 9);
   }
 
+  @Test
+  public void testDeleteSegmentsWithTimeWindow()

Review Comment:
   This test does not cover for a particular window but dropping all segments right? Should we rename it accordingly or enhance the test?



##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSegmentRestletResource.java:
##########
@@ -1130,4 +1152,38 @@ private SuccessResponse updateZKTimeIntervalInternal(String tableNameWithType) {
       }
       return new SuccessResponse("Successfully updated time interval zk metadata for table: " + tableNameWithType);
   }
+
+  public List<Pair<TableType, List<String>>> selectSegments(

Review Comment:
   Are we planning to add UTs for this method? If not, can we make this private?



-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] ankitsultana commented on a diff in pull request #10758: Add a new controller endpoint for segment deletion with a time window

Posted by "ankitsultana (via GitHub)" <gi...@apache.org>.
ankitsultana commented on code in PR #10758:
URL: https://github.com/apache/pinot/pull/10758#discussion_r1228820464


##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSegmentRestletResource.java:
##########
@@ -884,6 +865,47 @@ public SuccessResponse deleteSegments(
     }
   }
 
+  @DELETE
+  @Consumes(MediaType.APPLICATION_JSON)
+  @Produces(MediaType.APPLICATION_JSON)
+  @Path("/segments/{tableName}/select")

Review Comment:
   We want to be able to delete data older than a given age using an API. At present I think we only have APIs that either delete all segments or delete one particular segment.
   
   This functionality should be useful to everyone since this is a common requirement when you have a lot of customers using Pinot.
   
   re: using an existing API, we could consider that but afaik there's no clean way of integrating this behavior of deletion in the existing APIs. Let us know if you have any API in mind.



-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] Jackie-Jiang commented on pull request #10758: [Draft] Add a new controller endpoint for segment deletion with a time window

Posted by "Jackie-Jiang (via GitHub)" <gi...@apache.org>.
Jackie-Jiang commented on PR #10758:
URL: https://github.com/apache/pinot/pull/10758#issuecomment-1579187687

   cc @snleee 


-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] codecov-commenter commented on pull request #10758: [Draft] Add a new controller endpoint for segment deletion with a time window

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #10758:
URL: https://github.com/apache/pinot/pull/10758#issuecomment-1574223212

   ## [Codecov](https://app.codecov.io/gh/apache/pinot/pull/10758?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   > Merging [#10758](https://app.codecov.io/gh/apache/pinot/pull/10758?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) (30e5ca2) into [master](https://app.codecov.io/gh/apache/pinot/commit/51bf75efa65cbe8bd8b497eb20e34869205d74e8?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) (51bf75e) will **decrease** coverage by `56.60%`.
   > The diff coverage is `48.38%`.
   
   ```diff
   @@              Coverage Diff              @@
   ##             master   #10758       +/-   ##
   =============================================
   - Coverage     70.22%   13.62%   -56.60%     
   + Complexity     6525      439     -6086     
   =============================================
     Files          2164     2116       -48     
     Lines        116369   114188     -2181     
     Branches      17599    17360      -239     
   =============================================
   - Hits          81719    15558    -66161     
   - Misses        28952    97355    +68403     
   + Partials       5698     1275     -4423     
   ```
   
   | Flag | Coverage Δ | |
   |---|---|---|
   | integration1 | `?` | |
   | integration2 | `?` | |
   | unittests1 | `?` | |
   | unittests2 | `13.62% <48.38%> (-0.04%)` | :arrow_down: |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Impacted Files](https://app.codecov.io/gh/apache/pinot/pull/10758?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [...ler/api/resources/PinotSegmentRestletResource.java](https://app.codecov.io/gh/apache/pinot/pull/10758?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cGlub3QtY29udHJvbGxlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29udHJvbGxlci9hcGkvcmVzb3VyY2VzL1Bpbm90U2VnbWVudFJlc3RsZXRSZXNvdXJjZS5qYXZh) | `12.72% <48.38%> (-25.39%)` | :arrow_down: |
   
   ... and [1715 files with indirect coverage changes](https://app.codecov.io/gh/apache/pinot/pull/10758/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   :mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   


-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] snleee commented on a diff in pull request #10758: Add a new controller endpoint for segment deletion with a time window

Posted by "snleee (via GitHub)" <gi...@apache.org>.
snleee commented on code in PR #10758:
URL: https://github.com/apache/pinot/pull/10758#discussion_r1261943671


##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSegmentRestletResource.java:
##########
@@ -884,6 +865,52 @@ public SuccessResponse deleteSegments(
     }
   }
 
+  @DELETE
+  @Consumes(MediaType.APPLICATION_JSON)
+  @Produces(MediaType.APPLICATION_JSON)
+  @Path("/segments/{tableName}/select")

Review Comment:
   @wirybeaver sorry for the late response on this. 
   
   The current behavior for `DELETE /segments/{tableName}` API is already to delete all segments in the table.
   
   Adding filter (start, end) means that we will delete the segments matching the filter. I think that we are keeping the backward compatibility and not breaking any existing behavior?
   
   Am I missing something?



-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] wirybeaver commented on a diff in pull request #10758: Add a new controller endpoint for segment deletion with a time window

Posted by "wirybeaver (via GitHub)" <gi...@apache.org>.
wirybeaver commented on code in PR #10758:
URL: https://github.com/apache/pinot/pull/10758#discussion_r1245969155


##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSegmentRestletResource.java:
##########
@@ -884,6 +865,47 @@ public SuccessResponse deleteSegments(
     }
   }
 
+  @DELETE
+  @Consumes(MediaType.APPLICATION_JSON)
+  @Produces(MediaType.APPLICATION_JSON)
+  @Path("/segments/{tableName}/select")

Review Comment:
   There's an delete api to delete list of segments, but it's not user friendly. Users need to use the get api with time window and then invoke the deletion api. Moreover, the new delete api flip the default value of excludeOverlapping (false -> true) and excludeReplacedSegments (true -> false) of get api to cater with more intuitive deletion requirement. If the segment min-max partially overlap with the give time window, the segments might contain data out of given time window. Most of customers don't expect to delete those data. Thus excludeOverlapping is set to true, meaning ignore segment that are partially overlapped for deletion. For excludeReplacedSegments, the default value is set to false, meaning completely delete segments regardless of the replaced states.
   
   @jtao15 do you have any objections?



-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] snleee commented on a diff in pull request #10758: Add a new controller endpoint for segment deletion with a time window

Posted by "snleee (via GitHub)" <gi...@apache.org>.
snleee commented on code in PR #10758:
URL: https://github.com/apache/pinot/pull/10758#discussion_r1248355285


##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSegmentRestletResource.java:
##########
@@ -884,6 +865,52 @@ public SuccessResponse deleteSegments(
     }
   }
 
+  @DELETE
+  @Consumes(MediaType.APPLICATION_JSON)
+  @Produces(MediaType.APPLICATION_JSON)
+  @Path("/segments/{tableName}/select")

Review Comment:
   @wirybeaver We deprecated `GET /segments/{tableName}/select` over `GET /segments/{tableName}`. (We added the annotation). 
   
   Can we add new parameters to `DELETE /segments/{tableName}` API?



-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] wirybeaver commented on a diff in pull request #10758: [Draft] Add a new controller endpoint for segment deletion with a time window

Posted by "wirybeaver (via GitHub)" <gi...@apache.org>.
wirybeaver commented on code in PR #10758:
URL: https://github.com/apache/pinot/pull/10758#discussion_r1214726972


##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSegmentRestletResource.java:
##########
@@ -884,6 +865,45 @@ public SuccessResponse deleteSegments(
     }
   }
 
+  @DELETE
+  @Consumes(MediaType.APPLICATION_JSON)
+  @Produces(MediaType.APPLICATION_JSON)
+  @Path("/segments/{tableName}/select")
+  @Authenticate(AccessType.DELETE)
+  @ApiOperation(value = "Delete select segments. An optional 'excludeReplacedSegments' parameter is used to get the"
+      + " list of segments which has not yet been replaced (determined by segment lineage entries) and can be queried"
+      + " from the table. The value is false by default.",
+      // TODO: more and more filters can be added later on, like excludeErrorSegments, excludeConsumingSegments, etc.
+      notes = "List all segments")
+  public SuccessResponse deleteSegmentsWithTimeWindow(
+      @ApiParam(value = "Name of the table", required = true) @PathParam("tableName") String tableName,
+      @ApiParam(value = "OFFLINE|REALTIME") @QueryParam("type") String tableTypeStr,
+      @ApiParam(value = "Whether to keep replaced segments, which have been replaced"
+          + " specified in the segment lineage entries and cannot be queried from the table, false by default")
+      @QueryParam("excludeReplacedSegments") @DefaultValue("false") boolean excludeReplacedSegments,
+      @ApiParam(value = "Start timestamp (inclusive)") @QueryParam("startTimestamp") @DefaultValue("")
+          String startTimestampStr,
+      @ApiParam(value = "End timestamp (exclusive)") @QueryParam("endTimestamp") @DefaultValue("")
+          String endTimestampStr,
+      @ApiParam(value = "Whether to keep segments overlapping with the [start, end) from deletion, true by default")
+      @QueryParam("excludeOverlapping") @DefaultValue("true") boolean excludeOverlapping,
+      @ApiParam(value = "Retention period for the table segments (e.g. 12h, 3d); If not set, the retention period "
+          + "will default to the first config that's not null: the table config, then to cluster setting, then '7d'. "
+          + "Using 0d or -1d will instantly delete segments without retention")
+      @QueryParam("retention") String retentionPeriod) {
+    int numSegments = 0;
+    for(Pair<TableType, List<String>> tableTypeSegments : selectSegments(tableName, tableTypeStr, excludeReplacedSegments, startTimestampStr, endTimestampStr, excludeOverlapping)) {
+      List<String> segments = tableTypeSegments.getValue();
+      numSegments += segments.size();
+      if(segments.isEmpty()) {
+        continue;
+      }
+      String tableNameWithType = getExistingTable(tableName, segments.get(0));

Review Comment:
   Thanks for pointing out the helix will be called. Fix with TableNameBuilder.



-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] wirybeaver commented on a diff in pull request #10758: Add a new controller endpoint for segment deletion with a time window

Posted by "wirybeaver (via GitHub)" <gi...@apache.org>.
wirybeaver commented on code in PR #10758:
URL: https://github.com/apache/pinot/pull/10758#discussion_r1230146683


##########
pinot-controller/src/test/java/org/apache/pinot/controller/api/PinotSegmentRestletResourceTest.java:
##########
@@ -165,6 +165,30 @@ public void testSegmentCrcApi()
     checkCrcRequest(rawTableName, segmentMetadataTable, 9);
   }
 
+  @Test
+  public void testDeleteSegmentsWithTimeWindow()

Review Comment:
   I added more test cases.



-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] snleee merged pull request #10758: Add a new controller endpoint for segment deletion with a time window

Posted by "snleee (via GitHub)" <gi...@apache.org>.
snleee merged PR #10758:
URL: https://github.com/apache/pinot/pull/10758


-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] snleee commented on a diff in pull request #10758: Add a new controller endpoint for segment deletion with a time window

Posted by "snleee (via GitHub)" <gi...@apache.org>.
snleee commented on code in PR #10758:
URL: https://github.com/apache/pinot/pull/10758#discussion_r1253930435


##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSegmentRestletResource.java:
##########
@@ -884,6 +865,52 @@ public SuccessResponse deleteSegments(
     }
   }
 
+  @DELETE
+  @Consumes(MediaType.APPLICATION_JSON)
+  @Produces(MediaType.APPLICATION_JSON)
+  @Path("/segments/{tableName}/select")

Review Comment:
   @wirybeaver 
   We can change the convention to be:
   
   `Delete all segments -> delete all segments that satisfies the filter`.
   
   `startTime, endTime, excludeReplacedSegments`. Please take a look at `/segments/{tableName}`. It already has those filters for fetching segments.
   
   We can keep the backward compatibility by picking all segments if no filter is provided. How do you think?



-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] wirybeaver commented on pull request #10758: Add a new controller endpoint for segment deletion with a time window

Posted by "wirybeaver (via GitHub)" <gi...@apache.org>.
wirybeaver commented on PR #10758:
URL: https://github.com/apache/pinot/pull/10758#issuecomment-1642565646

   @Jackie-Jiang Do you have an suggestion on which section shall I update? 
   
   This one https://docs.pinot.apache.org/users/api/controller-api-reference ?


-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] Jackie-Jiang commented on pull request #10758: Add a new controller endpoint for segment deletion with a time window

Posted by "Jackie-Jiang (via GitHub)" <gi...@apache.org>.
Jackie-Jiang commented on PR #10758:
URL: https://github.com/apache/pinot/pull/10758#issuecomment-1645189916

   @wirybeaver Sure, let's add it here. Seems we have a lot of APIs not properly documented, but let's not make them more :-P
   Here is the [link](https://github.com/pinot-contrib/pinot-docs/blob/latest/contributing/contributing.md) of how to contribute the doc


-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] ankitsultana commented on a diff in pull request #10758: Add a new controller endpoint for segment deletion with a time window

Posted by "ankitsultana (via GitHub)" <gi...@apache.org>.
ankitsultana commented on code in PR #10758:
URL: https://github.com/apache/pinot/pull/10758#discussion_r1228820464


##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSegmentRestletResource.java:
##########
@@ -884,6 +865,47 @@ public SuccessResponse deleteSegments(
     }
   }
 
+  @DELETE
+  @Consumes(MediaType.APPLICATION_JSON)
+  @Produces(MediaType.APPLICATION_JSON)
+  @Path("/segments/{tableName}/select")

Review Comment:
   We want to be able to delete data older than a given age using an API. At present I think we only have APIs that either delete all segments or delete one particular segment.
   
   This functionality should be useful to everyone since this is a common requirement when you have a lot of customers using Pinot.



-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] wirybeaver commented on a diff in pull request #10758: Add a new controller endpoint for segment deletion with a time window

Posted by "wirybeaver (via GitHub)" <gi...@apache.org>.
wirybeaver commented on code in PR #10758:
URL: https://github.com/apache/pinot/pull/10758#discussion_r1230157359


##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSegmentRestletResource.java:
##########
@@ -1130,4 +1152,38 @@ private SuccessResponse updateZKTimeIntervalInternal(String tableNameWithType) {
       }
       return new SuccessResponse("Successfully updated time interval zk metadata for table: " + tableNameWithType);
   }
+
+  public List<Pair<TableType, List<String>>> selectSegments(

Review Comment:
   I am hesitated to refactor getSelectedSegments() since it has annotation Deprecated.
   
   getSegments() is already refactored with this util function.



-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] tibrewalpratik17 commented on a diff in pull request #10758: Add a new controller endpoint for segment deletion with a time window

Posted by "tibrewalpratik17 (via GitHub)" <gi...@apache.org>.
tibrewalpratik17 commented on code in PR #10758:
URL: https://github.com/apache/pinot/pull/10758#discussion_r1228718762


##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSegmentRestletResource.java:
##########
@@ -1130,4 +1152,38 @@ private SuccessResponse updateZKTimeIntervalInternal(String tableNameWithType) {
       }
       return new SuccessResponse("Successfully updated time interval zk metadata for table: " + tableNameWithType);
   }
+
+  public List<Pair<TableType, List<String>>> selectSegments(

Review Comment:
   Are we planning to add UTs for this method? If not, can we make this `private`?



-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] snleee commented on a diff in pull request #10758: Add a new controller endpoint for segment deletion with a time window

Posted by "snleee (via GitHub)" <gi...@apache.org>.
snleee commented on code in PR #10758:
URL: https://github.com/apache/pinot/pull/10758#discussion_r1248355285


##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSegmentRestletResource.java:
##########
@@ -884,6 +865,52 @@ public SuccessResponse deleteSegments(
     }
   }
 
+  @DELETE
+  @Consumes(MediaType.APPLICATION_JSON)
+  @Produces(MediaType.APPLICATION_JSON)
+  @Path("/segments/{tableName}/select")

Review Comment:
   @wirybeaver We deprecated `GET /segments/{tableName}/select` over `GET /segments`. (We added the annotation). 
   
   Can we add new parameters to `DELETE /segments` API?



-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] wirybeaver commented on a diff in pull request #10758: Add a new controller endpoint for segment deletion with a time window

Posted by "wirybeaver (via GitHub)" <gi...@apache.org>.
wirybeaver commented on code in PR #10758:
URL: https://github.com/apache/pinot/pull/10758#discussion_r1253455169


##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSegmentRestletResource.java:
##########
@@ -884,6 +865,52 @@ public SuccessResponse deleteSegments(
     }
   }
 
+  @DELETE
+  @Consumes(MediaType.APPLICATION_JSON)
+  @Produces(MediaType.APPLICATION_JSON)
+  @Path("/segments/{tableName}/select")

Review Comment:
   @snleee I actually copy the parameters from `GET /segments/{tableName}`, and enforce `GET /segments/{tableName}` and this delete function use the same private method `selectSegments`. It's just a coincidence that the path is identical to the deprecated `GET /segments/{tableName}/select`. I can rename the path to `DELETE /segments/{tableName}/choose`.
   
   The `DELETE /segments/{tableName}` has annotation `@ApiOperation(value = "Delete all segments", notes = "Delete all segments")`, that's the reason why I want to have a different path.



-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] wirybeaver commented on a diff in pull request #10758: Add a new controller endpoint for segment deletion with a time window

Posted by "wirybeaver (via GitHub)" <gi...@apache.org>.
wirybeaver commented on code in PR #10758:
URL: https://github.com/apache/pinot/pull/10758#discussion_r1262755062


##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSegmentRestletResource.java:
##########
@@ -884,6 +865,52 @@ public SuccessResponse deleteSegments(
     }
   }
 
+  @DELETE
+  @Consumes(MediaType.APPLICATION_JSON)
+  @Produces(MediaType.APPLICATION_JSON)
+  @Path("/segments/{tableName}/select")

Review Comment:
   I wanted to enforce both start and end to be non empty to avoid the case that customers incidentally delete all segments due to forgetting inputing (start, end). However, since start and end must be non empty, current `DELETE /segments/{tableName}` will fail, which is a breaking change.
   
   If you thought we don't need to validate empty start and end, I am good to reuse the existing api



-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] wirybeaver commented on pull request #10758: Add a new controller endpoint for segment deletion with a time window

Posted by "wirybeaver (via GitHub)" <gi...@apache.org>.
wirybeaver commented on PR #10758:
URL: https://github.com/apache/pinot/pull/10758#issuecomment-1595423664

   @jtao15 @snleee Could you review the PR when you are available?


-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] wirybeaver commented on a diff in pull request #10758: Add a new controller endpoint for segment deletion with a time window

Posted by "wirybeaver (via GitHub)" <gi...@apache.org>.
wirybeaver commented on code in PR #10758:
URL: https://github.com/apache/pinot/pull/10758#discussion_r1262755062


##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSegmentRestletResource.java:
##########
@@ -884,6 +865,52 @@ public SuccessResponse deleteSegments(
     }
   }
 
+  @DELETE
+  @Consumes(MediaType.APPLICATION_JSON)
+  @Produces(MediaType.APPLICATION_JSON)
+  @Path("/segments/{tableName}/select")

Review Comment:
   I wanted to enforce both start and end to be non empty to avoid the case that customers incidentally delete all segments due to forgetting inputing (start, end). However, since start and end must be non empty, current `DELETE /segments/{tableName}` will fail, which is a breaking change. If you thought we don't need to validate empty start and end, I am good to reuse the existing api



-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] snleee commented on a diff in pull request #10758: Add a new controller endpoint for segment deletion with a time window

Posted by "snleee (via GitHub)" <gi...@apache.org>.
snleee commented on code in PR #10758:
URL: https://github.com/apache/pinot/pull/10758#discussion_r1262799680


##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSegmentRestletResource.java:
##########
@@ -884,6 +865,52 @@ public SuccessResponse deleteSegments(
     }
   }
 
+  @DELETE
+  @Consumes(MediaType.APPLICATION_JSON)
+  @Produces(MediaType.APPLICATION_JSON)
+  @Path("/segments/{tableName}/select")

Review Comment:
   I see. You need the protection. In that case, I'm good with keeping the separate API. It would be nice to have if 'DELETE /segments' also gets extra filter just to have the feature parity with `GET /segments`. Anyway, this can be addressed as part of the separate PR. 



-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] wirybeaver commented on a diff in pull request #10758: Add a new controller endpoint for segment deletion with a time window

Posted by "wirybeaver (via GitHub)" <gi...@apache.org>.
wirybeaver commented on code in PR #10758:
URL: https://github.com/apache/pinot/pull/10758#discussion_r1228752953


##########
pinot-controller/src/test/java/org/apache/pinot/controller/api/PinotSegmentRestletResourceTest.java:
##########
@@ -165,6 +165,30 @@ public void testSegmentCrcApi()
     checkCrcRequest(rawTableName, segmentMetadataTable, 9);
   }
 
+  @Test
+  public void testDeleteSegmentsWithTimeWindow()

Review Comment:
   The endpoint is different with the one that drop all segments. ControllerTest.sendDeleteRequest(urlBuilder.forSegmentDeleteAPI(rawTableName)) will return /segments/<table>/select. The normal endpoint to drop all segments is /segments/<table>
   
   The reason why I don't specify the time range is because mockSegmentMetadata hard code the time range to 1L-10L.  If the time window option is not claimed, the start and end will be filled with default value [0, +inf]. 
   
   I can specify time range [0, Long.MAX_VALUE].



-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] wirybeaver commented on a diff in pull request #10758: Add a new controller endpoint for segment deletion with a time window

Posted by "wirybeaver (via GitHub)" <gi...@apache.org>.
wirybeaver commented on code in PR #10758:
URL: https://github.com/apache/pinot/pull/10758#discussion_r1245956913


##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSegmentRestletResource.java:
##########
@@ -884,6 +865,52 @@ public SuccessResponse deleteSegments(
     }
   }
 
+  @DELETE
+  @Consumes(MediaType.APPLICATION_JSON)
+  @Produces(MediaType.APPLICATION_JSON)
+  @Path("/segments/{tableName}/select")
+  @Authenticate(AccessType.DELETE)
+  @ApiOperation(value = "Delete select segments. An optional 'excludeReplacedSegments' parameter is used to get the"
+      + " list of segments which has not yet been replaced (determined by segment lineage entries) and can be queried"
+      + " from the table. The value is false by default.",
+      // TODO: more and more filters can be added later on, like excludeErrorSegments, excludeConsumingSegments, etc.
+      notes = "List all segments")
+  public SuccessResponse deleteSegmentsWithTimeWindow(
+      @ApiParam(value = "Name of the table", required = true) @PathParam("tableName") String tableName,
+      @ApiParam(value = "OFFLINE|REALTIME") @QueryParam("type") String tableTypeStr,

Review Comment:
   If not specified, both realtime and offline parts will be deleted, which make sense to me.



-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] ankitsultana commented on pull request #10758: [Draft] Add a new controller endpoint for segment deletion with a time window

Posted by "ankitsultana (via GitHub)" <gi...@apache.org>.
ankitsultana commented on PR #10758:
URL: https://github.com/apache/pinot/pull/10758#issuecomment-1579460172

   Thanks @wirybeaver. Let us know when this is ready for review.


-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] jtao15 commented on a diff in pull request #10758: Add a new controller endpoint for segment deletion with a time window

Posted by "jtao15 (via GitHub)" <gi...@apache.org>.
jtao15 commented on code in PR #10758:
URL: https://github.com/apache/pinot/pull/10758#discussion_r1228816672


##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSegmentRestletResource.java:
##########
@@ -884,6 +865,47 @@ public SuccessResponse deleteSegments(
     }
   }
 
+  @DELETE
+  @Consumes(MediaType.APPLICATION_JSON)
+  @Produces(MediaType.APPLICATION_JSON)
+  @Path("/segments/{tableName}/select")

Review Comment:
   Can you please elaborate on why a new api is needed instead of adding more parameters for the existing segment deletion api?



##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSegmentRestletResource.java:
##########
@@ -1130,4 +1152,38 @@ private SuccessResponse updateZKTimeIntervalInternal(String tableNameWithType) {
       }
       return new SuccessResponse("Successfully updated time interval zk metadata for table: " + tableNameWithType);
   }
+
+  public List<Pair<TableType, List<String>>> selectSegments(
+      String tableName,

Review Comment:
   (nit) we usually don't list parameters on separate lines?



##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSegmentRestletResource.java:
##########
@@ -1130,4 +1152,38 @@ private SuccessResponse updateZKTimeIntervalInternal(String tableNameWithType) {
       }
       return new SuccessResponse("Successfully updated time interval zk metadata for table: " + tableNameWithType);
   }
+
+  public List<Pair<TableType, List<String>>> selectSegments(

Review Comment:
   Possible to refactor `getSelectedSegments()` with the same util function as well?



-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] wirybeaver commented on a diff in pull request #10758: Add a new controller endpoint for segment deletion with a time window

Posted by "wirybeaver (via GitHub)" <gi...@apache.org>.
wirybeaver commented on code in PR #10758:
URL: https://github.com/apache/pinot/pull/10758#discussion_r1228831190


##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSegmentRestletResource.java:
##########
@@ -884,6 +865,47 @@ public SuccessResponse deleteSegments(
     }
   }
 
+  @DELETE
+  @Consumes(MediaType.APPLICATION_JSON)
+  @Produces(MediaType.APPLICATION_JSON)
+  @Path("/segments/{tableName}/select")
+  @Authenticate(AccessType.DELETE)
+  @ApiOperation(value = "Delete select segments. An optional 'excludeReplacedSegments' parameter is used to get the"
+      + " list of segments which has not yet been replaced (determined by segment lineage entries) and can be queried"
+      + " from the table. The value is false by default.",
+      // TODO: more and more filters can be added later on, like excludeErrorSegments, excludeConsumingSegments, etc.
+      notes = "List all segments")
+  public SuccessResponse deleteSegmentsWithTimeWindow(
+      @ApiParam(value = "Name of the table", required = true) @PathParam("tableName") String tableName,
+      @ApiParam(value = "OFFLINE|REALTIME") @QueryParam("type") String tableTypeStr,
+      @ApiParam(value = "Whether to keep replaced segments, which have been replaced"
+          + " specified in the segment lineage entries and cannot be queried from the table, false by default")
+      @QueryParam("excludeReplacedSegments") @DefaultValue("false") boolean excludeReplacedSegments,
+      @ApiParam(value = "Start timestamp (inclusive)") @QueryParam("startTimestamp") @DefaultValue("")
+          String startTimestampStr,
+      @ApiParam(value = "End timestamp (exclusive)") @QueryParam("endTimestamp") @DefaultValue("")
+          String endTimestampStr,
+      @ApiParam(value = "Whether to keep segments overlapping with the [start, end) from deletion, true by default")
+      @QueryParam("excludeOverlapping") @DefaultValue("true") boolean excludeOverlapping,

Review Comment:
   IIUC, the excludeOverlapping here means exclude partially overlapped segments.
   
   Let say the segment's min and max time is [100L, 200L]. And the input [start_time, end time] is [150L, 250L]. Since segment contains some data before 150L, I guess customer prefer not deleting this segment, and thus I set the default value to true, indicating "partial overlapping segments won't be delelted"



-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] wirybeaver commented on a diff in pull request #10758: Add a new controller endpoint for segment deletion with a time window

Posted by "wirybeaver (via GitHub)" <gi...@apache.org>.
wirybeaver commented on code in PR #10758:
URL: https://github.com/apache/pinot/pull/10758#discussion_r1253978437


##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSegmentRestletResource.java:
##########
@@ -884,6 +865,52 @@ public SuccessResponse deleteSegments(
     }
   }
 
+  @DELETE
+  @Consumes(MediaType.APPLICATION_JSON)
+  @Produces(MediaType.APPLICATION_JSON)
+  @Path("/segments/{tableName}/select")

Review Comment:
   From the perspective of safety, since it's a delete api, my hunt is to enforce users MUST input non-empty startTime and endTime, which will break the compatibility that delete all segment if no filter is provides. That's another reason to have different PATH. User would know they are doing a dangerous operation if they use `DELETE /segments/{tableName}` meanwhile `DELETE /segments/{tableName}/choose` has a safety guard even though they forgot to add the timestamp.
   
   I am OK to add filters into `DELETE /segments/{tableName}` and remove `DELETE /segments/{tableName}/choose` if you thought the lack of prevention of missing time window is not a major concern.



-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] wirybeaver commented on a diff in pull request #10758: Add a new controller endpoint for segment deletion with a time window

Posted by "wirybeaver (via GitHub)" <gi...@apache.org>.
wirybeaver commented on code in PR #10758:
URL: https://github.com/apache/pinot/pull/10758#discussion_r1253455169


##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSegmentRestletResource.java:
##########
@@ -884,6 +865,52 @@ public SuccessResponse deleteSegments(
     }
   }
 
+  @DELETE
+  @Consumes(MediaType.APPLICATION_JSON)
+  @Produces(MediaType.APPLICATION_JSON)
+  @Path("/segments/{tableName}/select")

Review Comment:
   @snleee I actually copy the parameters from `GET /segments/{tableName}`, and enforce `GET /segments/{tableName}` and this delete function use the same private method `selectSegments`. It's just a coincidence that the path is identical to the deprecated `GET /segments/{tableName}/select`. I can rename the path to `DELETE /segments/{tableName}/choose`.
   
   The existing `DELETE /segments/{tableName}` has a note `@ApiOperation(value = "Delete all segments", notes = "Delete all segments")`, that's the reason why I want to have a different path.



-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] wirybeaver commented on a diff in pull request #10758: Add a new controller endpoint for segment deletion with a time window

Posted by "wirybeaver (via GitHub)" <gi...@apache.org>.
wirybeaver commented on code in PR #10758:
URL: https://github.com/apache/pinot/pull/10758#discussion_r1253455169


##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSegmentRestletResource.java:
##########
@@ -884,6 +865,52 @@ public SuccessResponse deleteSegments(
     }
   }
 
+  @DELETE
+  @Consumes(MediaType.APPLICATION_JSON)
+  @Produces(MediaType.APPLICATION_JSON)
+  @Path("/segments/{tableName}/select")

Review Comment:
   @snleee I actually copy the parameters from `GET /segments/{tableName}`, and enforce `GET /segments/{tableName}` and this delete function use the same private method selectSegments. It's just a coincidence that the path overlap with the deprecated `GET /segments/{tableName}/select`. I can rename the path to `DELETE /segments/{tableName}/choose`.
   
   The `DELETE /segments/{tableName}` has annotation `@ApiOperation(value = "Delete all segments", notes = "Delete all segments")`, that's the reason why I want to have a different path.



-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] wirybeaver commented on a diff in pull request #10758: Add a new controller endpoint for segment deletion with a time window

Posted by "wirybeaver (via GitHub)" <gi...@apache.org>.
wirybeaver commented on code in PR #10758:
URL: https://github.com/apache/pinot/pull/10758#discussion_r1260355019


##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSegmentRestletResource.java:
##########
@@ -884,6 +865,52 @@ public SuccessResponse deleteSegments(
     }
   }
 
+  @DELETE
+  @Consumes(MediaType.APPLICATION_JSON)
+  @Produces(MediaType.APPLICATION_JSON)
+  @Path("/segments/{tableName}/select")

Review Comment:
   @snleee @jtao15 Could you share your idea when you are available? 



-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org