Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-17937

Clarify Kafka offset semantics for Structured Streaming

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Critical
    • Resolution: Incomplete
    • None
    • None
    • Structured Streaming

    Description

      Possible events for which offsets are needed:

      1. New partition is discovered
      2. Offset out of range (aka, data has been lost). It's possible to separate this into offset too small and offset too large, but I'm not sure it matters for us.

      Possible sources of offsets:

      1. Earliest position in log
      2. Latest position in log
      3. Fail and kill the query
      4. Checkpoint position
      5. User specified per topicpartition
      6. Kafka commit log. Currently unsupported. This means users who want to migrate from existing kafka jobs need to jump through hoops. Even if we never want to support it, as soon as we take on SPARK-17815 we need to make sure Kafka commit log state is clearly documented and handled.
      7. Timestamp. Currently unsupported. This could be supported with old, inaccurate Kafka time api, or upcoming time index
      8. X offsets before or after latest / earliest position. Currently unsupported. I think the semantics of this are super unclear by comparison with timestamp, given that Kafka doesn't have a single range of offsets.

      Currently allowed pre-query configuration, all "ORs" are exclusive:

      1. startingOffsets: earliest OR latest OR User specified json per topicpartition (SPARK-17812)
      2. failOnDataLoss: true (which implies Fail above) OR false (which implies Earliest above) In general, I see no reason this couldn't specify Latest as an option.

      Possible lifecycle times in which an offset-related event may happen:

      1. At initial query start
        • New partition: if startingOffsets is Earliest or Latest, use that. If startingOffsets is User specified perTopicpartition, and the new partition isn't in the map, Fail. Note that this is effectively undistinguishable from new parititon during query, because partitions may have changed in between pre-query configuration and query start, but we treat it differently, and users in this case are SOL
        • Offset out of range on driver: We don't technically have behavior for this case yet. Could use the value of failOnDataLoss, but it's possible people may want to know at startup that something was wrong, even if they're ok with earliest for a during-query out of range
        • Offset out of range on executor: seems like it should be Fail or Earliest, based on failOnDataLoss. but it looks like this setting is currently ignored, and the executor will just fail...
      2. During query
        • New partition: Earliest, only. This seems to be by fiat, I see no reason this can't be configurable.
        • Offset out of range on driver: this probably doesn't happen, because we're doing explicit seeks to the latest position
        • Offset out of range on executor: ?
      3. At query restart
        • New partition: Checkpoint, fall back to Earliest. Again, no reason this couldn't be configurable fall back to Latest
        • Offset out of range on driver: this probably doesn't happen, because we're doing explicit seeks to the specified position
        • Offset out of range on executor: ?

      I've probably missed something, chime in.

      Attachments

        Activity

          People

            Unassigned Unassigned
            koeninger Cody Koeninger
            Votes:
            3 Vote for this issue
            Watchers:
            11 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: