Schema Distribution
Schema definitions such as keyspaces and tables are stored in system tables. When the schema is changed, nodes in a cluster are notified of the changes via schema push mechanism. If a node was down during a schema change, it will use the schema pull mechanism to synchronize with the rest of the cluster at startup.
Push happens whenever a schema is changed (e.g. CREATE KEYSPACE
) via migration manager. This makes schema changes visible across all available nodes in the cluster. The local node sends schema change mutations in a DEFINITIONS_UPDATE
message to all live members. Each node that receives the message, applies the mutations via schema merging.
Schema pull is triggered when a the onAlive()
, onChange()
, onJoin()
event handlers in StorageService
are invoked.
Here's the sequence of events in Origin:
- At node boostrap,
MigrationManager.scheduleSchemaPull()
is invoked. - The
scheduleSchemaPull()
function submits aMigrationTask
is which sends aMIGRATION_REQUEST
. - An endpoint responds with INTERNAL_RESPONSE that includes a list of mutations returned from
LegacySchemaTables.convertSchemaToMutations()
. - The bootrapping node applies the mutations via
LegacySchemaTables.mergeSchema()
.