Skip to content

Period load rules should include the future by default #5869

Closed

Description

@gianm

We have seen problem scenarios like the following:

  1. A user has load rules like: load 30 days, drop forever.
  2. The user loads some data from slightly in the future (maybe some clocks are running a bit fast or slow) using streaming ingestion. This creates a segment with an interval that is in the future.
  3. The coordinator disables the segment immediately upon noticing it (since it is not within the last 30 days).
  4. The Kafka tasks time out during handoff (because the segments are never loaded).
  5. And after that timeout, the data that was slightly in the future is still not available!

It would be better, I think, if period-based load rules included an unbounded time into the future too. I bet this lines up better with users' intuitive idea of what "retain 30 days" means. Of course it could be changeable with some optional parameters (or a different kind of rule?) but I think the default behavior should be the intuitive one.

NB: A workaround to this is to use rules like "load 30 days" followed by "drop 1000 years" followed by "load forever". That has the same effect as what I am suggesting for the new default behavior: we'll drop anything older than 30 days, but retain the last 30 days and also anything that is in the future.

Related, but different: #5868.

Activity

  1. gianm commented on Jul 1, 2018

    @gianm
    ContributorAuthor

    Even though this isn't directly related to Kafka indexing, I gave it a Kafka tag since that's the kind of indexing most likely to be affected.

  2. teeram commented on Jul 4, 2018

    @teeram

    Nice idea @gianm. Just wanted to mention that perhaps the lateMessageRejectionPeriod and earlyMessageRejectionPeriod found in the KafkaSupervisorIOConfig could go away in favor of new load rules. Up to you guys of course, I just thought it might end up being a little confusing to have these configurable supervisor fields separate from load rules.

  3. gianm commented on Jul 5, 2018

    @gianm
    ContributorAuthor

    Hmm, I think there is still a use case for lateMessageRejectionPeriod / earlyMessageRejectionPeriod even if load / drop rule usage becomes more intelligent. Imagine having a 90 day load rule, but only wanting to load stream data if it's received within 24 hours. It could be useful if you need to do batch reprocessing on older data and don't want to worry about locks.

  4. teeram commented on Jul 6, 2018

    @teeram

    Ah true, that's a good point.

  5. added this to the 0.13.0 milestone on Aug 9, 2018
  6. QiuMM commented on Sep 27, 2018

    @QiuMM
    Member

    @gianm maybe add a new drop rule which will drop data older than a configured date, then if people we want to retain the last 30 days data, they can do like this: drop 30 days ago, load forever.

  7. jihoonson commented on Sep 28, 2018

    @jihoonson
    Contributor

    @QiuMM would you elaborate more on your idea? I'm not sure how's it different from the PeriodDropRule. Also, how does it fix this issue?

  8. jihoonson commented on Sep 28, 2018

    @jihoonson
    Contributor

    Is anyone working on this? If not, I think we can move this to 0.13.1.

  9. QiuMM commented on Sep 28, 2018

    @QiuMM
    Member

    @jihoonson currently, we can edit a PeriodDropRule like this:

    {
      "type" : "dropByPeriod",
      "period" : "P1D"
    }

    The period is from some time in the past to the current time, so this example will drop last one day data. I think PeriodDropRule is a impractical rule for it will always drop recent data. So people who want to retain the last 30 days data, they can not use this PeriodDropRule but have to do like this: load 30 days, drop forever. Then because of drop forever cause issues that @gianm have listed above.

    Maybe we can remove the PeriodDropRule because I think few people would like to use it. Then add a new drop rule which will drop data older than a configured date. I also want a rule like this.

  10. jihoonson commented on Sep 28, 2018

    @jihoonson
    Contributor

    @QiuMM thank you for the explanation. Now I get it.

    But, I'm afraid that it can introduce another issue. The purpose of load/drop rule is to control data retention which means how many data historicals should store locally. And as @gianm said, this problem mostly happens in stream ingestion which data size grows as time goes by. If dropRule works based on a fixed date, people might update the date for the dropRule periodically.

  11. QiuMM commented on Sep 29, 2018

    @QiuMM
    Member

    @jihoonson I'm not sure why you think people need to update the date? If I just want to keep last 1 day data, then set the drop rule like this: drop 1 day ago and no need to change it as time goes by, 1 day ago data will always be dropped. Besides, 1 day ago for current hour is different from 1 day ago for next hour, the coordinator should realize this and operate automatically just like the current approach for LoadPeriodRule.

  12. jihoonson commented on Sep 29, 2018

    @jihoonson
    Contributor

    Ah, now I really get it. I thought you want to set a specific date for dropRule. Your idea makes sense to me. Probably it's easier to use than the combination of the current loadRule and dropRule.

  13. QiuMM commented on Sep 29, 2018

    @QiuMM
    Member

    @jihoonson yes, that right. And by adding such drop rule, I think we don't have to change the current LoadPeriodRule. I can help to add such drop rule for I also want it.

  14. jihoonson commented on Sep 29, 2018

    @jihoonson
    Contributor

    @QiuMM thanks! I think it makes more sense to add new rules like LoadSince or DropBefore rather than modifying existing rules. They would be more intuitive and easier to use than combining loadRules and dropRules to get the same effect. But I don't know what was the rationale for the current design of the load/drop rules. @gianm any idea?

  15. QiuMM commented on Sep 29, 2018

    @QiuMM
    Member

    In conclusion, I think current design of the load/drop rules is flexible and able to deal with almost all scenarios. But current PeriodDropRule is a impractical rule for it will always drop recent data. Then if people want to retain 30 days data, they can not use such PeriodDropRule but have to do like: load 30 days, drop forever. And because people have used the drop forever rule which would drop segments in the future, then below things occured:

    1. The user loads some data from slightly in the future (maybe some clocks are running a bit fast or slow) using streaming ingestion. This creates a segment with an interval that is in the future.
    2. The coordinator disables the segment immediately upon noticing it (since it is not within the last 30 days).
    3. The Kafka tasks time out during handoff (because the segments are never loaded).
    4. And after that timeout, the data that was slightly in the future is still not available!

    Then I think there are two ways to solve these things:

    1. Period load rules include the future by default
    2. Add a new drop rule or modify current PeriodDropRule to support drop before a period, then if people want to retain 30 days data, they can do like this: drop 30 days before, load forever.

    I prefer the second way and want to modify current PeriodDropRule not add a new one because the current one is very impractical, IMO no people would like to use such drop rule.

  16. jihoonson commented on Sep 29, 2018

    @jihoonson
    Contributor

    I think current design of the load/drop rules is flexible and able to deal with almost all scenarios.

    Yeah, I think it was the rationale of the current design, but it doesn't explain why PeriodLoadRule doesn't consider future data or PeriodDropRule is designed in such a way. For PeriodLoadRule, I think we didn't consider future data at that time. For PeriodDropRule, I have no idea.

    I prefer the second way and want to modify current PeriodDropRule not add a new one because the current one is very impractical, IMO no people would like to use such drop rule.

    I would say it's better to add a new rule because it's much easier. Modifying an existing rule in an incompatible way would take a long time, because we need to discuss about it and check its use cases as many as possible. Please note that modifying PeriodLoadRule to include future data is compatible with the current behavior. If PeriodDropRule is really not useful, we can deprecate and remove it in the future.

    But, I know there is a production use case that PeriodDropRule might be useful. They are ingesting data from a single Kafka stream into two different Druid dataSources. One stores the recent data of, let's say last month while another stores old data. In such cases, they can use PeriodDropRule for the old dataSource to drop last month data to avoid the potential duplicate data issue.

    So, I would say adding new rules is more welcomed and having the current PeriodDropRule would be fine if there's no real problem. What do you think?

  17. QiuMM commented on Sep 30, 2018

    @QiuMM
    Member

    It's fine for me to keep current PeriodDropRule. I'll open a PR to add such drop rule in a few days.

  18. jihoonson commented on Sep 30, 2018

    @jihoonson
    Contributor

    @QiuMM thanks!

  19. modified the milestones: 0.13.0, 0.13.1 on Oct 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions