-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[improve][broker] PIP-192 Added Deleted and Init states in ServiceUnitState #19546
[improve][broker] PIP-192 Added Deleted and Init states in ServiceUnitState #19546
Conversation
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we add waitForReconnection
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When seek()
resets the cursor, this reader will be temporarily disconnected.
Then, when calling acknowledgeCumulativeAsync()
at the end of the compaction(below code), the reader might throw an exception because state == Connecting. This issue could likely happen if there is only one message to compact.
.thenCompose(v -> {
log.info("Acking ledger id {}", phaseOneResult.firstId);
return ((CompactionReaderImpl<T>) reader)
.acknowledgeCumulativeAsync(
phaseOneResult.lastId, Map.of(COMPACTED_TOPIC_LEDGER_PROPERTY,
ledger.getId()));
})
3f7c850
to
c485357
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! Left some comments.
.../src/main/java/org/apache/pulsar/broker/loadbalance/extensions/channel/ServiceUnitState.java
Outdated
Show resolved
Hide resolved
...ava/org/apache/pulsar/broker/loadbalance/extensions/channel/ServiceUnitStateChannelImpl.java
Outdated
Show resolved
Hide resolved
...ava/org/apache/pulsar/broker/loadbalance/extensions/channel/ServiceUnitStateChannelImpl.java
Show resolved
Hide resolved
...ava/org/apache/pulsar/broker/loadbalance/extensions/channel/ServiceUnitStateChannelImpl.java
Show resolved
Hide resolved
.../src/main/java/org/apache/pulsar/broker/loadbalance/extensions/channel/ServiceUnitState.java
Outdated
Show resolved
Hide resolved
.../src/main/java/org/apache/pulsar/broker/loadbalance/extensions/channel/ServiceUnitState.java
Outdated
Show resolved
Hide resolved
...ava/org/apache/pulsar/broker/loadbalance/extensions/channel/ServiceUnitStateChannelImpl.java
Outdated
Show resolved
Hide resolved
...ava/org/apache/pulsar/broker/loadbalance/extensions/channel/ServiceUnitStateChannelImpl.java
Show resolved
Hide resolved
...ava/org/apache/pulsar/broker/loadbalance/extensions/channel/ServiceUnitStateChannelImpl.java
Outdated
Show resolved
Hide resolved
...ava/org/apache/pulsar/broker/loadbalance/extensions/channel/ServiceUnitStateChannelImpl.java
Show resolved
Hide resolved
...ava/org/apache/pulsar/broker/loadbalance/extensions/channel/ServiceUnitStateChannelImpl.java
Outdated
Show resolved
Hide resolved
...ava/org/apache/pulsar/broker/loadbalance/extensions/channel/ServiceUnitStateChannelImpl.java
Show resolved
Hide resolved
7d4eac5
to
e2290b3
Compare
993b8c6
to
2fbafc9
Compare
...ava/org/apache/pulsar/broker/loadbalance/extensions/channel/ServiceUnitStateChannelImpl.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
...ava/org/apache/pulsar/broker/loadbalance/extensions/channel/ServiceUnitStateChannelImpl.java
Outdated
Show resolved
Hide resolved
pulsar-broker/src/test/java/org/apache/pulsar/compaction/ServiceUnitStateCompactionTest.java
Outdated
Show resolved
Hide resolved
.../src/main/java/org/apache/pulsar/broker/loadbalance/extensions/channel/ServiceUnitState.java
Outdated
Show resolved
Hide resolved
5feff8a
to
77209e7
Compare
77209e7
to
0689771
Compare
Master Issue: #16691
Motivation
There is a possible edge case where bundle ownership could be in an invalid state in the new load balancer.
Let's say strategic compaction happened in the middle of the bundle transfer.
Owned->Transfer_Assigned // compaction happened.
After the compaction, when a tableview joins and builds its cache from the compacted topic, it will first see a transition,
null -> Transfer_Assigned
. However, because this is invalid, the tableview will skip this msg, causing an inconsistent view.To avoid this issue, this transition(
null -> Transfer_Assigned
) has been changed to a valid transition in the state diagram, but I realized that this could bring another wrong state when transfer and split occur concurrently.Racing condition
leader : Owned -> Transfer_Assigned -> Released -> Owned
Broker-2 : Owned -> Splitting -> null(parent-bundle)
Wrong state: a parent bundle is owned by another broker after the split.
Owned -> Splitting -> null -> Transfer_Assigned -> Released -> Owned
To break this invalid transition, we need semi-terminal states(
Deleted
, andFree
) andInit
state to better represent tombstoned bundles.Owned -> Splitting -> Deleted -> Transfer_Assigned // invalid
Owned -> Released -> Free -> Transfer_Assigned // invalid
Modifications
This PR
Deleted
andInit
States inServiceUnitState
.Owned- > Released
transition to make theUnload
command a two-phase protocol.monitorOwnerships()
on the leader broker's ServiceUnitStateChannel, which overrides states toOwned
orInit
for service units(bundles)Future Work / Discussion
Also, we may need to think about pre-creating all bundles in
Owned
state whenever a new namespace is created.If all bundles are pre-created and do exist in the service units state channel, tombstone can only happen on parent bundles after split(
Deleted state
).Also, with the bundle pre-creations and the transfer command, there will be no need for the assign command,(which could cause thundering herds impact when many brokers concurrently issue bundle ownership). This will simplify the state transitions by removing the 'Free' state and 'Free -> Assigned' transition.
However, this pre-creation requires some additional memory space from keeping bundles in Owned state(some might not be used at all).
Verifying this change
This change added tests and can be verified as follows:
Does this pull request potentially affect one of the following parts:
If the box was checked, please highlight the changes
Documentation
doc
doc-required
doc-not-needed
doc-complete
We will have separate PRs to update the Doc later.
Matching PR in forked repository
PR in forked repository: heesung-sn#32