GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Documentation
  • Privacy Statement
  • License Agreement
  • Contact Us

This view

  • Original page
  • New address

GeezerVison is showing university.voltdb.com — Chapter 14. Saving & Restoring a VoltDB Database

  • Volt Active Data
  • Developer Hub
  • Books
    • VoltDB Tutorial
    • Using VoltDB
    • VoltDB Guide to Performance and Customization
    • VoltDB Administrator's Guide
    • Volt Kubernetes Administrator's Guide
    • VoltDB Quick Reference
  • VoltDB V16
    • VoltDB V16
    • VoltDB V15.3 LTS
    • VoltDB V14.3 LTS
    • VoltDB V13.3 LTS
    • VoltDB V12.3 LTS
    • VoltDB V11.4
    • VoltDB V10.2
    • VoltDB V9.3
Chapter 14. Saving & Restoring a VoltDB Database

Using VoltDB

  • About This Book
  • 1. Overview▶
    • 1.1. What is VoltDB?
    • 1.2. Who Should Use VoltDB
    • 1.3. How VoltDB Works
      • 1.3.1. Partitioning
      • 1.3.2. Serialized (Single-Threaded) Processing
      • 1.3.3. Partitioned vs. Replicated Tables
      • 1.3.4. Ease of Scaling to Meet Application Needs
    • 1.4. Working with VoltDB Effectively
  • 2. Installing VoltDB▶
    • 2.1. Operating System and Software Requirements
    • 2.2. Installing VoltDB
      • 2.2.1. Upgrading From Older Versions
    • 2.3. Setting Up Your Environment
    • 2.4. What is Included in the VoltDB Distribution
  • 3. Starting the Database▶
    • 3.1. Initializing and Starting a VoltDB Database
    • 3.2. Initializing and Starting a VoltDB Database on a Cluster
    • 3.3. Stopping a VoltDB Database
    • 3.4. Saving the Data
    • 3.5. Restarting a VoltDB Database
    • 3.6. Updating Nodes on the Cluster
    • 3.7. Defining the Cluster Configuration
      • 3.7.1. Determining How Many Sites per Host
      • 3.7.2. Configuring Paths for Runtime Features
      • 3.7.3. Verifying your Hardware Configuration
  • 4. Designing the Database Schema▶
    • 4.1. How to Enter DDL Statements
    • 4.2. Creating Tables and Primary Keys
    • 4.3. Analyzing Data Volume and Workload
    • 4.4. Partitioning Database Tables
      • 4.4.1. Choosing a Column on which to Partition Table Rows
      • 4.4.2. Specifying Partitioned Tables
      • 4.4.3. Design Rules for Partitioning Tables
    • 4.5. Replicating Database Tables
      • 4.5.1. Choosing Replicated Tables
      • 4.5.2. Specifying Replicated Tables
    • 4.6. Modifying the Schema
      • 4.6.1. Effects of Schema Changes on Data and Clients
      • 4.6.2. Viewing the Schema
      • 4.6.3. Modifying Tables
      • 4.6.4. Adding and Dropping Indexes
      • 4.6.5. Modifying Partitioning for Tables and Stored Procedures
  • 5. Designing Stored Procedures to Access the Database▶
    • 5.1. How Stored Procedures Work
      • 5.1.1. VoltDB Stored Procedures are Transactional
      • 5.1.2. VoltDB Stored Procedures are Deterministic
    • 5.2. The Anatomy of a VoltDB Stored Procedure
      • 5.2.1. The Structure of the Stored Procedure
      • 5.2.2. Passing Arguments to a Stored Procedure
      • 5.2.3. Creating and Executing SQL Queries in Stored Procedures
      • 5.2.4. Interpreting the Results of SQL Queries
      • 5.2.5. Returning Results from a Stored Procedure
      • 5.2.6. Rolling Back a Transaction
    • 5.3. Installing Stored Procedures into the Database
      • 5.3.1. Compiling, Packaging, and Loading Stored Procedures
      • 5.3.2. Declaring Stored Procedures in the Schema
      • 5.3.3. Partitioning Stored Procedures in the Schema
  • 6. Designing VoltDB Client Applications▶
    • 6.1. Connecting to the VoltDB Database
      • 6.1.1. How Connections To The Cluster Work
      • 6.1.2. Specifying Multiple Servers
    • 6.2. Invoking Stored Procedures
    • 6.3. Invoking Stored Procedures Asynchronously
    • 6.4. Defining Options on a Per-Call Basis
    • 6.5. Closing the Connection
    • 6.6. Handling Errors
      • 6.6.1. Interpreting Execution Errors
      • 6.6.2. Handling Timeouts
      • 6.6.3. Writing Handlers to Interpret Other Errors
    • 6.7. Compiling and Running Client Applications
      • 6.7.1. Starting the Client Application
      • 6.7.2. Running Clients from Outside the Cluster
  • 7. Simplifying Application Development▶
    • 7.1. Using Default Procedures
    • 7.2. Shortcut for Defining Simple Stored Procedures
    • 7.3. Verifying Expected Query Results
    • 7.4. Scheduling Stored Procedures as Tasks
    • 7.5. Directed Procedures: Distributing Transactions to Every Partition
  • 8. Using VoltDB with Other Programming Languages▶
    • 8.1. C++ Client Interface
      • 8.1.1. Writing VoltDB Client Applications in C++
      • 8.1.2. Creating a Connection to the Database Cluster
      • 8.1.3. Invoking Stored Procedures
      • 8.1.4. Invoking Stored Procedures Asynchronously
      • 8.1.5. Interpreting the Results
    • 8.2. JSON HTTP Interface
      • 8.2.1. How the JSON Interface Works
      • 8.2.2. Using the JSON Interface from Client Applications
      • 8.2.3. How Parameters Are Interpreted
      • 8.2.4. Interpreting the JSON Results
      • 8.2.5. Error Handling using the JSON Interface
      • 8.2.6. Managing Client Sessions
    • 8.3. JDBC Interface
      • 8.3.1. Using JDBC to Connect to a VoltDB Database
      • 8.3.2. Using JDBC to Query a VoltDB Database
    • 8.4. Python Client Interface
      • 8.4.1. Creating a Connection to the Database Cluster
      • 8.4.2. Invoking Stored Procedures
      • 8.4.3. Invoking Stored Procedures Asynchronously
      • 8.4.4. Interpreting the Results
      • 8.4.5. Closing the Connections to the Database Cluster
  • 9. Integrating Volt Active Data with AI Agents and Chatbots▶
    • 9.1. Volt Agent Skills
      • 9.1.1. Installing Volt Skills
      • 9.1.2. Using Volt Skills Effectively
    • 9.2. The VoltDB MCP Server
      • 9.2.1. Installing the VoltDB MCP Server
      • 9.2.2. Configuring the MCP Server
      • 9.2.3. How to Use the VoltDB MCP Server
  • 10. Using VoltDB in a Cluster▶
    • 10.1. Starting a Database Cluster
    • 10.2. Defining the Cluster Configuration
    • 10.3. Elastic Scaling to Resize the Cluster
      • 10.3.1. Adding Nodes with Elastic Scaling
      • 10.3.2. Removing Nodes with Elastic Scaling
      • 10.3.3. Configuring How VoltDB Rebalances Nodes During Elastic Scaling
  • 11. Availability▶
    • 11.1. How K-Safety Works
    • 11.2. Enabling K-Safety
      • 11.2.1. What Happens When You Enable K-Safety
      • 11.2.2. Calculating the Appropriate Number of Nodes for K-Safety
    • 11.3. Recovering from System Failures
      • 11.3.1. What Happens When a Node Rejoins the Cluster
      • 11.3.2. Where and When Recovery May Fail
    • 11.4. Avoiding Network Partitions
      • 11.4.1. K-Safety and Network Partitions
      • 11.4.2. Network Fault Protection
  • 12. Active(N) Database Replication▶
    • 12.1. How Database Replication Works
      • 12.1.1. Starting Database Replication
      • 12.1.2. Database Replication, Availability, and Disaster Recovery
      • 12.1.3. Database Replication and Completeness
    • 12.2. Using Active(N) Cross Datacenter Replication
      • 12.2.1. Designing Your Schema for Active Replication
      • 12.2.2. Configuring the Database Clusters
      • 12.2.3. Starting the Database Clusters
      • 12.2.4. Loading a Matching Schema and Starting Replication
      • 12.2.5. Stopping Replication
      • 12.2.6. Example XDCR Configurations
      • 12.2.7. Understanding Conflict Resolution
    • 12.3. Updating the Schema During Replication
      • 12.3.1. Safely Updating the Schema While the Clusters are Paused
      • 12.3.2. Adding and Removing Tables Without Pausing
      • 12.3.3. Using Dynamic Schema Change to Add, Remove, and Modify Table Columns Without Pausing
    • 12.4. Monitoring Database Replication
    • 12.5. Tuning Active(N) to Meet Your Application Needs
      • 12.5.1. The XDCR Workflow
      • 12.5.2. Detecting and Correcting Bottlenecks in the XDCR Workflow
  • 13. Security▶
    • 13.1. How Security Works in VoltDB
    • 13.2. Enabling Authentication and Authorization
    • 13.3. Defining Users and Roles
    • 13.4. Assigning Access to Stored Procedures
    • 13.5. Assigning Access by Function (System Procedures, SQL Queries, and Default Procedures)
    • 13.6. Using Built-in Roles
    • 13.7. Encrypting VoltDB Communication Using TLS/SSL
      • 13.7.1. Creating the TLS/SSL Certificates
      • 13.7.2. Using Certificate Revocation Lists (CRLs)
      • 13.7.3. Configuring TLS/SSL on the VoltDB Server
      • 13.7.4. Configuring Mutual TLS/SSL on the Server and Clients
      • 13.7.5. Using the VoltDB Command Line Utilities with TLS/SSL
      • 13.7.6. Implementing TLS/SSL in the Java Client Applications
      • 13.7.7. Configuring Database Replication (XDCR) With TLS/SSL
      • 13.7.8. Updating TLS/SSL Certificates and Certificate Revocation Lists (CRLs)
    • 13.8. Integrating LDAP Security with VoltDB
      • 13.8.1. Configuring LDAP Security in VoltDB
      • 13.8.2. Configuring VoltDB Security in LDAP
    • 13.9. Integrating Kerberos Security with VoltDB
      • 13.9.1. Installing and Configuring Kerberos
      • 13.9.2. Configuring Java Security
      • 13.9.3. Configuring the VoltDB Servers and Clients
      • 13.9.4. Accessing the Database from the Command Line and the Web
  • 14. Saving & Restoring a VoltDB Database▶
    • 14.1. Performing a Manual Save and Restore of a VoltDB Cluster
      • 14.1.1. How to Save the Contents of a VoltDB Database
      • 14.1.2. How to Restore the Contents of a VoltDB Database Manually
      • 14.1.3. Changing the Cluster Configuration Using Save and Restore
    • 14.2. Scheduling Automated Snapshots
    • 14.3. Tuning the Snapshot Process
    • 14.4. Managing Snapshot Files
    • 14.5. Special Notes Concerning Save and Restore
  • 15. Command Logging and Recovery▶
    • 15.1. How Command Logging Works
    • 15.2. Controlling Command Logging
    • 15.3. Configuring Command Logging for Optimal Performance
      • 15.3.1. Log Size
      • 15.3.2. Log Frequency
      • 15.3.3. Synchronous vs. Asynchronous Logging
      • 15.3.4. Hardware Considerations
  • 16. Streaming Data: Import, Export, and Migration▶
    • 16.1. How Data Streaming Works in VoltDB
      • 16.1.1. Understanding Import
      • 16.1.2. Understanding Export
      • 16.1.3. Understanding Migration
    • 16.2. The Business Case for Streaming Data
      • 16.2.1. Extract, Transform, Load (ETL)
      • 16.2.2. Change Data Capture
      • 16.2.3. Streaming Data Validation
      • 16.2.4. Caching
      • 16.2.5. Archiving
    • 16.3. VoltDB Export Connectors
      • 16.3.1. How Export Works
      • 16.3.2. The File Export Connector
      • 16.3.3. The HTTP Export Connector
      • 16.3.4. The JDBC Export Connector
      • 16.3.5. The Kafka Export Connector
      • 16.3.6. The Elasticsearch Export Connector
    • 16.4. VoltDB Import Connectors
      • 16.4.1. Bulk Loading Data Using VoltDB Standalone Utilities
      • 16.4.2. Streaming Import Using Built-in Import Features
      • 16.4.3. The Kafka Importer
    • 16.5. VoltDB Import Formatters
  • A. Supported SQL DDL Statements▶
    • ALTER STREAM
    • ALTER TABLE
    • ALTER TASK
    • ALTER VIEW
    • CREATE INDEX
    • CREATE PROCEDURE AS
    • CREATE PROCEDURE FROM CLASS
    • CREATE ROLE
    • CREATE STREAM
    • CREATE TABLE
    • CREATE TASK
    • CREATE VIEW
    • DR TABLE
    • DROP INDEX
    • DROP PROCEDURE
    • DROP ROLE
    • DROP STREAM
    • DROP TABLE
    • DROP TASK
    • DROP VIEW
    • PARTITION TABLE
  • B. Supported SQL Statements▶
    • DELETE
    • INSERT
    • MIGRATE
    • SELECT
    • TRUNCATE TABLE
    • UPDATE
    • UPSERT
  • C. SQL Functions▶
    • ABS()
    • APPROX_COUNT_DISTINCT()
    • AREA()
    • ARRAY_ELEMENT()
    • ARRAY_LENGTH()
    • ASTEXT()
    • AVG()
    • BIN()
    • BIT_SHIFT_LEFT()
    • BIT_SHIFT_RIGHT()
    • BITAND()
    • BITNOT()
    • BITOR()
    • BITXOR()
    • CAST()
    • CEILING()
    • CENTROID()
    • CHAR()
    • CHAR_LENGTH()
    • COALESCE()
    • CONCAT()
    • CONTAINS()
    • COS()
    • COT()
    • COUNT()
    • CSC()
    • CURRENT_DATE()
    • CURRENT_TIMESTAMP()
    • DATEADD()
    • DATEDIFF()
    • DAY(), DAYOFMONTH()
    • DAYOFWEEK()
    • DAYOFYEAR()
    • DECODE()
    • DEGREES()
    • DISTANCE()
    • DWITHIN()
    • EXP()
    • EXTRACT()
    • FIELD()
    • FLOOR()
    • FORMAT()
    • FORMAT_CURRENCY()
    • FORMAT_TIMESTAMP()
    • FROM_UNIXTIME()
    • HEX()
    • HOUR()
    • INET6_ATON()
    • INET6_NTOA()
    • INET_ATON()
    • INET_NTOA()
    • ISINVALIDREASON()
    • ISVALID()
    • IS_VALID_TIMESTAMP()
    • LATITUDE()
    • LEFT()
    • LN(), LOG()
    • LOG10()
    • LONGITUDE()
    • LOWER()
    • MAKEVALIDPOLYGON()
    • MASK_CCN()
    • MASK_EMAIL()
    • MASK_INNER()
    • MASK_OUTER()
    • MASK_PAN()
    • MASK_PAN_RELAXED()
    • MASK_PARTIAL()
    • MASK_TEXT()
    • MAX()
    • MAX_VALID_TIMESTAMP()
    • MIGRATING()
    • MIN()
    • MIN_VALID_TIMESTAMP()
    • MINUTE()
    • MOD()
    • MONTH()
    • NOW()
    • NUMINTERIORRINGS()
    • NUMPOINTS()
    • OCTET_LENGTH()
    • OVERLAY()
    • PI()
    • POINTFROMTEXT()
    • POLYGONFROMTEXT()
    • POSITION()
    • POWER()
    • QUARTER()
    • RADIANS()
    • REGEXP_POSITION()
    • REPEAT()
    • REPLACE()
    • RIGHT()
    • ROUND()
    • SEC()
    • SECOND()
    • SET_FIELD()
    • SIGN()
    • SIN()
    • SINCE_EPOCH()
    • SPACE()
    • SQRT()
    • STR()
    • SUBSTRING()
    • SUM()
    • TAN()
    • TIME_WINDOW()
    • TO_TIMESTAMP()
    • TRIM()
    • TRUNCATE()
    • UPPER()
    • VALIDPOLYGONFROMTEXT()
    • WEEK(), WEEKOFYEAR()
    • WEEKDAY()
    • YEAR()
  • D. VoltDB CLI Commands▶
    • csvloader
    • jdbcloader
    • kafkaloader
    • sqlcmd
    • voltadmin
    • voltdb
  • E. YAML Configuration Properties▶
    • E.1. Understanding YAML Syntax
      • E.1.1. YAML Files
      • E.1.2. Dot Notation
    • E.2. YAML Properties for Configuring Volt Databases on Bare Metal
  • F. VoltDB Datatype Compatibility▶
    • F.1. Java and VoltDB Datatype Compatibility
  • G. System Procedures▶
    • @AdHoc
    • @AdjustLogging
    • @Explain
    • @ExplainProc
    • @ExplainView
    • @GetPartitionKeys
    • @GetYamlConfiguration
    • @Metrics
    • @Note
    • @Pause
    • @Ping
    • @Quiesce
    • @Resume
    • @SetYamlConfiguration
    • @Shutdown
    • @SnapshotDelete
    • @SnapshotRestore
    • @SnapshotSave
    • @SnapshotScan
    • @Statistics
    • @StopNode
    • @SwapTables
    • @SystemCatalog
    • @SystemInformation
    • @UpdateClasses
    • @UpdateLogging

Chapter 14. Saving & Restoring a VoltDB Database

There are times when it is necessary to save the contents of a VoltDB database to disk and then restore it. For example, if the cluster needs to be shut down for maintenance, you may want to save the current state of the database before shutting down the cluster and then restore the database once the cluster comes back online. Performing periodic backups of the data can also provide a fallback in case of unexpected failures — either physical failures, such as power outages, or logic errors where a client application mistakenly corrupts the database contents.

VoltDB provides shell commands, system procedures, and an automated snapshot feature that help you perform these operations. The following sections explain how to save and restore a running VoltDB cluster, either manually or automatically.

14.1. Performing a Manual Save and Restore of a VoltDB Cluster

Manually saving and restoring a VoltDB database is useful when you need to modify the database's physical structure or make schema changes that cannot be made to a running database. For example, changing the K-safety value, the number of sites per site, or changing the partitioning column of a partitioned table. The normal way to perform such a maintenance operation using save and restore is as follows:

  1. Stop database activities (using pause).

  2. Use save to write a snapshot of the current data to disk.

  3. Shutdown the cluster.

  4. Make changes to the VoltDB schema, cluster configuration, and/or configuration file as desired.

  5. Reinitialize the database with the modified configuration file, using voltdb init --force.

  6. Restart the cluster in admin mode, using voltdb start --pause.

  7. Optionally, reload the schema and stored procedures (if you are changing the schema).

  8. Restore the previous snapshot.

  9. Restart client activity (using resume).

