Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Actor termination #9

Open
tbuehlmann opened this issue Jun 2, 2013 · 5 comments
Open

Actor termination #9

tbuehlmann opened this issue Jun 2, 2013 · 5 comments
Assignees

Comments

@tbuehlmann
Copy link
Owner

Linked Channel actors won't be terminated at any time. Memory leaks incoming.

@ghost ghost assigned tbuehlmann Jun 2, 2013
@tbuehlmann
Copy link
Owner Author

Linked Channel actors will be terminate on Bot#terminate: ea3dd5c.

Still, no mechanism to regularly clean up wild, "orphaned" Channel actors.

@neektza
Copy link

neektza commented Jun 4, 2014

Hey Tobias.

What's the case in which "orphaned" channel actors spring into existence? In other words, how do I know if there are any orphaned Channel actors?

After calling terminate on the bot, it seems it does indeed die, but all channels show it as if it's still connected.

@tbuehlmann
Copy link
Owner Author

"Orphaned" Channels spring into existence when for example leaving one or being kicked off one. The channels should be terminated when the Bot is terminated, but there's no mechanism that will terminate such inactive channels regularly.

One way would be to remember all channels on join/etc and check regularly if these channels are present in @channels. If not, terminate. Another rather meh way would be to scan through all Channel objects (using Objectspace and whatnot) and terminate the ones not being present in @channels.

@neektza
Copy link

neektza commented Jun 6, 2014

I don't think I've hit the use case you described.

When I noticed that the bot is still showing as present on a channel even though I killed the Bot actor, I did not explicitly leave the channel (nor was I kicked from it). All I did was simply

bot = Vetinari::Bot.new do |c|
  # config
end

# later
bot.terminate

As far as I understand, after I kill the Bot actor, all Channel actors should die by consequence of being linked to the Bot as specified here.

What I don't understand is, why does the bot show as present, even though all the channel actors are (or at least, should be) dead. Where is this channel presence being maintained?

@tbuehlmann
Copy link
Owner Author

IIRC: Channels are linked to the Bot so if the Bot crashes, the channels shall crash and die as well. But just because Channels are linked to the Bot doesn't mean the Channels are terminated when the Bot is terminated. When terminating the Bot, the following calls happen:

Bot#finalize
@channels#terminate
@channels#finalize
#<Channel>#terminate
#<Channel>#terminate
#<Channel>#terminate
...

If the Bot parts a Channel, this Channel is simply removed from @channels (an Object of ChannelContainer. The Channel actor won't be terminated. Also, since that Channel is not in '@channels` anymore, it also won't be terminated when the Bot terminates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants