Locking on sequence relation is not required for sequence server
Locking on sequence relation is not required for sequence server

Postgres merge introduced init_sequence() which can optionally lock sequence
relation.

In GPDB, single sequence server instance is used to generate sequence values
for all requests coming from segments, hence it doesn't require a lock on
sequence relation.

There are three concurrent scenarios when using sequence:
Scenario A: concurrent requests from segments:
create table t1 (c int, d serial) distributed by (c);
insert into t1 select i from generate_series(1, 100) i;

Scenario B: concurrent requests from master:
tx1: select nextval('t1_c_seq'::regclass);
tx2: select nextval('t1_c_seq'::regclass);

Scenario C: concurrent requests from both master and segments
tx1: select nextval('t1_c_seq'::regclass);
tx2: insert into t1 values (200, default);

Scenario A is protected by the single instance of sequence server.
Scenario B and C are protected by the BUFFER_LOCK_EXCLUSIVE on shared
buffer of the sequence relation.

With that said, we don't need to hold additional lock on sequence relation.

Signed-off-by: Xin Zhang <80ac6425c128040c27b3c6077c824bc26222f5e7@pivotal.io>

lisakowen/gpdb,adam8157/gpdb,kaknikhil/gpdb,adam8157/gpdb,edespino/gpdb,lisakowen/gpdb,yuanzhao/gpdb,xinzweb/gpdb,edespino/gpdb,kaknikhil/gpdb,jmcatamney/gpdb,jmcatamney/gpdb,ashwinstar/gpdb,cjcjameson/gpdb,yuanzhao/gpdb,Quikling/gpdb,jmcatamney/gpdb,Chibin/gpdb,kaknikhil/gpdb,Chibin/gpdb,janebeckman/gpdb,janebeckman/gpdb,adam8157/gpdb,greenplum-db/gpdb,ashwinstar/gpdb,yuanzhao/gpdb,rvs/gpdb,yuanzhao/gpdb,Chibin/gpdb,50wu/gpdb,lisakowen/gpdb,jmcatamney/gpdb,jmcatamney/gpdb,lisakowen/gpdb,xinzweb/gpdb,janebeckman/gpdb,yuanzhao/gpdb,jmcatamney/gpdb,janebeckman/gpdb,edespino/gpdb,50wu/gpdb,50wu/gpdb,adam8157/gpdb,kaknikhil/gpdb,janebeckman/gpdb,50wu/gpdb,yuanzhao/gpdb,xinzweb/gpdb,cjcjameson/gpdb,greenplum-db/gpdb,janebeckman/gpdb,cjcjameson/gpdb,rvs/gpdb,cjcjameson/gpdb,Quikling/gpdb,greenplum-db/gpdb,Quikling/gpdb,edespino/gpdb,cjcjameson/gpdb,rvs/gpdb,lisakowen/gpdb,50wu/gpdb,kaknikhil/gpdb,cjcjameson/gpdb,edespino/gpdb,adam8157/gpdb,edespino/gpdb,Chibin/gpdb,yuanzhao/gpdb,greenplum-db/gpdb,yuanzhao/gpdb,rvs/gpdb,50wu/gpdb,kaknikhil/gpdb,Quikling/gpdb,xinzweb/gpdb,kaknikhil/gpdb,janebeckman/gpdb,janebeckman/gpdb,jmcatamney/gpdb,rvs/gpdb,Quikling/gpdb,kaknikhil/gpdb,adam8157/gpdb,edespino/gpdb,50wu/gpdb,greenplum-db/gpdb,cjcjameson/gpdb,rvs/gpdb,yuanzhao/gpdb,Quikling/gpdb,janebeckman/gpdb,Chibin/gpdb,adam8157/gpdb,Quikling/gpdb,rvs/gpdb,Quikling/gpdb,cjcjameson/gpdb,edespino/gpdb,janebeckman/gpdb,ashwinstar/gpdb,ashwinstar/gpdb,edespino/gpdb,xinzweb/gpdb,ashwinstar/gpdb,lisakowen/gpdb,Chibin/gpdb,Chibin/gpdb,ashwinstar/gpdb,adam8157/gpdb,cjcjameson/gpdb,ashwinstar/gpdb,ashwinstar/gpdb,edespino/gpdb,rvs/gpdb,Chibin/gpdb,greenplum-db/gpdb,lisakowen/gpdb,greenplum-db/gpdb,greenplum-db/gpdb,Quikling/gpdb,jmcatamney/gpdb,yuanzhao/gpdb,lisakowen/gpdb,xinzweb/gpdb,xinzweb/gpdb,kaknikhil/gpdb,50wu/gpdb,Chibin/gpdb,rvs/gpdb,kaknikhil/gpdb,Chibin/gpdb,xinzweb/gpdb,rvs/gpdb,Quikling/gpdb,cjcjameson/gpdb