The key is to make sure that all database activity is stopped before the save and shutdown are performed. This ensures that no further changes to the database are made (and therefore lost) after the save and before the shutdown. Similarly, it is important that no client activity starts until the database has started and the restore operation completes.

Also note that Step #7, reloading the schema, is optional. If you are going to reuse the same schema in a new database instance, the restore operation will automatically load the schema from the snapshot itself. If you want to modify the schema in any way, such as changing indexes or tables and columns, you should load the modified schema before restoring the data from the snapshot. If the database schema is not empty (that is there are tables already defined), only the data is loaded from the snapshot. See Section 14.1.3.2, “Modifying the Database Schema and Stored Procedures” for more information on modifying the schema when restoring snapshots.

Save and restore operations are performed either by calling VoltDB system procedures or using the corresponding voltadmin shell commands. In most cases, the shell commands are simpler since they do not require program code to use. Therefore, this chapter uses voltadmin commands in the examples. If you are interested in programming the save and restore procedures, see Appendix G, System Procedures for more information about the corresponding system procedures.

When you issue a save command, you specify a path where the data will be saved and a unique identifier for tagging the files. VoltDB then saves the current data on each node of the cluster to a set of files at the specified location (using the unique identifier as a prefix to the file names). This set of files is referred to as a snapshot, since it contains a complete record of the database for a given point in time (when the save operation was performed).

