On Fri, Nov 2, 2012 at 9:50 AM, Tatsuo Ishii <is...@po...> wrote:
> Hi,
>
> I'm wondering how sequences are handled in Postgres-XC. Could you
> please let me know where I can start with understanding this? Docs?
> Source code? Thanks in advance,
>
I am sure you already know that a Postgres-XC cluster needs a unique GTM
(global transaction manager) to feed global transaction ID values and
global snapshots to each node of the cluster, the same GTM is used for the
feed of sequence values in a global way.
As a start if you want to have a look at how it is managed in XC, for the
postgres backend side have a look at nextval_internal in
src/backend/commands/sequence.c, we put in the PG code a hook called
GetNextValGTM to get the next global sequence value from GTM. There are
similar hooks for CREATE/ALTER/DROP SEQUENCE. All the backend-side client
APIs related to GTM are located in src/backend/access/transam/gtm.c.
On the GTM side, I would recommend you to have a look at src/gtm/main,
mainly gtm_seq.c which contains all the sequence-related APIs.
Also, the message types exchanged between GTM and backend nodes are listed
in src/include/gtm/gtm_msg.h. MSG_SEQUENCE_GET_NEXT is for example the
message type used to get the next global value of a sequence. Look at how
messages of this type are managed on backend and GTM side and you will
understand easily the process flow.
--
Michael Paquier
http://michael.otacoo.com
|