4949import org .apache .paimon .operation .commit .ConflictDetection ;
5050import org .apache .paimon .operation .commit .ManifestEntryChanges ;
5151import org .apache .paimon .operation .commit .RetryCommitResult ;
52+ import org .apache .paimon .operation .commit .RetryCommitResult .CommitFailRetryResult ;
5253import org .apache .paimon .operation .commit .RowTrackingCommitUtils .RowTrackingAssigned ;
5354import org .apache .paimon .operation .commit .StrictModeChecker ;
5455import org .apache .paimon .operation .commit .SuccessCommitResult ;
@@ -786,13 +787,15 @@ CommitResult tryCommitOnce(
786787
787788 // Check if the commit has been completed. At this point, there will be no more repeated
788789 // commits and just return success
789- if (retryResult != null && latestSnapshot != null ) {
790+ if (retryResult instanceof CommitFailRetryResult && latestSnapshot != null ) {
791+ CommitFailRetryResult commitFailRetry = (CommitFailRetryResult ) retryResult ;
790792 Map <Long , Snapshot > snapshotCache = new HashMap <>();
791793 snapshotCache .put (latestSnapshot .id (), latestSnapshot );
792794 long startCheckSnapshot = Snapshot .FIRST_SNAPSHOT_ID ;
793- if (retryResult .latestSnapshot != null ) {
794- snapshotCache .put (retryResult .latestSnapshot .id (), retryResult .latestSnapshot );
795- startCheckSnapshot = retryResult .latestSnapshot .id () + 1 ;
795+ if (commitFailRetry .latestSnapshot != null ) {
796+ snapshotCache .put (
797+ commitFailRetry .latestSnapshot .id (), commitFailRetry .latestSnapshot );
798+ startCheckSnapshot = commitFailRetry .latestSnapshot .id () + 1 ;
796799 }
797800 for (long i = startCheckSnapshot ; i <= latestSnapshot .id (); i ++) {
798801 Snapshot snapshot = snapshotCache .computeIfAbsent (i , snapshotManager ::snapshot );
@@ -836,13 +839,17 @@ CommitResult tryCommitOnce(
836839 // latestSnapshotId is different from the snapshot id we've checked for conflicts,
837840 // so we have to check again
838841 List <BinaryRow > changedPartitions = changedPartitions (deltaFiles , indexFiles );
839- if (retryResult != null
840- && retryResult .latestSnapshot != null
841- && retryResult .baseDataFiles != null ) {
842- baseDataFiles = new ArrayList <>(retryResult .baseDataFiles );
842+ CommitFailRetryResult commitFailRetry =
843+ retryResult instanceof CommitFailRetryResult
844+ ? (CommitFailRetryResult ) retryResult
845+ : null ;
846+ if (commitFailRetry != null
847+ && commitFailRetry .latestSnapshot != null
848+ && commitFailRetry .baseDataFiles != null ) {
849+ baseDataFiles = new ArrayList <>(commitFailRetry .baseDataFiles );
843850 List <SimpleFileEntry > incremental =
844851 scanner .readIncrementalChanges (
845- retryResult .latestSnapshot , latestSnapshot , changedPartitions );
852+ commitFailRetry .latestSnapshot , latestSnapshot , changedPartitions );
846853 if (!incremental .isEmpty ()) {
847854 baseDataFiles .addAll (incremental );
848855 baseDataFiles = new ArrayList <>(FileEntry .mergeEntries (baseDataFiles ));
@@ -872,7 +879,7 @@ CommitResult tryCommitOnce(
872879 if (exception .isPresent ()) {
873880 if (allowRollback && rollback != null ) {
874881 if (rollback .tryToRollback (latestSnapshot )) {
875- return RetryCommitResult .ofEmpty (exception .get ());
882+ return RetryCommitResult .forRollback (exception .get ());
876883 }
877884 }
878885 throw exception .get ();
@@ -1005,7 +1012,7 @@ CommitResult tryCommitOnce(
10051012 } catch (Exception e ) {
10061013 // commit exception, not sure about the situation and should not clean up the files
10071014 LOG .warn ("Retry commit for exception." , e );
1008- return RetryCommitResult .ofContext (latestSnapshot , baseDataFiles , e );
1015+ return RetryCommitResult .forCommitFail (latestSnapshot , baseDataFiles , e );
10091016 }
10101017
10111018 if (!success ) {
@@ -1022,7 +1029,7 @@ CommitResult tryCommitOnce(
10221029 commitTime );
10231030 commitCleaner .cleanUpNoReuseTmpManifests (
10241031 baseManifestList , mergeBeforeManifests , mergeAfterManifests );
1025- return RetryCommitResult .ofContext (latestSnapshot , baseDataFiles , null );
1032+ return RetryCommitResult .forCommitFail (latestSnapshot , baseDataFiles , null );
10261033 }
10271034
10281035 LOG .info (
0 commit comments