|
28 | 28 | import org.apache.fluss.client.metadata.KvSnapshots; |
29 | 29 | import org.apache.fluss.config.ConfigOptions; |
30 | 30 | import org.apache.fluss.config.Configuration; |
| 31 | +import org.apache.fluss.exception.UnsupportedVersionException; |
31 | 32 | import org.apache.fluss.flink.lake.LakeSplitGenerator; |
32 | 33 | import org.apache.fluss.flink.lake.split.LakeSnapshotAndFlussLogSplit; |
33 | 34 | import org.apache.fluss.flink.lake.split.LakeSnapshotSplit; |
@@ -607,17 +608,33 @@ private KvSnapshots getLatestKvSnapshotsAndRegister(@Nullable String partitionNa |
607 | 608 | kvSnapshotLeaseId, |
608 | 609 | PhysicalTablePath.of(tablePath, partitionName)); |
609 | 610 | long kvSnapshotLeaseDurationMs = leaseContext.getKvSnapshotLeaseDurationMs(); |
610 | | - Set<TableBucket> unavailableTableBucketSet = |
611 | | - flussAdmin |
612 | | - .createKvSnapshotLease(kvSnapshotLeaseId, kvSnapshotLeaseDurationMs) |
613 | | - .acquireSnapshots(bucketsToLease) |
614 | | - .get() |
615 | | - .getUnavailableTableBucketSet(); |
616 | | - if (!unavailableTableBucketSet.isEmpty()) { |
617 | | - LOG.error( |
618 | | - "Failed to acquire kv snapshot lease for table {}: {}.", |
619 | | - tablePath, |
620 | | - unavailableTableBucketSet); |
| 611 | + try { |
| 612 | + Set<TableBucket> unavailableTableBucketSet = |
| 613 | + flussAdmin |
| 614 | + .createKvSnapshotLease( |
| 615 | + kvSnapshotLeaseId, kvSnapshotLeaseDurationMs) |
| 616 | + .acquireSnapshots(bucketsToLease) |
| 617 | + .get() |
| 618 | + .getUnavailableTableBucketSet(); |
| 619 | + if (!unavailableTableBucketSet.isEmpty()) { |
| 620 | + LOG.error( |
| 621 | + "Failed to acquire kv snapshot lease for table {}: {}.", |
| 622 | + tablePath, |
| 623 | + unavailableTableBucketSet); |
| 624 | + } |
| 625 | + } catch (Exception e) { |
| 626 | + if (ExceptionUtils.findThrowable(e, UnsupportedVersionException.class) |
| 627 | + .isPresent()) { |
| 628 | + LOG.warn( |
| 629 | + "Failed to acquire kv snapshot lease for table {} because the " |
| 630 | + + "server does not support kv snapshot lease API. " |
| 631 | + + "Snapshots may be cleaned up earlier than expected. " |
| 632 | + + "Please upgrade the Fluss server to version 0.9 or later.", |
| 633 | + tablePath, |
| 634 | + e); |
| 635 | + } else { |
| 636 | + throw e; |
| 637 | + } |
621 | 638 | } |
622 | 639 | } |
623 | 640 | } catch (Exception e) { |
@@ -1054,10 +1071,21 @@ public void notifyCheckpointComplete(long checkpointId) throws Exception { |
1054 | 1071 | .releaseSnapshots(consumedKvSnapshots) |
1055 | 1072 | .get(); |
1056 | 1073 | } catch (Exception e) { |
1057 | | - LOG.error("Failed to release kv snapshot lease. These snapshot need to re-enqueue", e); |
1058 | | - // use the current checkpoint id to re-enqueue the buckets |
1059 | | - consumedKvSnapshots.forEach( |
1060 | | - tableBucket -> addConsumedBucket(checkpointId, tableBucket)); |
| 1074 | + if (ExceptionUtils.findThrowable(e, UnsupportedVersionException.class).isPresent()) { |
| 1075 | + LOG.warn( |
| 1076 | + "Failed to release kv snapshot lease because the server does not support " |
| 1077 | + + "kv snapshot lease API. Snapshots may remain in storage longer " |
| 1078 | + + "than necessary. Please upgrade the Fluss server to version 0.9 " |
| 1079 | + + "or later.", |
| 1080 | + e); |
| 1081 | + } else { |
| 1082 | + LOG.error( |
| 1083 | + "Failed to release kv snapshot lease. These snapshots need to re-enqueue", |
| 1084 | + e); |
| 1085 | + // use the current checkpoint id to re-enqueue the buckets |
| 1086 | + consumedKvSnapshots.forEach( |
| 1087 | + tableBucket -> addConsumedBucket(checkpointId, tableBucket)); |
| 1088 | + } |
1061 | 1089 | } |
1062 | 1090 | } |
1063 | 1091 |
|
@@ -1114,12 +1142,25 @@ private void maybeDropKvSnapshotLease() throws Exception { |
1114 | 1142 | "Dropping kv snapshot lease {} when source enumerator close. isStreaming {}", |
1115 | 1143 | leaseContext.getKvSnapshotLeaseId(), |
1116 | 1144 | streaming); |
1117 | | - flussAdmin |
1118 | | - .createKvSnapshotLease( |
1119 | | - leaseContext.getKvSnapshotLeaseId(), |
1120 | | - leaseContext.getKvSnapshotLeaseDurationMs()) |
1121 | | - .dropLease() |
1122 | | - .get(); |
| 1145 | + try { |
| 1146 | + flussAdmin |
| 1147 | + .createKvSnapshotLease( |
| 1148 | + leaseContext.getKvSnapshotLeaseId(), |
| 1149 | + leaseContext.getKvSnapshotLeaseDurationMs()) |
| 1150 | + .dropLease() |
| 1151 | + .get(); |
| 1152 | + } catch (Exception e) { |
| 1153 | + if (ExceptionUtils.findThrowable(e, UnsupportedVersionException.class) |
| 1154 | + .isPresent()) { |
| 1155 | + LOG.warn( |
| 1156 | + "Failed to drop kv snapshot lease because the server does not support " |
| 1157 | + + "kv snapshot lease API. Please upgrade the Fluss server to " |
| 1158 | + + "version 0.9 or later.", |
| 1159 | + e); |
| 1160 | + } else { |
| 1161 | + throw e; |
| 1162 | + } |
| 1163 | + } |
1123 | 1164 | } |
1124 | 1165 | } |
1125 | 1166 |
|
|
0 commit comments