You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@helix.apache.org by GitBox <gi...@apache.org> on 2021/05/18 01:22:24 UTC
[GitHub] [helix] jiajunwang commented on a change in pull request #1723: Remove task requested state
jiajunwang commented on a change in pull request #1723:
URL: https://github.com/apache/helix/pull/1723#discussion_r633965682
##########
File path: helix-core/src/main/java/org/apache/helix/messaging/handling/HelixStateTransitionHandler.java
##########
@@ -138,42 +136,6 @@ void preHandleMessage() throws Exception {
throw err.exception;
}
- // Reset the REQUESTED_STATE property if it exists.
- try {
- String instance = _manager.getInstanceName();
- String sessionId = _message.getTgtSessionId();
- String resource = _message.getResourceName();
- ZNRecordBucketizer bucketizer = new ZNRecordBucketizer(_message.getBucketSize());
- PropertyKey key = _isTaskMessage && !_isTaskCurrentStatePathDisabled ? accessor.keyBuilder()
- .taskCurrentState(instance, sessionId, resource, bucketizer.getBucketName(partitionName))
- : accessor.keyBuilder()
- .currentState(instance, sessionId, resource, bucketizer.getBucketName(partitionName));
- ZNRecord rec = new ZNRecord(resource);
- Map<String, String> map = new TreeMap<String, String>();
- map.put(CurrentState.CurrentStateProperty.REQUESTED_STATE.name(), null);
- rec.getMapFields().put(partitionName, map);
- ZNRecordDelta delta = new ZNRecordDelta(rec, ZNRecordDelta.MergeOperation.SUBTRACT);
- List<ZNRecordDelta> deltaList = new ArrayList<ZNRecordDelta>();
- deltaList.add(delta);
- CurrentState currStateUpdate = new CurrentState(resource);
- currStateUpdate.setDeltaList(deltaList);
-
- // Update the ZK current state of the node
- if (!accessor.updateProperty(key, currStateUpdate)) {
- logger.error("Fails to persist current state back to ZK for resource " + resource
- + " partition: " + partitionName);
- }
- } catch (Exception e) {
- logger.error("Error when removing " + CurrentState.CurrentStateProperty.REQUESTED_STATE.name()
- + " from current state.", e);
- StateTransitionError error =
- new StateTransitionError(ErrorType.FRAMEWORK, ErrorCode.ERROR, e);
- _stateModel.rollbackOnError(_message, _notificationContext, error);
- _statusUpdateUtil.logError(
- _message, HelixStateTransitionHandler.class, e, "Error when removing "
- + CurrentState.CurrentStateProperty.REQUESTED_STATE.name() + " from current state.",
- _manager);
- }
}
void postHandleMessage() {
Review comment:
The changes in this PR make sense. However, it introduces even more special cases in addition to the already complicated code. For example,
1. Drop ST is handled differently from the other ST message. If from-state mismatch, we don't touch the state model. But as long as it is a drop message, then we can delete it.
2. If ST fails, no matter if the states match or not, the ERROR state will be updated.
I suggest refactoring postHandleMessage to clean up (or group) the special cases so it remains readable. I wish the logic could be,
1. Basic read.
2. Check corner cases, special handling.
3. Normal case processing.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org