The --blocking option lets you specify whether the save operation should block other transactions until it completes. In the case of manual saves, it is a good idea to use this option since you do not want additional changes made to the database during the save operation.

Note that every node in the cluster uses the same absolute path, so the path specified must be valid, must exist on every node, and must not already contain data from any previous saves using the same unique identifier, or the save will fail.

When you issue a restore command, you specify the same absolute path and unique identifier used when creating the snapshot. VoltDB checks to make sure the appropriate save set exists on each node, then restores the data into memory.

14.1.1. How to Save the Contents of a VoltDB Database

To save the contents of a VoltDB database, use the voltadmin save command. The following example creates a snapshot at the path /tmp/voltdb/backup using the unique identifier TestSnapshot.

$ voltadmin save --blocking /tmp/voltdb/backup "TestSnapshot"

In this example, the command tells the save operation to block all other transactions until it completes. It is possible to save the contents without blocking other transactions (which is what automated snapshots do). However, when performing a manual save prior to shutting down, it is normal to block other transactions to ensure you save a known state of the database.

Note that it is possible for the save operation to succeed on some nodes of the cluster and not others. When you issue the voltadmin save command, VoltDB displays messages from each partition indicating the status of the save operation. If there are any issues that would stop the process from starting, such as a bad file path, they are displayed on the console. It is a good practice to examine these messages to make sure all partitions are saved as expected.

