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

Question: API call to trigger pindex -> node reassignment? #22

Closed
tleyden opened this issue Aug 5, 2015 · 9 comments
Closed

Question: API call to trigger pindex -> node reassignment? #22

tleyden opened this issue Aug 5, 2015 · 9 comments

Comments

@tleyden
Copy link
Contributor

tleyden commented Aug 5, 2015

Is there an API call to do this?

In our case, if one Sync Gateway was taken offline.

@steveyen
Copy link
Member

steveyen commented Aug 5, 2015

If you want a sync-gateway taken out of the cluster, then you have to get that node unlisted or unregistered from the Cfg. Then the planner will automatically wake up and reassign the PIndexes across remaining nodes.

For example, to do this kind of thing in cbft's case, that's done by stopping cbft, and running it again with the "-register=unknown" cmd-line flag. See cbft's docs here:

http://labs.couchbase.com/cbft/admin-guide/clustering/#removing-cbft-nodes

Underneath the hood, that "-register=unknown" command-line flag eventually leads to codepath that invokes cbgt.Manager.RemoveNodeDef(), like here...

https://github.com/couchbaselabs/cbgt/blob/master/manager.go#L214

And, then, the planner (which is subscribing to Cfg changes) will awake and automatically do the PIndex->node reassignment & re-planning.

@steveyen
Copy link
Member

steveyen commented Aug 5, 2015

One more thing, if you think for example for whatever reason the planner needs a "force wake up" or a kick in the head to do some re-planning, then you can invoke...

http://godoc.org/github.com/couchbaselabs/cbgt#Manager.Kick

And, if you're also using cbgt's REST endpoints, then that's also available via REST -- search for the "/api/managerKick" API here...

http://labs.couchbase.com/cbft/api-ref/#node-configuration

@tleyden
Copy link
Contributor Author

tleyden commented Aug 6, 2015

Supposing we added a Sync Gateway endpoint on the admin API (port 4985, superuser mode), which told this Sync Gateway instance to remove itself, would we just call Manager.StartRegister("unwanted")?

@steveyen
Copy link
Member

steveyen commented Aug 6, 2015

Slight correction, you'd probably us "unknown", like...

cbgtManger.StartRegister("unknown")

In hindsight, the StartRegister() method is something I wish I had instead renamed to just plain old Register().

@tleyden
Copy link
Contributor Author

tleyden commented Aug 6, 2015

Yeah, I agree, StartRegister() is misleading, Register() is definitely better. Add Register() which calls StartRegister() under the hood and deprecate StartRegister()?

@steveyen
Copy link
Member

steveyen commented Aug 6, 2015

Yep, good idea. Will make that StartRegister->Register the plan.

@steveyen
Copy link
Member

steveyen commented Aug 6, 2015

On the StartRegister deprecation & rename to Register, see commit: 74c80d

@tleyden
Copy link
Contributor Author

tleyden commented Aug 17, 2015

A few more questions on this topic:

  • The examples you gave look like they were geared toward a node removing itself from the CBGT Cfg. Instead of that, is it possible for a node to remove another node?
  • If there were a scenario where there were 5 sync gateway nodes, and 4 of the 5 detected that one of the nodes was dead and all tried to remove that node at approximately the same time -- would this be safe or would it cause issues?

@steveyen
Copy link
Member

Instead of that, is it possible for a node to remove another node?

Going to pull that out as a new, separate issue: #26

If there were a scenario where there were 5 sync gateway nodes, and 4 of the 5 detected that one of the nodes was dead and all tried to remove that node at approximately the same time -- would this be safe or would it cause issues?

Similarly, gonna point to brand new issue 27 to capture that scenario... #27

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

No branches or pull requests

2 participants