Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

StreamStatus is currently defined as follows:

...

A

...

Stream

...

Status

...

element

...

informs

...

stream

...

tasks

...

whether

...

or

...

not

...

they

...

should

...

continue

...

to

...

expect

...

records

...

and

...

watermarks

...

from

...

the

...

input

...

stream

...

that

...

sent

...

them.

...

There

...

are

...

2

...

kinds

...

of

...

status,

...

namely

...

IDLE

...

and

...

ACTIVE.

...

Stream

...

Status

...

elements

...

are

...

generated

...

at

...

the

...

sources,

...

and

...

may

...

be

...

propagated

...

through

...

the

...

tasks

...

of

...

the

...

topology.

...

They

...

directly

...

infer

...

the

...

current

...

status

...

of

...

the

...

emitting

...

task;

...

a

...

SourceStreamTask

...

or

...

StreamTask

...

emits

...

a

...

IDLE

...

if

...

it

...

will

...

temporarily

...

halt

...

to

...

emit

...

any

...

records

...

or

...

watermarks

...

(i.e.

...

is

...

idle),

...

and

...

emits

...

a

...

ACTIVE

...

once

...

it

...

resumes

...

to

...

do

...

so

...

(i.e.

...

is

...

active).

...

However that definition is quite problematic. Operators with delayed responses, such as AsyncIO, windows, or time-based process functions, might output elements when they are actually IDLEidle. So by that definition, they would need to switch from IDLE from idle to ACTIVEactive, emit an element, and go back to IDLEidle. It's not entirely clear when they would go back to IDLE to idle (after each element or after some time?). Furthermore, under heavy backpressure, these additional StreamRecord s additional StreamStatuses delay progress quite a bit.

At this point, it makes sense to revise the original intent of StreamStatus: being able to advance the watermark without data. Indeed, there is no reason to expand the definition towards records; we could simply limit the definition to watermarks as this is the only use case for StreamStatus in the code base currently. Moreover, that's exactly how it's implemented in Flink so far. So, in this FLIP we propose to adjust the definition to reality and act on that.

Idleness

Related A related questions is: What exactly is idleness? And how does a source instance become idle?

Idleness is a means to make progress when a source reader temporarily does not emit watermarks because it has no data. We can distinguish three cases if we just look where no data can be emitted at the source:

1. Static assignment + too few splits

The source uses a static assignment of splits to readers and there are more readers than sources.

In this case, readers will be closed and emit MAX_WATERMARK to unblock watermark propagation indefinitely. At this point, idleness is not needed.

2. Static assignment + temporary no data

The source uses a static assignment of splits to readers, every reader obtains at least one split, but some readers have no records in their splits temporarily (e.g. a Kafka partition became stale).

In this case, a user can use WatermarkStrategy#withIdleness to let the watermark advance after a specific amount of time. However, when a partition becomes active again, there is a risk of marking records as late that wouldn't have been late without idleness.

Here, it's important that a user is aware of the realistic potential for late records and can adjust the job accordingly to work with retractions. As part of this FLIP, we should improve the documentation of withIdleness to give the user all necessary tools to deal with late records.

3. Dynamic assignment + temporary no split

The last case is that a source uses dynamic assignment and a reader temporarily does not a have a split assigned.

In this case, a reader cannot be closed and thus holds back the watermark. Unfortunately, idleness on reader level would introduce systematic errors as in the previous case

...

. However, in contrast to the previous case, the user may not be aware of such imprecision.

HenceHence, for the 3. case, Flink needs a mechanism to sync the watermarks between source readers and source coordinator, such that no data may be potentially lost. For example, in systems that support watermarks natively, the coordinator extracts that global watermark and forwards it to the readers. Another example would be a file source that reads from time-bucketed folders where the coordinator can infer a global minimum watermark from the folder structure. This mechanism will be covered in a separate, later FLIP and is beyond the scope of this FLIP. Note that a user can still add idleness on top of the global minimum watermark to speed up processing.

Nevertheless, it should be clear that we should tweak the public interfaces to make it clear that idleness should only come from a user as it's a heuristic approach. This FLIP will address the change.

Public Interfaces

Briefly list any new interfaces that will be introduced as part of this proposal or any existing interfaces that will be removed or changed. The purpose of this section is to concisely call out the public contract that will come along with this feature.

A public interface is any change to the following:

  • Binary log format

  • The network protocol and api behavior

  • Any class in the public packages under clientsConfiguration, especially client configuration

    • org/apache/kafka/common/serialization

    • org/apache/kafka/common

    • org/apache/kafka/common/errors

    • org/apache/kafka/clients/producer

    • org/apache/kafka/clients/consumer (eventually, once stable)

  • Monitoring

  • Command line tools and arguments

  • Anything else that will likely break existing users in some way when they upgrade

Proposed Changes

Implications

With this FLIP, we need to adjust the APIs around idleness, such that it's clear that only users should be able to make a source instance go idle. We need to emphasize the potential of late records and subsequent data loss if no counter-measures are taken.

Public Interfaces

  • WatermarkOutput
  • Output
  • Input

Proposed Changes

The biggest change includes StreamStatus albeit it's an internal class. We propose to adjust the definition (JavaDoc) to exclude records and rename the class to WatermarkStatus and move it to the watermarkstatus package. Finally, we need to rename emitStreamStatus and processStreamStatus in a few public evolving interfaces (Input, Output). Here, we can add deprecated shortcuts to the top-level interfaces with the old name.

We should also update the definition of StreamStatus#IDLE to make sure that this a) may introduce late records and b) should be user-controlled.

Since sources may offer users the ability to go IDLE beyond the WatermarkStrategy#withIdleness, we propose to also add WatermarkOutput#markActive to quickly go active again without the need to explicitly emit a watermark first. In fact, we would change the contract of WatermarkOutput#emitWatermark to not automatically go active: going back and forth should always be a cautious decision in the implementationsDescribe the new thing you want to do in appropriate detail. This may be fairly extensive and have large subsections of its own. Or it may be a few sentences. Use judgement based on the scope of the change.

Compatibility, Deprecation, and Migration Plan

  • What impact (if any) will there be on existing users?
  • If we are changing behavior how will we phase out the older behavior?
  • If we need special migration tools, describe them here.
  • When will we remove the existing behavior?

Test Plan

Describe in few sentences how the FLIP will be tested. We are mostly interested in system tests (since unit-tests are specific to implementation details). How will we know that the implementation works as expected? How will we know nothing broke?

Rejected Alternatives

  • This change will break existing FLIP-27 sources that rely on the implicit WatermarkOutput#markActive behavior.
  • User code using Input and Output would work without recompilation. Compiling would yield deprecation warnings.

Test Plan

The change of StreamStatus  reflects the current implementation and is thus already covered by tests. We might need to add additional unit/integration tests if we discover paths where we automatically switch to IDLE (a recent change on 1.14-SNAPSHOT does it).

Changes to WatermarkOutput require a few additional unit tests. It's already covered in integration tests.

Rejected Alternatives

None yetIf there are alternative ways of accomplishing the same thing, what were they? The purpose of this section is to motivate why the design is the way it is and not some other way.