[ 
https://issues.apache.org/jira/browse/SCB-802?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16574914#comment-16574914
 ] 

ASF GitHub Bot commented on SCB-802:
------------------------------------

liubao68 commented on a change in pull request #857: [SCB-802]in rollback 
scenario, old versions meta is used and invocation is fail
URL: 
https://github.com/apache/incubator-servicecomb-java-chassis/pull/857#discussion_r208952522
 
 

 ##########
 File path: 
service-registry/src/main/java/org/apache/servicecomb/serviceregistry/consumer/MicroserviceVersions.java
 ##########
 @@ -191,9 +193,30 @@ private void setInstances(List<MicroserviceInstance> 
pulledInstances, String rev
         microserviceVersionRule.setInstances(instances);
       }
       revision = rev;
+      // Clean up down versions in case of rollback and other interface not 
compatible scenarios. Users should ensure running versions are compatible.
+      pack();
     }
   }
 
+  private void pack() {
+    Set<String> microservices = new HashSet<>(instances.size());
+    instances.forEach(item -> {
+      microservices.add(item.getServiceId());
+    });
+    Set<String> downSet = new HashSet<>(instances.size());
+    versions.keySet().forEach(item -> {
+      if (!microservices.contains(item)) {
+        downSet.add(item);
+      }
+    });
+    downSet.forEach(item -> {
+      MicroserviceVersion version = versions.remove(item);
+      for (MicroserviceVersionRule microserviceVersionRule : 
versionRules.values()) {
+        microserviceVersionRule.deleteMicroserviceVersion(version);
 
 Review comment:
   In order to update latestVersion, we also have to check which versions are 
removed. And I think it is good to remove unused version, because some of them 
may never used again.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> in rollback scenario, old versions meta is used and invocation is fail
> ----------------------------------------------------------------------
>
>                 Key: SCB-802
>                 URL: https://issues.apache.org/jira/browse/SCB-802
>             Project: Apache ServiceComb
>          Issue Type: Bug
>          Components: Java-Chassis
>    Affects Versions: java-chassis-1.0.0
>            Reporter: liubao
>            Assignee: liubao
>            Priority: Major
>
> Given version 1 & verson 2
>  # version 1 have interface a, b, c, and consumer & provider are running 
> good. 
>  # user upgrade to version 2, and mistaking to delete interface b. and 
> consumer run error.
>  # user degrade to version 1. consumer still run error and can not recover. 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to