Race Problem: ClusterNode.start
The ClusterNode.start method has a race problem which can lead to returning an unstarted ClusterNode after the start method has been called.
The code:
def start(): ClusterNode = {
if (isConnected.compareAndSet(false, true)) {
initializeNode()
}
this
}
The cause. This code doesn't block and if one thread has called start and this takes some time, if then another thread also calls start, he will get an partially or non initialized node.
Fix:
Easiest thing is to make it synchronized. And make the isCOnnected a volatile var boolean that is checked when something needs to be done with the cluster and a running cluster needs to be available.
From the documentation it also is not clear what to expect and which guarantees are given.
The code:
def start(): ClusterNode = {
if (isConnected.compareAndSet(false, true)) {
initializeNode()
}
this
}
The cause. This code doesn't block and if one thread has called start and this takes some time, if then another thread also calls start, he will get an partially or non initialized node.
Fix:
Easiest thing is to make it synchronized. And make the isCOnnected a volatile var boolean that is checked when something needs to be done with the cluster and a running cluster needs to be available.
From the documentation it also is not clear what to expect and which guarantees are given.
Leave a comment
on 2011-07-15 03:10 *
By pveentjer
Assigned to set to viktorklang
Status changed from Accepted to Test
https://github.com/jboner/akka/commit/966f7d92979ea544d8ac245bbf22c4aea7c33fa4
The important change in this commit was the replacement of the isConnected type from AtomicBOolean to Switch. Both the start and the shutdown are now making use of this Switch.
A lot of other diff stuff is probably a reformatting.
The important change in this commit was the replacement of the isConnected type from AtomicBOolean to Switch. Both the start and the shutdown are now making use of this Switch.
A lot of other diff stuff is probably a reformatting.
Updating tickets (#967, #974, #975, #976, #980, #981, #989, #990, #992, #993, #994, #999, #1000, #1004, #1008, #1011, #1015, #1018, #1022, #1023, #1024, #1025, #1027, #1028, #1029, #1030, #1032, #1033, #1036, #1047, #1053, #1062, #1067, #1068, #1069, #1072, #1075, #1078, #1082, #1102, #1107, #1110, #1111, #1115, #1116, #1121, #1122, #1123, #1124)