namgk / ambienttalk

Automatically exported from code.google.com/p/ambienttalk
0 stars 0 forks source link

"retract:" primitive can deadlock the actor when applied to remote far references #51

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

Run two VMs A and B. On VM B, export an object.
On VM A, discover the object, then disconnect.
Then send a message to the disconnected far reference annotated with @Due.
(the actual code I used to test this are the demo-client.at and demo-server.at 
files under "/at/demo/echoservice")

What is the expected output? What do you see instead?

Expected: the future associated with the message is ruined with a 
TimeoutException.
Actual: the actor is deadlocked.

What's going on here?
I traced the AmbientTalk code and found that the actor is deadlocked when it 
calls "retract:" in the file "futures.at" in the method "constructLeaseFor":

{{{
def outbox := retract: receiver;
}}}

I then traced the Java code and the call that deadlocks the actor is the call 
to .get() in the class "FarReferencesThreadPool", in the 
"sync_event_retractUnsentMessages" method (line 282). I didn't debug any 
further but it probably means that the Callable submitted to the thread pool is 
itself blocked.

Original issue reported on code.google.com by tvcut...@gmail.com on 27 May 2011 at 3:35

GoogleCodeExporter commented 8 years ago
The problem was on the implementation of meta_retractUnsentMessages for remote 
far references.
More concretely line in 640 of NATFarReference.java.
The FarReferencesThreadPool was attempting to execute AmbientTalk code to 
convert a table of NATOutboxLetter to one of NATASyncMessages (the expected 
result of meta_retractUnsentMessages) and the Coercer tried to prevent this 
which cause the creation of a future which was never resolved.

The fix consist of splitting the process of retract in : 1) removing the 
NATOutboxLetter and canceling them from the outbox (executed by 
FarReferencesThreadPool) and then 2) returning a table of NATASyncMessages 
(executed by the corresponding ELActor).

Original comment by egonzal...@gmail.com on 31 May 2011 at 3:23