This is an automated email from the ASF dual-hosted git repository. lzljs3620320 pushed a commit to branch release-1.0 in repository https://gitbox.apache.org/repos/asf/paimon.git
commit 77b9c000e680e3ac9483a0773eb9680c0accef39 Author: jerry <[email protected]> AuthorDate: Mon Jan 6 15:40:26 2025 +0800 [core] overwrite should be true when commit change log (#4838) --- .../main/java/org/apache/paimon/utils/SnapshotManager.java | 2 +- .../java/org/apache/paimon/utils/SnapshotManagerTest.java | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/paimon-core/src/main/java/org/apache/paimon/utils/SnapshotManager.java b/paimon-core/src/main/java/org/apache/paimon/utils/SnapshotManager.java index 49da83bfe4..ae70d7aec5 100644 --- a/paimon-core/src/main/java/org/apache/paimon/utils/SnapshotManager.java +++ b/paimon-core/src/main/java/org/apache/paimon/utils/SnapshotManager.java @@ -745,7 +745,7 @@ public class SnapshotManager implements Serializable { } public void commitChangelog(Changelog changelog, long id) throws IOException { - fileIO.writeFile(longLivedChangelogPath(id), changelog.toJson(), false); + fileIO.writeFile(longLivedChangelogPath(id), changelog.toJson(), true); } /** diff --git a/paimon-core/src/test/java/org/apache/paimon/utils/SnapshotManagerTest.java b/paimon-core/src/test/java/org/apache/paimon/utils/SnapshotManagerTest.java index 26480cf411..e828a0c90a 100644 --- a/paimon-core/src/test/java/org/apache/paimon/utils/SnapshotManagerTest.java +++ b/paimon-core/src/test/java/org/apache/paimon/utils/SnapshotManagerTest.java @@ -39,6 +39,7 @@ import java.util.stream.Collectors; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; /** Tests for {@link SnapshotManager}. */ public class SnapshotManagerTest { @@ -398,4 +399,15 @@ public class SnapshotManagerTest { Assertions.assertThat(snapshotManager.latestSnapshotId()).isEqualTo(10); Assertions.assertThat(snapshotManager.changelog(1)).isNotNull(); } + + @Test + public void testCommitChangelogWhenSameChangelogCommitTwice() throws IOException { + FileIO localFileIO = LocalFileIO.create(); + SnapshotManager snapshotManager = + new SnapshotManager(localFileIO, new Path(tempDir.toString())); + long id = 1L; + Changelog changelog = createChangelogWithMillis(id, 1L); + snapshotManager.commitChangelog(changelog, id); + assertDoesNotThrow(() -> snapshotManager.commitChangelog(changelog, id)); + } }
