Demonstration of DBLE Global Sequence Configuration: Timestamp (Snowflake) and Offset‑Setup Types
This tutorial demonstrates how to configure and use DBLE's global sequence feature, covering the timestamp‑based Snowflake algorithm and the offset‑setup type, including server.xml settings, table definitions, insertion behavior, and handling of restarts to ensure unique identifiers.
In the previous episode we introduced the principle of global sequences; this article uses video demonstrations to show how the two global sequence types work in DBLE.
The first type uses the Snowflake timestamp algorithm. In server.xml the attribute sequnceHandlerType set to 2 selects the timestamp mode. A table such as tb_hash_sharding_er2 with autoIncrement=true and a target column is configured to store the global sequence, and a worker‑node ID is defined to form a composite primary key that guarantees uniqueness across machines.
Connecting to a DBLE traffic port and inspecting the newly created table reveals three columns; the first column is bigint because Snowflake generates a 64‑bit integer, which exceeds the range of a regular int .
Inserting a row generates a unique sequence number; subsequent inserts produce different numbers. The algorithm applies a modulo‑1024 operation and a range‑based lookup (0‑512). Once a global‑sequence algorithm is chosen it must not be changed, as mixing types can cause data conflicts.
The second type is the offset‑setup sequence. Changing sequnceHandlerType to 1 (and restarting DBLE) switches to this mode. After updating the configuration, the tb_hash_sharding_er2 table in the testdb database is referenced in the sequence_db file, allowing each table to have its own sequence granularity. The generator is placed on dn1 (a database instance), with db1 pointing to datahost1 on port 33061 .
The accompanying dbseq.sql script creates a simple three‑column table and a stored procedure that acts as the number generator. The procedure uses a lock to modify a record and return the next value, preventing conflicts from concurrent requests. The script is executed with the source command on the dn1 node.
After the table is created it is empty; an initial record must be inserted to set the start value (commonly 0 or 1‑1000 ). Subsequent inserts automatically increment (e.g., 2, 3, …) under DBLE’s internal control. If DBLE crashes and restarts, the generator may skip numbers, but uniqueness is still guaranteed.
Finally, the article summarizes that the DBLE global sequence feature has been demonstrated, covering both timestamp‑based and offset‑setup configurations, and provides repository links for further reference.
Aikesheng Open Source Community
The Aikesheng Open Source Community provides stable, enterprise‑grade MySQL open‑source tools and services, releases a premium open‑source component each year (1024), and continuously operates and maintains them.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.