Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A lost partition is no longer fatal #1252

Merged
merged 7 commits into from
Jul 9, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,6 @@ final class PartitionStreamControl private (
private[internal] def maxPollIntervalExceeded(now: NanoTime): UIO[Boolean] =
queueInfoRef.get.map(_.deadlineExceeded(now))

/** To be invoked when the partition was lost. */
private[internal] def lost: UIO[Boolean] = {
val lostException = new RuntimeException(s"Partition ${tp.toString} was lost") with NoStackTrace
interruptionPromise.fail(lostException)
}

/** To be invoked when the stream is no longer processing. */
private[internal] def halt: UIO[Boolean] = {
val timeOutMessage = s"No records were polled for more than $maxPollInterval for topic partition $tp. " +
Expand All @@ -97,6 +91,14 @@ final class PartitionStreamControl private (
interruptionPromise.fail(consumeTimeout)
}

/** To be invoked when the partition was lost. It clears the queue and ends the stream. */
private[internal] def lost: UIO[Unit] =
logAnnotate {
ZIO.logDebug(s"Partition ${tp.toString} lost") *>
erikvanoosten marked this conversation as resolved.
Show resolved Hide resolved
dataQueue.takeAll *>
dataQueue.offer(Take.end).unit
}

/** To be invoked when the partition was revoked or otherwise needs to be ended. */
private[internal] def end: ZIO[Any, Nothing, Unit] =
logAnnotate {
Expand Down
Loading