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
Multi-instance raft #1759
Comments
In this regard, the raft implementation isn't different from any other DCS. It uses
IMO, the main use-case for using raft, is when you just have a single cluster, with two or three PostgreSQL nodes.
Yes, that's the major difference of raft with other DCS. You have to specify in the config the list of other nodes of this specific PostgreSQL cluster.
I don't think that pysyncobj recommends or advertises any default port. It just happened that in my experiments I used some "random" ports, so they ended up in the sample configs and code.
The thing is that DCS implementations don't know anything about REST API. Even the code which handles the config file doesn't care much about DCS, it only tries to match available DCS with config. I.e., it knows that there is for example etcd3.py in the It seems that you put some effort into the raft implementation, so I should warn you that it is not yet production-ready. |
Hrm, ok - I only did a quick
I now realize that this is probably just the pysyncobj internal stuff, I'll have to look into how to get at the patroni DCS data itself, is there some CLI way to get at it? When I try to start a second patroni cluster on the same raft port, I just get
I see; I think one of the main advantages of raft would be that you don't need another service besides
Right, I took a look at hacking that in but didn't get far.
Ok, thanks for the heads-up. I did not spend a lot of time, just tried to see whether it's possible to easily integrate raft into the Debian package now that pysyncobj is in Debian |
So, one thing is having the same Otherwise, I would expect binding to the same port should just fail, but it seems pysyncobj just sits idle/is in a loop I tried starting |
I just noticed now that the second, waiting instance spins in a tight loop and takes 100% CPU |
Exactly,
Unfortunately pysyncobj is not very good at providing feedback of what is going on. It tries to bind to the port and if bind failed it immediately retries without even writing anything to the log. Therefore the CPU usage jumps to 100%. It is not possible to run multiple Patroni instances on the same host with raft on the same port.
Yes, this is the main advantage. But it is useful only when you need to manage just one cluster. If you need to run more then one - it is better to invest in setting up for example Etcd. The only reason to have
Yes, that's definitely an issue. Two instances with the same config will try to use the same files and might damage raft logs and dump files. Although, it shouldn't be so dangerous as it sounds. The log is only mirrored to the file, while the content is stored in the memory, so only when you restart it will read something unexpected. But even in that case it will get the latest snapshot from the leader.
It fails for sure, but pysyncobj is very silent about that and simply retries without a back-off :( |
I thought about this some more. I think the DCS setup being encapsulated and insulated from Patroni makes sense for the other DCS providers, but for RAFT, I believe it would be beneficial to have one RAFT per instance, and maybe let the RAFT code know a bit more about the config (in particular, the REST API port) in order to deduce a RAFT port ab initio, without having to touch the DCS config for each instance. This could be done (and it I've got a PoC working, will open a PR in a bit) by exposing
The API port can then be extracted from Another possibility would be the Postgres port, but that one is hidden even further down in
Is that done a lot in practise? I think it would be ok to just use the REST API port that the Patroni configuration mentioned at startup time and keep using that.
I think it would be wise to mark features like that as "Preview" or "Beta", as users have come to expect Patroni to be a pretty mature and solid product. They might assume that once you've cut a release with it, the feature must be ready for prime-time. |
If no ports are specified for self_addr, bind_addr and/or listen_addrs, then Patroni will self-assign the startup API port + 10000 as RAFT port.
If no ports are specified for self_addr, bind_addr and/or partnern_addrs, then Patroni will self-assign the startup API port + 10000 as RAFT port.
If no ports are specified for self_addr, bind_addr and/or partner_addrs, then Patroni will self-assign the startup API port + 10000 as RAFT port.
If no ports are specified for self_addr, bind_addr and/or partner_addrs, then Patroni will self-assign the startup API port + 10000 as RAFT port.
If no ports are specified for self_addr, bind_addr and/or partner_addrs, then Patroni will self-assign the startup API port + 10000 as RAFT port.
If no ports are specified for self_addr, bind_addr and/or partner_addrs, then Patroni will self-assign the startup API port + 10000 as RAFT port.
It seems pure raft based on pysyncobj does not namespace the configuration values like e.g. etcd does (which uses the
/$SCOPE/
as prefix/namespace). So you can't run two patroni instances on the same raft port.Is this not possible due to restrictions in the way the key-value store works (no directories/nesting), or even due to the fact that it would be intrinsically tied to the patroni instance creating it (maybe like the systemid in postgresql)?
It would of course be possible to just select a different port for each instance, but this makes it more cumbersome to setup multiple instances the way Debian does it, because it currently assumes the DCS configuration is the same for each patroni instance.
As an aside, is there some default port assigned for raft? I see both 1234 and 222[234] in the code.
Maybe it could be made to just use API port + 10000 (so 18008 by default) if no port is specified, (assuming that this class could even get at the API port)?
The text was updated successfully, but these errors were encountered: