sorintlab / stolon

PostgreSQL cloud native High Availability and more.
https://talk.stolon.io
Apache License 2.0
4.62k stars 443 forks source link

what mean about PG WANTEDGENERATION and PG CURRENTGENERATION #881

Open jackin853 opened 2 years ago

jackin853 commented 2 years ago

I just learned the stolon framework, and I encountered some concepts that I don't understand very well, and I didn't find any relevant explanations in the relevant documents. When I use the stolonctl status command to get the cluster status, I see the following two columns in the status of the keepers. I don't know what it means. The two values are sometimes the same, sometimes different. What does the same value mean? What's the difference? PG WANTEDGENERATION PG CURRENTGENERATION

viggy28 commented 2 years ago

I agree, that it would be nice to improve the documentation around these internal concepts.

Let me explain what I understand.

When the db spec changes, sentinel increases the db.Generation by 1. https://github.com/sorintlab/stolon/blob/e48f9a4d63e622b4ef8a3c674f30321ea47ac9c4/cmd/sentinel/cmd/sentinel.go#L1560

If the keeper is healthy, then it would likely update the spec change and finally keeper sets local status with db.generation. https://github.com/sorintlab/stolon/blob/5dc6358f69eb73e03f7ab55c07295bd65be7c800/cmd/keeper/cmd/keeper.go#L1741

Keeper reports the updated local state generation and sentinel updates db.status.currentGeneration with db.generation https://github.com/sorintlab/stolon/blob/e48f9a4d63e622b4ef8a3c674f30321ea47ac9c4/cmd/sentinel/cmd/sentinel.go#L301

Overall, why we doing all these is a way to identify that whether the databases (keepers) are converged or not. @sgotti feel free to correct me wherever I am wrong :)

jackin853 commented 1 year ago

@viggy28 Thanks,I got it