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

Remove lost partitions from assigned streams #1350

Merged
merged 9 commits into from
Oct 29, 2024
Merged
Changes from 6 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 @@ -236,7 +236,7 @@ private[consumer] final class Runloop private (
state <- currentStateRef.get
lostStreams = state.assignedStreams.filter(control => lostTps.contains(control.tp))
_ <- ZIO.foreachDiscard(lostStreams)(_.lost)
_ <- lastRebalanceEvent.set(rebalanceEvent.onLost(lostTps))
_ <- lastRebalanceEvent.set(rebalanceEvent.onLost(lostTps, lostStreams))
_ <- ZIO.logTrace(s"onLost done")
} yield ()
)
Expand Down Expand Up @@ -560,6 +560,17 @@ private[consumer] final class Runloop private (
ended = endedStreams.map(_.tp).toSet
)
)
// Ensure that all assigned partitions have a stream and no streams are present for unassigned streams
_ <-
ZIO
.logWarning(
s"Not all assigned partitions have a (single) stream or vice versa. Assigned: ${currentAssigned.mkString(",")}, streams: ${updatedAssignedStreams.map(_.tp).mkString(",")}"
)
.when(
currentAssigned != updatedAssignedStreams
.map(_.tp)
.toSet || currentAssigned.size != updatedAssignedStreams.size
svroonland marked this conversation as resolved.
Show resolved Hide resolved
)
} yield Runloop.PollResult(
records = polledRecords,
ignoreRecordsForTps = ignoreRecordsForTps,
Expand Down Expand Up @@ -830,11 +841,12 @@ object Runloop {
endedStreams = this.endedStreams ++ endedStreams
)

def onLost(lost: Set[TopicPartition]): RebalanceEvent =
def onLost(lost: Set[TopicPartition], endedStreams: Chunk[PartitionStreamControl]): RebalanceEvent =
copy(
wasInvoked = true,
assignedTps = assignedTps -- lost,
lostTps = lostTps ++ lost
lostTps = lostTps ++ lost,
endedStreams = this.endedStreams ++ endedStreams
)
}

Expand Down
Loading