aurora-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Zameer Manji (JIRA)" <>
Subject [jira] [Created] (AURORA-1912) DbSnapShot may remove enum values
Date Wed, 29 Mar 2017 17:25:41 GMT
Zameer Manji created AURORA-1912:

             Summary: DbSnapShot may remove enum values
                 Key: AURORA-1912
             Project: Aurora
          Issue Type: Bug
            Reporter: Zameer Manji

The dbnsapshot restore may truncate enum tables and cause referential integrity issues. From
the code it restores from the SQL dump by first dropping all tables:
            try (Connection c = ((DataSource) store.getUnsafeStoreAccess()).getConnection())
    "Dropping all tables");
              try (PreparedStatement drop = c.prepareStatement("DROP ALL OBJECTS")) {

However a freshly started leader will have some data in there from preparing the storage:
  protected void startUp() throws IOException {
    Configuration configuration = sessionFactory.getConfiguration();
    String createStatementName = "create_tables";

    // The ReuseExecutor will cache jdbc Statements with equivalent SQL, improving performance
    // slightly when redundant queries are made.

        CharStreams.toString(new InputStreamReader(

    try (SqlSession session = sessionFactory.openSession()) {

    for (CronCollisionPolicy policy : CronCollisionPolicy.values()) {
      enumValueMapper.addEnumValue("cron_policies", policy.getValue(),;

    for (MaintenanceMode mode : MaintenanceMode.values()) {
      enumValueMapper.addEnumValue("maintenance_modes", mode.getValue(),;

    for (JobUpdateStatus status : JobUpdateStatus.values()) {
      enumValueMapper.addEnumValue("job_update_statuses", status.getValue(),;

    for (JobUpdateAction action : JobUpdateAction.values()) {
      enumValueMapper.addEnumValue("job_instance_update_actions", action.getValue(),;

    for (ScheduleStatus status : ScheduleStatus.values()) {
      enumValueMapper.addEnumValue("task_states", status.getValue(),;

    for (ResourceType resourceType : ResourceType.values()) {
      enumValueMapper.addEnumValue("resource_types", resourceType.getValue(),;

    for (Mode mode : Mode.values()) {
      enumValueMapper.addEnumValue("volume_modes", mode.getValue(),;


Consider the case where we add a new value to an existing enum. This means restoring from
a snapshot will not allow us to have that value in the enum table. 

To fix this we should have a migration for every enum value we add. However to me it seems
that the better idea would be to update the enum tables after we restore from a snapshot.

This message was sent by Atlassian JIRA

View raw message