Hi. I understand from the documentation that the s...
# general
k
Hi. I understand from the documentation that the storage capacity used by historical nodes is linked to the number of segments they retrieve from deep storage, which can be managed using load rules such as loadByPeriod. I would like to know if applying the loadByPeriod rule leads to the removal of older segments (those outside the specified period) from the historical nodes, thereby freeing up space on these nodes. I did change the load rule to just load P1M segments, but I didn’t see any changes in disk usage, and I guess that its effect will be seen after the given period, and those segments that had been loaded by the default load rule would remain on the historical cache path. If my observation is correct, is there any method for freeing up space on historical storage?
a
Your understanding seems right. The retention rules are evaluated sequentially in order and that includes the cluster default rules too. Are there segments older than a month for that datasource that you’d like to drop? Also, if you have the default
loadForever
cluster rule in addition to
loadByPeriod(P1M)
, that will essentially act as a catch-all and load everything. You could either drop the cluster default rule, or if you don’t care about tiering, you could use
dropBeforeByPeriod(P1M)
+ cluster default
loadForever
.
k
Our
segmentGranularity
is
DAY
, and we have segments from 2023-12-25 up to now (2024-05-02), and all of them are cached on Historicals too. I made some changes. First, I tried to remove the default
loadForever
rule, but Druid showed me an error saying that cluster-level rules cannot be empty. Then I changed the cluster default rule to the
loadByPeriod(P1M)
to somehow remove the
loadForever
impact, waited about 2 hours, and also restarted the Historicals, but I didn’t see any changes in the number of cached segments. I’m not allowed to apply any drop rules right now, that’s why I’m looking for a solution to just reduce the number of cached segments on Historicals.
a
Got it. I think the rules system expects at least one rule to be valid for any given segment. Looking into the code
RunRules
, it seems that if there are no rules evaluated, you’d expect to see alerts for segments that have no rules associated, but we don’t mark those segments as unused, so they will still be loaded by the data servers. That’s likely what you’re seeing here. Basically if you have a cluster default rule of
loadByPeriod(P1M)
, and say you have 10 segments spanning a month each, for e.g.,:`[T-P10M, T-P9M),...,[T-P2M, T-P1M), [T-P1M, T)`, then only the most recent month segment
[T-P1M, T)
should be loaded. You’d see alerts for the remaining 9 month-granularity segments, but still loaded by the historicals as Druid doesn’t take any action on these segments.
I’m not sure if the behavior above re loading segments that don’t have a valid rule is intentional, or it might be a subtle bug. I will think about it more. However, I think it’s quite common to have catch-all rules like
loadForever
and
dropForever
as the default cluster rule and have datasource-specific retention rules that are like a combination of
loadByPeriod(), dropBeforeByPeriod()
, etc. In your case, it seems that adding a datasource-specific rule
dropBeforeByPeriod(P1M)
while keeping the cluster default
loadForever
should achieve the 1 month cache period for that datasource.
k
Thanks a lot 🙏, I’ll consider your answers in the final solution.
👍 1