SET DR

Documentation

VoltDB Home » Documentation » Using VoltDB

SET DR

SET DR — Enables the use of Cross Datacenter Replication (XDCR).

Synopsis

SET DR= {ACTIVE | PASSIVE}

Description

The SET DR statements enables and disables Cross Datacenter Replication (XDCR). You actually turn on database replication in the deployment file using the <dr> and <connection> elements. But to use two-way, active replication, you must also enable it in the database schema using the SET DR=ACTIVE statement for both databases involved in the XDCR process. See Chapter 11, Database Replication for more information about XDCR.

By default, only passive DR is enabled in the schema. By specifying SET DR=ACTIVE you enable the use of XDCR. When enabled, XDCR assigns an additional 8 bytes per row for every DR table in the database. The additional space is used to store metadata about the row's most recent transaction.

For example, say your schema contains 5 tables which you declare as DR tables and those tables will store a million rows each. This means the database will consume approximately 40 megabytes of additional memory when XDCR is enabled, even if DR is not yet initiated in the deployment file. Which is why the SET DR=ACTIVE statement should only be used for databases that will be involved in active XDCR.

If use of XDCR is enabled in the schema, you can use the SET DR=PASSIVE statement to disable it. Note, however, for both the SET DR=ACTIVE and SET DR=PASSIVE statements, any tables declared as DR tables must be empty when the SET DR statement is executed.

Examples

The following example enables the use of XDCR and then declares three tables as DR tables. Because any DR tables must be empty when the SET DR statement is executed, it is often easiest to place the statement at the beginning of the schema.

SET DR=ACTIVE;
DR TABLE Employees;
DR TABLE Divisions;
DR TABLE Locations;