Compare commits
31
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6f365d4048 | ||
|
|
790de11827
|
||
|
|
8252d4fb14 | ||
|
|
1f916556a2 | ||
|
|
f4de56dd9e
|
||
|
|
1f2557e96c | ||
|
|
5adc79976d | ||
|
|
0eb18a36da
|
||
|
|
4d56012352
|
||
|
|
a17c6739bb | ||
|
|
11156c8e8c | ||
|
|
0cc273bb52
|
||
|
|
036cd45f32 | ||
|
|
eaa6c9b93a | ||
|
|
33cb1f7a17 | ||
|
|
773629d253
|
||
|
|
9855521637 | ||
|
|
99f74b4b5f
|
||
|
|
fa9c4c1774 | ||
|
|
c8ba79f55b
|
||
|
|
7830226982 | ||
|
|
b1f258a3d5
|
||
|
|
3df24cda5a | ||
|
|
987c20899b
|
||
|
|
14bb6fa1b4 | ||
|
|
b1ff70d7d3
|
||
|
|
cda334f2fe | ||
|
|
590b132fb6
|
||
|
|
f0a8c5000e | ||
|
|
8f3f9ec60a
|
||
|
|
cdaf218201 |
No files matched your search
@@ -19,7 +19,6 @@ All notable changes to this project are documented here. The format follows Keep
|
||||
- Repository scaffold: `BackupsQBitConfig` and `BackupsQBitProducer` (table prefix `backups_`, permissions `backups.*`), build, CI and repository standard files.
|
||||
|
||||
### Changed
|
||||
- **A plan with an unfinished backup could not be pruned on real storage.** A listing through the object-storage qbit dropped each object's modification time, and the pruner compared those times to find backups that never finished and are older than 7 days: with one failed run under a plan, every prune of that plan threw. The listing carries the time now, and the pruner dates an unfinished backup by its run record where a storage lists no times (and never deletes as old what it cannot date). The in-memory storage of the tests supplies times, which is why no test saw it; a host's live check did.
|
||||
- **The daily prune prunes.** It is a process of its own, `backupPruneScheduled` (`BackupScheduledPruneProcess`), which prunes every active plan with nobody selecting anything. The schedule used to be on "Prune per retention" (`backupPrune`), an action for a person that needs plans selected and a review: started by a scheduler it answered "No records were selected", the scheduler logged a warning, and no old backup was ever deleted by the schedule. `backupPrune` has no schedule now. A host that scheduled it itself should stop.
|
||||
- The file index of an encrypted run (`files/index-00001.jsonl.gz`: tables, record keys and where each file came from) is encrypted like every other object of the run. It was written in the clear while the catalog recorded it as encrypted, and a restore from an encrypted run could not read it. No release could encrypt before this one, so no stored run is affected.
|
||||
- A plan that asks for encryption without a key provider is refused with "no key provider is configured" (was "not available in this version"); a refused run names the key reference.
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
<qqq.version>4.1.0-RC.26</qqq.version> <!-- feeds qbit-build-parent's qqq-bom-pom import -->
|
||||
<qbit.guardrails.enforce>true</qbit.guardrails.enforce>
|
||||
<qbit.guardrails.strictUiApiRoutes>true</qbit.guardrails.strictUiApiRoutes>
|
||||
<revision>0.1.0-SNAPSHOT</revision>
|
||||
<revision>0.1.0-RC.14</revision>
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
<maven.compiler.target>21</maven.compiler.target>
|
||||
<jacoco.version>0.8.15</jacoco.version>
|
||||
|
||||
@@ -425,44 +425,6 @@ public class BackupPruner
|
||||
/*******************************************************************************
|
||||
** Prefixes of the plan that never got a manifest and are old enough.
|
||||
*******************************************************************************/
|
||||
/*******************************************************************************
|
||||
** When the newest object of an unfinished backup was written. A storage may
|
||||
** list objects without their times: then the run's own record dates them (its
|
||||
** end, else its start), and where there is no run record either the prefix is
|
||||
** taken as written now, so nothing that cannot be dated is deleted as old.
|
||||
*******************************************************************************/
|
||||
static Instant newestOf(List<StoredObjectInfo> objects, QRecord run, Instant now)
|
||||
{
|
||||
Instant newest = null;
|
||||
boolean undated = false;
|
||||
for(StoredObjectInfo object : objects)
|
||||
{
|
||||
if(object.lastModified() == null)
|
||||
{
|
||||
undated = true;
|
||||
}
|
||||
else if(newest == null || object.lastModified().isAfter(newest))
|
||||
{
|
||||
newest = object.lastModified();
|
||||
}
|
||||
}
|
||||
if(!undated && newest != null)
|
||||
{
|
||||
return (newest);
|
||||
}
|
||||
Instant recorded = run == null ? null : run.getValueInstant("endDate") != null ? run.getValueInstant("endDate") : run.getValueInstant("startDate");
|
||||
if(recorded == null)
|
||||
{
|
||||
return (now);
|
||||
}
|
||||
return (newest != null && newest.isAfter(recorded) ? newest : recorded);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** The prefixes of backups that never finished and are old enough to delete.
|
||||
*******************************************************************************/
|
||||
private List<DebrisPlan> debris(QRecord plan, List<QRecord> allRuns, BackupStorage deleteSide, Instant now) throws QException
|
||||
{
|
||||
String prefix = planPrefix(plan);
|
||||
@@ -499,7 +461,7 @@ public class BackupPruner
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Instant newest = newestOf(objects, run, now);
|
||||
Instant newest = objects.stream().map(StoredObjectInfo::lastModified).max(Comparator.naturalOrder()).orElse(now);
|
||||
if(newest.isAfter(now.minus(Duration.ofDays(PruneCalculator.DEBRIS_DAYS))))
|
||||
{
|
||||
continue;
|
||||
|
||||
+1
-12
@@ -128,18 +128,7 @@ public class BackupScheduledPruneProcess implements BackendStep
|
||||
// failure it was; a message could carry a key or an endpoint //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
failed++;
|
||||
if(e instanceof RuntimeException)
|
||||
{
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// a defect, not a condition of the storage: its stack trace says where, //
|
||||
// and holds no data //
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
LOG.warn("A backup plan could not be pruned", e, logPair("plan", planKey));
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG.warn("A backup plan could not be pruned", logPair("plan", planKey), logPair("failure", e.getClass().getSimpleName()));
|
||||
}
|
||||
LOG.warn("A backup plan could not be pruned", logPair("plan", planKey), logPair("failure", e.getClass().getSimpleName()));
|
||||
BackupAlerts.raise(BackupAlerts.PRUNE_FAILED, planKey, BackupAlertSink.Severity.WARNING, "Old backups of " + plan.getValueString("name") + " could not be deleted",
|
||||
"plan", planKey, "failure", e.getClass().getSimpleName());
|
||||
}
|
||||
|
||||
+1
-1
@@ -323,7 +323,7 @@ public class ObjectStorageBackupStorage implements BackupStorage
|
||||
Page<ObjectSummary> page = bucket.list(ListRequest.prefix(prefix == null ? "" : prefix).pageSize(1000).after(after));
|
||||
for(ObjectSummary summary : page.getItems())
|
||||
{
|
||||
rs.add(new StoredObjectInfo(summary.getKey(), summary.getSize() == null ? 0 : summary.getSize(), summary.getLastModified(), new LinkedHashMap<>(), null));
|
||||
rs.add(new StoredObjectInfo(summary.getKey(), summary.getSize() == null ? 0 : summary.getSize(), null, new LinkedHashMap<>(), null));
|
||||
}
|
||||
after = page.getNextToken();
|
||||
}
|
||||
|
||||
@@ -317,63 +317,6 @@ class BackupPrunerTest
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** A storage that lists objects without their modification times (a listing
|
||||
** through the object-storage qbit did, for every real bucket) used to make the
|
||||
** pruner throw as soon as a plan had one unfinished backup, so that plan was
|
||||
** never pruned again. The run's own record dates the debris: it is deleted when
|
||||
** the run ended more than 7 days ago, kept before, and a prefix with no times
|
||||
** and no run record is never deleted as old.
|
||||
*******************************************************************************/
|
||||
@Test
|
||||
void testDebrisIsDatedByItsRunWhenTheStorageListsNoTimes() throws Exception
|
||||
{
|
||||
QRecord plan = plan(7, Map.of());
|
||||
BackupsTestUtils.BACKUPS.withFailWritesFor(key -> key.contains("/tables/blogPost/"));
|
||||
BackupRunResult failed = new BackupRunCoordinator().runPlan(plan, "SCHEDULED");
|
||||
BackupsTestUtils.BACKUPS.withFailWritesFor(null);
|
||||
assertThat(failed.getStatus()).isEqualTo("FAILED");
|
||||
runOnDay(plan, 6);
|
||||
|
||||
com.kingsrook.qbits.backups.storage.BackupStorage noTimes = (com.kingsrook.qbits.backups.storage.BackupStorage) java.lang.reflect.Proxy.newProxyInstance(
|
||||
getClass().getClassLoader(), new Class<?>[] { com.kingsrook.qbits.backups.storage.BackupStorage.class }, (proxy, method, args) ->
|
||||
{
|
||||
try
|
||||
{
|
||||
Object answer = method.invoke(BackupsTestUtils.BACKUPS, args);
|
||||
if("list".equals(method.getName()))
|
||||
{
|
||||
List<StoredObjectInfo> listed = new java.util.ArrayList<>();
|
||||
for(Object each : (List<?>) answer)
|
||||
{
|
||||
StoredObjectInfo object = (StoredObjectInfo) each;
|
||||
listed.add(new StoredObjectInfo(object.key(), object.size(), null, object.metadata(), object.lockedUntil()));
|
||||
}
|
||||
return (listed);
|
||||
}
|
||||
return (answer);
|
||||
}
|
||||
catch(java.lang.reflect.InvocationTargetException e)
|
||||
{
|
||||
throw (e.getCause());
|
||||
}
|
||||
});
|
||||
BackupsRuntime.getConfig().withStorageResolver(alias -> "backups".equals(alias) ? noTimes : BackupsTestUtils.MEDIA);
|
||||
|
||||
clock.set(DAY_1.plus(Duration.ofDays(6)));
|
||||
assertThat(new BackupPruner().plan(plan).debris()).as("6 days after the run ended it is not debris yet").isEmpty();
|
||||
|
||||
clock.set(DAY_1.plus(Duration.ofDays(8)));
|
||||
BackupPruner.Outcome outcome = new BackupPruner().prune(plan, "tester");
|
||||
assertThat(outcome.debrisPrefixesDeleted()).isEqualTo(1);
|
||||
assertThat(BackupsTestUtils.BACKUPS.list(failed.getRunPrefix())).isEmpty();
|
||||
|
||||
Instant now = DAY_1.plus(Duration.ofDays(30));
|
||||
assertThat(BackupPruner.newestOf(List.of(new StoredObjectInfo("orphan/part", 1, null, Map.of(), null)), null, now)).as("no times and no run record: not old").isEqualTo(now);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** The prefix of a run that never got a manifest is debris once its newest object
|
||||
** is older than 7 days, and not before.
|
||||
|
||||
-2
@@ -142,8 +142,6 @@ class ObjectStorageBackupStorageMinioTest
|
||||
|
||||
storage.copy("contract/big.bin", "contract/copy.bin");
|
||||
assertThat(storage.list("contract/")).extracting(StoredObjectInfo::key).containsExactly("contract/big.bin", "contract/copy.bin");
|
||||
assertThat(storage.list("contract/")).as("a listing says when each object was written: the pruner dates unfinished backups by it")
|
||||
.allSatisfy(object -> assertThat(object.lastModified()).isNotNull());
|
||||
assertThat(storage.presignGet("contract/copy.bin", Duration.ofMinutes(15), "x.bin")).startsWith("http");
|
||||
assertThat(storage.deletePermanent("contract/copy.bin")).isEqualTo(BackupStorage.DeleteResult.DELETED);
|
||||
assertThat(storage.deletePermanent("contract/copy.bin")).isEqualTo(BackupStorage.DeleteResult.NOT_FOUND);
|
||||
|
||||
Reference in new issue
Block a user