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

nsqd: create Topic paused #1050

Merged
merged 2 commits into from
Jul 6, 2018
Merged

Conversation

ploxiln
Copy link
Member

@ploxiln ploxiln commented Jul 4, 2018

Enables simplifications. Experimental, not fully tested.

Alternative to #1049. cc @mreiferson

@ploxiln ploxiln force-pushed the create_topic_paused branch from 31bfb88 to 32f99eb Compare July 4, 2018 20:32
@mreiferson
Copy link
Member

Yea, this is definitely better, thanks. It's still pretty gnarly, but I'm not sure how much it's worth messing with it.

@ploxiln
Copy link
Member Author

ploxiln commented Jul 6, 2018

I should probably do some real testing :P

@ploxiln
Copy link
Member Author

ploxiln commented Jul 7, 2018

Initial testing looks good, as expected.

I wonder if there might be some potential for confusion due to this change ... maybe if some script creates a topic then immediately pauses it, that could happen before the automatic un-pause and the the topic could unexpectedly end up unpaused. Or something like that. I don't want to be paranoid about this, just something to keep in mind.

On the other hand, I like how this reduces how long topic locks are held. Though I guess it's a one-time thing.

As a further digression, I know you thought may be a good idea to make a NewTopic() that takes channels to pre-create. While that would work for loading metadata, I think that wouldn't work for the runtime-created topics. We would still need some kind of lock for multiple clients (http or tcp) touching the same new topic around the same time. We probably would not want to hold the nsqd lock while querying nsqlookupds, so we'd add a sub-lock ... so we might as well create the topic and use it for coordination ;)

@mreiferson
Copy link
Member

I wonder if there might be some potential for confusion due to this change ... maybe if some script creates a topic then immediately pauses it, that could happen before the automatic un-pause and the the topic could unexpectedly end up unpaused. Or something like that. I don't want to be paranoid about this, just something to keep in mind.

That's an interesting edge case. It probably means we're abusing paused state when what we really need is tighter control over internals of topic creation, e.g. if we moved starting of topic.messagePump outside of NewTopic (into some Start() func) then we can control when that goro launches and not need to use pausing as a hack?

@ploxiln
Copy link
Member Author

ploxiln commented Jul 7, 2018

Yeah I think that's a good idea - instead of a special first "UnPause", have a separate "Start".

@ploxiln
Copy link
Member Author

ploxiln commented Jul 7, 2018

The tricky bit there is that Topic.Pause() and Topic.GetChannel() currently block until messagePump() consumes the notification (or until the exitChan is closed).

@ploxiln ploxiln deleted the create_topic_paused branch August 1, 2018 20:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants