ReplicationMechanics

The Mechanics of MusicBrainz Server Replication

In principal the broad approach that we've taken is to take the "dbmirror" PostgreSQL contributed code (which creates a log of changes to tables using triggers), but change data link between master and slave from "direct Postgres connection" to some file-transfer system (e.g. FTP).

How will this work exactly?

replication_control

This is a one-row table which records state information for the replication system. It's used slightly differently depending on whether we're the master or a slave. Possibly this is a design weakness.

Schema Sequence Number

current_schema_sequence defines the sequence number of the current database schema. This value is also held in &DBDefs::DB_SCHEMA_SEQUENCE.

How the Master Advances to the Next Schema Sequence Number

When upgrading to a new release (say from $OLD schema to $NEW schema, where $NEW=$OLD+1):

At some point the master then produces its next replication packet (#N+1), which will have the following properties:

How the Slave Advances to the Next Schema Sequence Number

When upgrading to a new release (say from $OLD schema to $NEW schema, where $NEW=$OLD+1):

Now the database is of schema $NEW, and replication_control.current_schema_sequence = $NEW.

When the next replication packet is loaded:

Other Processing Details

Replication Sequence Number

current_replication_sequence has two slightly different meanings, depending on whether we're the master or a slave.

How the Replication Sequence Number Is Advanced

Export

The same program is used both to perform a full database export and/or to produce replication packets.

All archives produced, whether a full export or a replication packet, include the replication sequence number in the file REPLICATION_SEQUENCE. If a full export is performed without a replication packet, however, then REPLICATION_SEQUENCE will be empty, indicating that this full export does not correspond to a replication point, and therefore cannot be used for replication.


CategoryReplication

last edited 2006-11-04 14:37:08 by LukasLalinsky

MusicBrainz web site  *  Support / Contact