Note that it is also possible to issue the voltadmin save command without arguments. In that case the snapshot is saved to the default snapshots folder in the database root directory. This can be useful because the voltdb start command can automatically restore the latest snapshot in that directory as described in the next section.

14.1.2. How to Restore the Contents of a VoltDB Database Manually

The easiest way to restore a snapshot is to let VoltDB do it for you as part of the recover operation. If you are not changing the cluster configuration you can use an automated snapshot or other snapshot saved into the voltdbroot/snapshots directory by simply restarting the cluster nodes using the voltdb start command. With the start action VoltDB automatically starts and restores the most recent snapshot. If command logging is enabled, it also replays any logs after the snapshot. This approach has the added benefit that VoltDB automatically loads the previous schema as well as part of the snapshot.

However, you cannot use voltdb start to restore a snapshot if the physical configuration of the cluster has changed or if you want to restore an earlier snapshot or a snapshot stored in an alternate location. In these cases you must do a manual restore.

To manually restore a VoltDB database from a snapshot previously created by a save operation, you can create a new database instance and use the voltadmin restore command. So, for example, if you modify the configuration, you must re-initialize the root directory with the new configuration file, using the --force flag to overwrite the previous configuration and database content:

$ voltdb init --config=newconfig.yaml --force

Then you can start the reconfigured database, which creates a new empty database. It is also a good idea to start the database in admin mode by including the --pause flag:

