Jackie-Jiang commented on code in PR #20284:
URL: https://github.com/apache/pinot/pull/20284#discussion_r4607733408
##########
pinot-controller/src/test/java/org/apache/pinot/controller/api/upload/ZKOperatorTest.java:
##########
@@ -428,29 +428,35 @@ public void testRefreshWithTarDeletesStaleMetadataTar()
}
@Test
- public void testRefreshWithMetadataPushKeepsSidecarGeneratedByTheSameJob()
+ public void
testRefreshWithMetadataPushDeletesSidecarOfPreviousBuildStagedInTheSameDirectory()
throws Exception {
PinotFSFactory.init(new PinotConfiguration());
ZKOperator zkOperator = new ZKOperator(_resourceManager,
mock(ControllerConf.class), mock(ControllerMetrics.class));
HttpHeaders httpHeaders = mock(HttpHeaders.class);
File tableDir = new File(DATA_DIR, OFFLINE_TABLE_NAME);
- String segmentName = "sidecarMetadataPushSameJobSegment";
- // The batch job staged the segment tar and its fresh sidecar next to each
other in the table dir.
+ String segmentName = "sidecarMetadataPushSameDirSegment";
+ // The tar and the sidecar of the previous build are staged next to each
other in the table dir.
File sourceTar = new File(tableDir, segmentName + ".tar.gz");
FileUtils.write(sourceTar, "segment bytes", "UTF-8");
File sidecar = new File(tableDir, segmentName +
Constants.METADATA_TAR_GZ_FILE_EXT);
- FileUtils.write(sidecar, "current metadata", "UTF-8");
+ FileUtils.write(sidecar, "old metadata", "UTF-8");
URI finalLocation = new File(tableDir, segmentName).toURI();
zkOperator.completeSegmentOperations(OFFLINE_TABLE_CONFIG,
mockSegmentMetadata(segmentName, 1L),
FileUploadType.METADATA, finalLocation, null,
sourceTar.toURI().toString(), finalLocation.toString(),
"crypter", 10, true, true, httpHeaders);
+ // A first push has no previous segment, so nothing is invalidated.
+ assertTrue(sidecar.exists());
+
+ // The tar is replaced by a changed build while the sidecar is not, and
the request carries fresh metadata
+ // (a push with preferMetadataTarGz=false extracts it from the tar rather
than reading the sidecar).
+ FileUtils.write(sourceTar, "changed segment bytes", "UTF-8");
zkOperator.completeSegmentOperations(OFFLINE_TABLE_CONFIG,
mockSegmentMetadata(segmentName, 2L),
Review Comment:
Non-blocking test improvement: please cover invalidation failures
(`exists()` throws, `delete()` throws, and `delete()` returns `false`) as well
as this successful refresh. Assert that the existing segment bytes and
ZooKeeper CRC remain unchanged, no refresh is sent, the upload lock is
released, and a subsequent retry succeeds. The current ordering and failure
handling look sound; these tests would protect that contract.
##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/upload/ZKOperator.java:
##########
@@ -685,18 +684,13 @@ private void copyFromSegmentURIToDeepStore(URI
sourceDownloadURI, URI finalSegme
}
/// A refresh replaces the full segment, so a sidecar left by the previous
build would describe the wrong bytes (a
- /// metadata push trusts an existing sidecar). The exception is a METADATA
push whose own sidecar (next to the source
- /// tar, describing the bytes about to be copied) is exactly the file we
would delete: it is kept. This runs for every
- /// refresh regardless of the preserve flags because batch jobs write
sidecars independent of them. Failing to
- /// invalidate fails the refresh.
- private void invalidateStaleMetadataTar(String segmentName, FileUploadType
uploadType, String sourceDownloadURIStr,
- URI finalSegmentLocationURI)
+ /// metadata push trusts an existing sidecar). It is deleted even when the
push staged its own sidecar next to the
+ /// source tar: matching paths do not show that the sidecar describes the
incoming build, because the request
+ /// metadata may have been extracted from the tar instead. This runs for
every refresh regardless of the preserve
Review Comment:
Non-blocking documentation/naming cleanup: "every refresh" is broader than
the actual call site, which runs for a changed-CRC refresh with a non-null
final segment destination. Please make that scope explicit. Naming the
helper/log messages around deleting the "existing" or "previous" sidecar would
also be more precise than "stale", since this intentionally removes valid
sidecars as well when freshness cannot be established.
##########
pinot-controller/src/test/java/org/apache/pinot/controller/api/upload/ZKOperatorTest.java:
##########
@@ -428,29 +428,35 @@ public void testRefreshWithTarDeletesStaleMetadataTar()
}
@Test
- public void testRefreshWithMetadataPushKeepsSidecarGeneratedByTheSameJob()
+ public void
testRefreshWithMetadataPushDeletesSidecarOfPreviousBuildStagedInTheSameDirectory()
throws Exception {
PinotFSFactory.init(new PinotConfiguration());
ZKOperator zkOperator = new ZKOperator(_resourceManager,
mock(ControllerConf.class), mock(ControllerMetrics.class));
HttpHeaders httpHeaders = mock(HttpHeaders.class);
File tableDir = new File(DATA_DIR, OFFLINE_TABLE_NAME);
Review Comment:
Non-blocking parity coverage: could this regression test be parameterized
for both OFFLINE and REALTIME with a non-null final destination? The existing
REALTIME cases pass a null destination and therefore bypass sidecar
invalidation. Please also assert the resulting ZooKeeper CRC, alongside the
sidecar deletion and changed full-segment bytes.
##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/upload/ZKOperator.java:
##########
@@ -685,18 +684,13 @@ private void copyFromSegmentURIToDeepStore(URI
sourceDownloadURI, URI finalSegme
}
/// A refresh replaces the full segment, so a sidecar left by the previous
build would describe the wrong bytes (a
- /// metadata push trusts an existing sidecar). The exception is a METADATA
push whose own sidecar (next to the source
- /// tar, describing the bytes about to be copied) is exactly the file we
would delete: it is kept. This runs for every
- /// refresh regardless of the preserve flags because batch jobs write
sidecars independent of them. Failing to
- /// invalidate fails the refresh.
- private void invalidateStaleMetadataTar(String segmentName, FileUploadType
uploadType, String sourceDownloadURIStr,
- URI finalSegmentLocationURI)
+ /// metadata push trusts an existing sidecar). It is deleted even when the
push staged its own sidecar next to the
+ /// source tar: matching paths do not show that the sidecar describes the
incoming build, because the request
+ /// metadata may have been extracted from the tar instead. This runs for
every refresh regardless of the preserve
+ /// flags because batch jobs write sidecars independent of them. Failing to
invalidate fails the refresh.
+ private void invalidateStaleMetadataTar(String segmentName, URI
finalSegmentLocationURI)
throws Exception {
URI metadataTarURI = URIUtils.getUri(finalSegmentLocationURI +
Constants.METADATA_TAR_GZ_FILE_EXT);
- if (uploadType == FileUploadType.METADATA
- && SegmentPushUtils.generateSegmentMetadataURI(sourceDownloadURIStr,
segmentName).equals(metadataTarURI)) {
- return;
- }
PinotFS pinotFS =
PinotFSFactory.create(finalSegmentLocationURI.getScheme());
if (pinotFS.exists(metadataTarURI)) {
Preconditions.checkState(pinotFS.delete(metadataTarURI, true), "Failed
to delete stale metadata tar: %s",
Review Comment:
Optional observability improvement: a table-type-neutral counter for
metadata-sidecar invalidation failures would make storage/permission failures
easier to distinguish from other upload failures. This path currently
contributes to the generic upload-failure signal; a dedicated counter would
help diagnose failures for both OFFLINE and REALTIME without reusing the
LLC-specific REALTIME metric.
--
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]