Project

General

Profile

« Previous | Next » 

Revision 7231

Added by Chris Jones over 12 years ago

In setReplicationStatus() and UpdateReplicationMetadata(), don't allow a status state change from COMPLETED to anything other than INVALIDATED. This prevents the completed status from being overwritten due to race conditions.

View differences:

src/edu/ucsb/nceas/metacat/dataone/CNodeService.java
659 659
          // set the status for the replica
660 660
          if ( replicaEntryIndex != -1 ) {
661 661
              targetReplica = replicas.get(replicaEntryIndex);
662
              
663
              // don't allow status to change from COMPLETED to anything other
664
              // than INVALIDATED: prevents overwrites from race conditions
665
              if ( targetReplica.getReplicationStatus() == ReplicationStatus.COMPLETED &&
666
            	   status != ReplicationStatus.INVALIDATED) {
667
            	  throw new InvalidRequest("4730", "Status state change from " +
668
            			  targetReplica.getReplicationStatus() + " to " +
669
            			  status.toString() + "is prohibited for identifier " +
670
            			  pid.getValue() + " and target node " + 
671
            			  targetReplica.getReplicaMemberNode().getValue());
672
              }
673
              
662 674
              targetReplica.setReplicationStatus(status);
663 675
              logMetacat.debug("Set the replication status for " + 
664 676
                  targetReplica.getReplicaMemberNode().getValue() + " to " +
665
                  targetReplica.getReplicationStatus());
677
                  targetReplica.getReplicationStatus() + " for identifier " +
678
                  pid.getValue());
666 679
              
667 680
          } else {
668 681
              // this is a new entry, create it
......
1537 1550
          // set the status for the replica
1538 1551
          List<Replica> replicas = systemMetadata.getReplicaList();
1539 1552
          NodeReference replicaNode = replica.getReplicaMemberNode();
1553
          ReplicationStatus replicaStatus = replica.getReplicationStatus();
1540 1554
          int index = 0;
1541 1555
          for (Replica listedReplica: replicas) {
1542 1556
              
1543 1557
              // remove the replica that we are replacing
1544 1558
              if ( replicaNode.getValue().equals(listedReplica.getReplicaMemberNode().getValue())) {
1559
                      // don't allow status to change from COMPLETED to anything other
1560
                      // than INVALIDATED: prevents overwrites from race conditions
1561
                	  if ( listedReplica.getReplicationStatus() == ReplicationStatus.COMPLETED &&
1562
            		    replicaStatus != ReplicationStatus.INVALIDATED ) {
1563
                	  throw new InvalidRequest("4853", "Status state change from " +
1564
                			  listedReplica.getReplicationStatus() + " to " +
1565
                			  replicaStatus.toString() + "is prohibited for identifier " +
1566
                			  pid.getValue() + " and target node " + 
1567
                			  listedReplica.getReplicaMemberNode().getValue());
1568

  
1569
            	  }
1545 1570
                  replicas.remove(index);
1546 1571
                  break;
1547 1572
                  

Also available in: Unified diff