$ voltdb start --pause

Finally, you restore the previously saved snapshot using the same pathname and unique identifier used during the save. The following example restores the snapshot created by the example in Section 14.1.1 and resumes normal operation (that is, exits admin mode).

$ voltadmin restore /tmp/voltdb/backup "TestSnapshot"
$ voltadmin resume

As with save operations, it is always a good idea to check the status information displayed by the command to ensure the operation completed as expected.

14.1.3. Changing the Cluster Configuration Using Save and Restore

Most changes to a VoltDB database can be made "on the fly" while the database is running. Adding and removing tables, enabling and disabling database features such as import and export, and adding or updating stored procedures can all be done while the database is active. However, between a save and a restore, it is possible to make changes to the database and cluster configuration that cannot be made on a running cluster. For example, you can:

  • Add or remove nodes from the cluster

  • Modify the schema and/or stored procedures that:

    • Change partitioned tables to replicated and vice versa

    • Change the partitioning column on partitioned tables

    • Add unique indexes to tables with existing data

  • Change the number of sites per host

  • Change the K-safety value

The following sections discuss these procedures in more detail.

14.1.3.1. Adding and Removing Nodes from the Database

To add nodes to the cluster, use the following procedure:

  1. Save the database with the voltadmin save command.

  2. Shutdown and re-initialize the database root directories on each node (including initializing new root directories for the nodes you are adding).

  3. Start the cluster (including the new nodes) specifying the new server count with the --count argument to the voltdb start command.

  4. Restore the database with the voltadmin restore command..

