Commit 6e88aec
(PDB-5351) Fix reports table partition gc bug
This commit fixes a bug that causes reports to get garbage collected
even though they were created within the 'reports-ttl' timeframe. This
was due to a comparision of these two datetime values:
- the 'reports-ttl' derived "cut-off" datetime: exactly 'reports-ttl'
ago.
- the table partition's datetime: the very beginning of the day in which
the reports within were created.
In puppetlabs.puppetdb.scf.storage/prune-daily-partitions, a table
partition is deemed expired if the latter datetime is *before* the
former. When GC'ing at 00:05 with a 'reports-ttl' of '1d', the partition
with all of yesterday's reports is deemed expired. The user is left with
reports from only the last 5 minutes.
This fix does a "floor" operation on the cutoff datetime generated from
the 'reports-ttl' value before comparing it to the partition's date.
This means that the "cut-off" datetime is rolled back to 0:00 of its
selected day. This way, in order for a partition to get purged, the
"cut-off" datetime has to be on a day before the partition's datetime.
This approach is already how we handle the 'resource-events-ttl' so this
fix meshes nicely with what's already in place.
The puppetlabs.puppetdb.integration.reports/reports-ttl integration test
is being removed because it is difficult to refactor into a useful test.
It was written before the reports table was partitioned by date and does
not take account how garbage collection currently works (dropping whole
expired table partitions). This test was difficult to modify because the
puppet agent service cannot easily create reports from the past. The
puppetlabs.puppetdb.cli.services-test/correctly-sweep-reports test is
sufficient to verify reports-ttl gc related functionality.1 parent e25e25e commit 6e88aec
File tree
3 files changed
+32
-33
lines changed- src/puppetlabs/puppetdb/cli
- test/puppetlabs/puppetdb
- cli
- integration
3 files changed
+32
-33
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
214 | 214 | | |
215 | 215 | | |
216 | 216 | | |
| 217 | + | |
217 | 218 | | |
218 | | - | |
| 219 | + | |
219 | 220 | | |
220 | 221 | | |
221 | 222 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
573 | 573 | | |
574 | 574 | | |
575 | 575 | | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
260 | 260 | | |
261 | 261 | | |
262 | 262 | | |
263 | | - | |
264 | | - | |
265 | | - | |
266 | | - | |
267 | | - | |
268 | | - | |
269 | | - | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
293 | | - | |
294 | | - | |
0 commit comments