From c313fdddbbf15a91641cdd81ae88e1fb69f8367f Mon Sep 17 00:00:00 2001 From: mattl-netflix <63665634+mattl-netflix@users.noreply.github.com> Date: Mon, 7 Jun 2021 22:23:14 -0700 Subject: [PATCH] Revert behavior back to truncating milliseconds in backups last modified time. (#948) --- .../netflix/priam/aws/RemoteBackupPath.java | 5 ++++- .../priam/aws/TestRemoteBackupPath.java | 20 +++++++++++++------ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/priam/src/main/java/com/netflix/priam/aws/RemoteBackupPath.java b/priam/src/main/java/com/netflix/priam/aws/RemoteBackupPath.java index a7fb7098a..f4e8cb07f 100644 --- a/priam/src/main/java/com/netflix/priam/aws/RemoteBackupPath.java +++ b/priam/src/main/java/com/netflix/priam/aws/RemoteBackupPath.java @@ -84,7 +84,10 @@ private String removeHash(String appNameWithHash) { */ private String getV2Location() { ImmutableList.Builder parts = getV2Prefix(); - parts.add(type.toString(), getLastModified().toEpochMilli() + ""); + // JDK-8177809 truncate to seconds to ensure consistent behavior with our old method of + // getting lastModified time (File::lastModified) in Java 8. + long lastModified = getLastModified().toEpochMilli() / 1_000L * 1_000L; + parts.add(type.toString(), lastModified + ""); if (BackupFileType.isDataFile(type)) { parts.add(keyspace, columnFamily); } diff --git a/priam/src/test/java/com/netflix/priam/aws/TestRemoteBackupPath.java b/priam/src/test/java/com/netflix/priam/aws/TestRemoteBackupPath.java index ad845914c..72ede456e 100644 --- a/priam/src/test/java/com/netflix/priam/aws/TestRemoteBackupPath.java +++ b/priam/src/test/java/com/netflix/priam/aws/TestRemoteBackupPath.java @@ -154,7 +154,9 @@ public void testV2BackupPathSST() { AbstractBackupPath abstractBackupPath2 = pathFactory.get(); abstractBackupPath2.parseRemote(remotePath); - Assert.assertEquals(now, abstractBackupPath2.getLastModified()); + Assert.assertEquals( + now.toEpochMilli() / 1_000L * 1_000L, + abstractBackupPath2.getLastModified().toEpochMilli()); validateAbstractBackupPath(abstractBackupPath, abstractBackupPath2); } @@ -183,7 +185,9 @@ public void testV2BackupPathMeta() { AbstractBackupPath abstractBackupPath2 = pathFactory.get(); abstractBackupPath2.parseRemote(remotePath); - Assert.assertEquals(now, abstractBackupPath2.getLastModified()); + Assert.assertEquals( + now.toEpochMilli() / 1_000L * 1_000L, + abstractBackupPath2.getLastModified().toEpochMilli()); validateAbstractBackupPath(abstractBackupPath, abstractBackupPath2); } @@ -214,15 +218,17 @@ public void testV2BackupPathSecondaryIndex() { abstractBackupPath.setLastModified(now); String remotePath = abstractBackupPath.getRemotePath(); logger.info(remotePath); + long correctLastModified = +now.toEpochMilli() / 1_000L * 1_000L; Assert.assertEquals( "casstestbackup/1049_fake-app/1808575600/SECONDARY_INDEX_V2/" - + now.toEpochMilli() + + correctLastModified + "/keyspace1/columnfamily1/.columnfamily1_field1_idx/SNAPPY/PLAINTEXT/mc-1234-Data.db", remotePath); AbstractBackupPath abstractBackupPath2 = pathFactory.get(); abstractBackupPath2.parseRemote(remotePath); - Assert.assertEquals(now, abstractBackupPath2.getLastModified()); + Assert.assertEquals( + correctLastModified, abstractBackupPath2.getLastModified().toEpochMilli()); validateAbstractBackupPath(abstractBackupPath, abstractBackupPath2); } @@ -254,15 +260,17 @@ public void testV2SnapshotPathSecondaryIndex() { abstractBackupPath.setLastModified(now); String remotePath = abstractBackupPath.getRemotePath(); logger.info(remotePath); + long correctLastModified = +now.toEpochMilli() / 1_000L * 1_000L; Assert.assertEquals( "casstestbackup/1049_fake-app/1808575600/SECONDARY_INDEX_V2/" - + now.toEpochMilli() + + correctLastModified + "/keyspace1/columnfamily1/.columnfamily1_field1_idx/SNAPPY/PLAINTEXT/mc-1234-Data.db", remotePath); AbstractBackupPath abstractBackupPath2 = pathFactory.get(); abstractBackupPath2.parseRemote(remotePath); - Assert.assertEquals(now, abstractBackupPath2.getLastModified()); + Assert.assertEquals( + correctLastModified, abstractBackupPath2.getLastModified().toEpochMilli()); validateAbstractBackupPath(abstractBackupPath, abstractBackupPath2); }