When the snapshot is restored, the database (and partitions) are redistributed over the new cluster configuration.

It is also possible to remove nodes from the cluster using this procedure. However, to make sure that no data is lost in the process, you must copy the snapshot files from the nodes that are being removed to one of the nodes that is remaining in the cluster. This way, the restore operation can find and restore the data from partitions on the missing nodes.

14.1.3.2. Modifying the Database Schema and Stored Procedures

The easiest and recommended way to change the database schema is by sending the appropriate SQL database definition language (DDL) statements to the sqlcmd utility. Similarly you can update the stored procedures on a running database using the LOAD CLASSES and REMOVE CLASSES directives.

However, there are a few changes that cannot be made to a running database,. For example, changing the partitioning column of a table if the table contains data. For these changes, you must use save and restore to change the schema.

To modify the database schema or stored procedures between a save and restore, make the appropriate changes to the source files (that is, the database DDL and the stored procedure Java source files). If you modify the stored procedures, be sure to repackage any Java stored procedures into a JAR file. Then you can:

  1. Save the database with the voltadmin save command.

  2. Shutdown and re-initialize the database root directories on each node.

  3. Start the cluster with the voltdb start command.

  4. Load the modified schema and stored procedures using sqlcmd.

  5. Restore the database contents with the voltadmin restore command.

Three points to note when modifying the database structure before restoring a snapshot are:

  • When existing rows are restored to tables where new columns have been added, the new columns are filled with either the default value (if defined by the schema) or nulls.

  • When existing tables are not included in the modified schema, their associated snapshot data is ignored during the restore.

  • When changing the datatypes of columns, it is possible to decrease the datatype size (for example, going from an INT to an TINYINT). However, if any existing values exceed the capacity of the new datatype (such as an integer value of 5,000 where the datatype has been changed to TINYINT), the entire restore will fail.

If you remove or modify stored procedures (particularly if you change the number and/or datatype of the parameters), you must make sure the corresponding changes are made to client applications as well.

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.