better traceability
removeUnlinkedReplicas:
SELECT ReplicaID FROM CacheReplicas WHERE Links = 0 AND ReplicaID NOT
IN ( SELECT DISTINCT( ReplicaID ) FROM StageRequests )
followed by
DELETE FROM CacheReplicas WHERE ReplicaID IN (%s) AND Links= 0;	
will cause a race condition under certain conditions when old tasks are
set failed.
small typo in script
SELECT ReplicaID FROM CacheReplicas WHERE Links = 0 AND ReplicaID NOT
IN ( SELECT DISTINCT( ReplicaID ) FROM StageRequests )
followed by
DELETE FROM CacheReplicas WHERE ReplicaID IN (%s) AND Links= 0;	
will cause a race condition under certain conditions when old tasks are
set failed.
Merge pull request #1541 from remenska/rel-v6r7-sms-race-conditions

Rel v6r7 sms race conditions