cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robert Stupp (JIRA)" <>
Subject [jira] [Commented] (CASSANDRA-9200) Sequences
Date Wed, 13 May 2015 07:56:01 GMT


Robert Stupp commented on CASSANDRA-9200:

The linked branch contains an implementation of sequences. The code is still ugly but works
including utests.

Syntax is explained in {{CQL.textile}} like this:

<create-sequence-stmt> ::= CREATE ( OR REPLACE )? SEQUENCE ( IF NOT EXISTS )?
                         ( <keyspace> '.' )? <sequencename>
                         ( INCREMENT ( BY )? <integer> )?
                         ( ( MINVALUE <integer> ) | ( NO MINVALUE ) )?
                         ( ( MAXVALUE <integer> ) | ( NO MAXVALUE ) )?
                         ( START ( WITH )? <integer> )?
                         ( CACHE <integer> )?
                         ( CACHE LOCAL <integer> )?
                         ( SERIAL CONSISTENCY LEVEL <consistencyLevel> )?
                         ( CONSISTENCY LEVEL <consistencyLevel> )?

Access to sequences:
SELECT nextval('keyspace_name', 'sequence_name') FROM table;

The implementation uses three tables:
# {{system.schema_sequences}} holding the sequence definitions
# {{system_distributed.seq_reservations}}  tracking the next available sequence value
# {{system.sequence_local}} tracking the range of values exclusively assigned to a node

* {{CACHE}} defines the number of values to acquire from the overall range ({{system_distributed.seq_reservations}}).
* {{CACHE LOCAL}} (defaults to {{CACHE}}) defines the number of values to take from {{system.sequence_local}}
- not sure whether to keep that option. It's not really necessary and its only limited use
is when a node crashes without being gracefully shut down.
* the consistency levels are those used to read from/modify {{system_distributed.seq_reservations}}
* I've not included a {{CYCLE}} option. Reason for that is that it would require a global
synchronization of all nodes to ensure that no node still owns a range before wrapping around.
* It also has some limited support for permissions (CASSANDRA-9372).
* {{SELECT nextval}} would benefit from virtual tables (CASSANDRA-7622) - i.e. {{SELECT nextval(...)
* Implementation of {{nextval()}} function requires to pass constant values to function arguments
(sneaked into the branch)

> Sequences
> ---------
>                 Key: CASSANDRA-9200
>                 URL:
>             Project: Cassandra
>          Issue Type: New Feature
>            Reporter: Jonathan Ellis
>            Assignee: Robert Stupp
>             Fix For: 3.x
> UUIDs are usually the right choice for surrogate keys, but sometimes application constraints
dictate an increasing numeric value.
> We could do this by using LWT to reserve "blocks" of the sequence for each member of
the cluster, which would eliminate paxos contention at the cost of not being strictly increasing.
> PostgreSQL syntax:

This message was sent by Atlassian JIRA

View raw message