Global sequences in Shardman are implemented on top of regular PostgreSQL sequences with some additional cluster-wide metadata, which among other things holds the interval of globally unused sequence elements.
When CREATE SEQUENCE is issued, an ordinary
PostgreSQL sequence with the same
name is created on every cluster node. The range of this local
sequence is a bounded sub-interval of the global sequence (as
defined by MINVALUE and
MAXVALUE parameters), and it contains at most
block_size elements. The
shardman.next_value function returns
values from the local sequence until it runs out, then a new
sub-interval with block_size elements is
allocated from the global sequence using a broadcast query
involving all cluster nodes. So, smaller block size values
make the generated numbers more monotonic across the cluster,
but incur a performance penalty since the broadcast query may
be rather expensive. Another way to describe the block size
parameter is to say that it controls the size of the second
cache level, similarly to how the CACHE
parameter works, except at the level of an entire
Shardman cluster.
Also note, that every time a new sub-interval is allocated the
underlying local sequence is modified (as in ALTER
SEQUENCE), which will lock it for the transaction
duration, preventing any other local concurrent transactions
from obtaining next sequence values.