mvanhorn commented on code in PR #11102:
URL: https://github.com/apache/paimon/pull/11102#discussion_r4563808279
##########
paimon-core/src/main/java/org/apache/paimon/operation/FileStoreCommitImpl.java:
##########
@@ -333,6 +348,120 @@ public List<ManifestCommittable>
filterCommitted(List<ManifestCommittable> commi
}
}
+ @Nullable
+ private ManifestCommittable recoverCompact(ManifestCommittable
committable) {
+ List<CommitMessage> messages = new ArrayList<>();
+ Set<Path> outputs = new HashSet<>();
+ DataFilePathFactories dataFactories = new
DataFilePathFactories(pathFactory);
+ IndexFilePathFactories indexFactories = new
IndexFilePathFactories(pathFactory);
+ for (CommitMessage message : committable.fileCommittables()) {
+ CompactIncrement compact = ((CommitMessageImpl)
message).compactIncrement();
+ if (compact.isEmpty()) {
+ continue;
+ }
+ messages.add(
+ new CommitMessageImpl(
+ message.partition(),
+ message.bucket(),
+ message.totalBuckets(),
+ DataIncrement.emptyIncrement(),
+ compact,
+ message.checkFromSnapshot()));
+ DataFilePathFactory dataFactory =
+ dataFactories.get(message.partition(), message.bucket());
+ compact.compactAfter().forEach(file ->
outputs.addAll(file.collectFiles(dataFactory)));
+ compact.changelogFiles()
+ .forEach(file ->
outputs.addAll(file.collectFiles(dataFactory)));
+ IndexPathFactory indexFactory =
+ indexFactories.get(message.partition(), message.bucket());
+ compact.newIndexFiles().forEach(file ->
outputs.add(indexFactory.toPath(file)));
+ }
+ if (messages.isEmpty()) {
+ return null;
+ }
+ // An expired or orphan-cleaned output cannot be replayed. Skip the
whole identifier,
+ // rather than publishing only some of its buckets. I/O failures must
still fail recovery.
+ for (Path output : outputs) {
+ Path physicalPath =
+
CompactedChangelogPathResolver.resolveCompactedChangelogPath(output);
+ try {
+ if (!fileIO.exists(physicalPath)) {
+ LOG.warn(
+ "Skipping compaction recovery for table {}, user
{}, identifier {}: output {} is missing",
+ tableName,
+ commitUser,
+ committable.identifier(),
+ physicalPath);
+ return null;
+ }
+ } catch (IOException e) {
+ throw new UncheckedIOException(e);
+ }
+ }
+ if (!compactInputsStillLive(committable)) {
+ return null;
+ }
+ return new CompactRecoveryCommittable(committable, messages);
+ }
+
+ /**
+ * A concurrent compaction may already have removed some compact-before
files. Replaying such an
+ * increment would fail conflict detection on every restart, so only
recover it when all of its
+ * inputs are still live in the latest snapshot.
+ */
+ private boolean compactInputsStillLive(ManifestCommittable committable) {
+ Set<List<Object>> inputs = new HashSet<>();
+ Set<String> inputNames = new HashSet<>();
+ Set<BinaryRow> partitions = new HashSet<>();
+ for (CommitMessage message : committable.fileCommittables()) {
+ for (DataFileMeta file :
+ ((CommitMessageImpl)
message).compactIncrement().compactBefore()) {
+ inputs.add(Arrays.asList(message.partition(),
message.bucket(), file.fileName()));
Review Comment:
Agreed, matching on partition/bucket/name misses the in-place level upgrade.
I'll change compactInputsStillLive to compare the full FileEntry.Identifier
(level and extra metadata included) and add your
testFilterHalfCommittedIdentifierWithConcurrentlyUpgradedInput regression to
the PR.
<!-- r:f19ed8a95547.794d1ca84a60 -->
--
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]