Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id BCDBD200C46 for ; Wed, 29 Mar 2017 19:25:46 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id BB53F160B95; Wed, 29 Mar 2017 17:25:46 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 0C431160B8A for ; Wed, 29 Mar 2017 19:25:45 +0200 (CEST) Received: (qmail 22197 invoked by uid 500); 29 Mar 2017 17:25:45 -0000 Mailing-List: contact issues-help@aurora.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@aurora.apache.org Delivered-To: mailing list issues@aurora.apache.org Received: (qmail 22181 invoked by uid 99); 29 Mar 2017 17:25:44 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 29 Mar 2017 17:25:44 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 78C50C0A1C for ; Wed, 29 Mar 2017 17:25:44 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -100.002 X-Spam-Level: X-Spam-Status: No, score=-100.002 tagged_above=-999 required=6.31 tests=[RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id C2WBX-8h7wO2 for ; Wed, 29 Mar 2017 17:25:43 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id 3B38760CF7 for ; Wed, 29 Mar 2017 17:25:43 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 53BC5E0710 for ; Wed, 29 Mar 2017 17:25:42 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 9E70B24174 for ; Wed, 29 Mar 2017 17:25:41 +0000 (UTC) Date: Wed, 29 Mar 2017 17:25:41 +0000 (UTC) From: "Zameer Manji (JIRA)" To: issues@aurora.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Assigned] (AURORA-1912) DbSnapShot may remove enum values MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Wed, 29 Mar 2017 17:25:46 -0000 [ https://issues.apache.org/jira/browse/AURORA-1912?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Zameer Manji reassigned AURORA-1912: ------------------------------------ Assignee: Zameer Manji > DbSnapShot may remove enum values > --------------------------------- > > Key: AURORA-1912 > URL: https://issues.apache.org/jira/browse/AURORA-1912 > Project: Aurora > Issue Type: Bug > Reporter: Zameer Manji > Assignee: 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: > {noformat} > try (Connection c = ((DataSource) store.getUnsafeStoreAccess()).getConnection()) { > LOG.info("Dropping all tables"); > try (PreparedStatement drop = c.prepareStatement("DROP ALL OBJECTS")) { > drop.executeUpdate(); > } > {noformat} > However a freshly started leader will have some data in there from preparing the storage: > {noformat} > @Override > @Transactional > protected void startUp() throws IOException { > Configuration configuration = sessionFactory.getConfiguration(); > String createStatementName = "create_tables"; > configuration.setMapUnderscoreToCamelCase(true); > // The ReuseExecutor will cache jdbc Statements with equivalent SQL, improving performance > // slightly when redundant queries are made. > configuration.setDefaultExecutorType(ExecutorType.REUSE); > addMappedStatement( > configuration, > createStatementName, > CharStreams.toString(new InputStreamReader( > DbStorage.class.getResourceAsStream("schema.sql"), > StandardCharsets.UTF_8))); > try (SqlSession session = sessionFactory.openSession()) { > session.update(createStatementName); > } > for (CronCollisionPolicy policy : CronCollisionPolicy.values()) { > enumValueMapper.addEnumValue("cron_policies", policy.getValue(), policy.name()); > } > for (MaintenanceMode mode : MaintenanceMode.values()) { > enumValueMapper.addEnumValue("maintenance_modes", mode.getValue(), mode.name()); > } > for (JobUpdateStatus status : JobUpdateStatus.values()) { > enumValueMapper.addEnumValue("job_update_statuses", status.getValue(), status.name()); > } > for (JobUpdateAction action : JobUpdateAction.values()) { > enumValueMapper.addEnumValue("job_instance_update_actions", action.getValue(), action.name()); > } > for (ScheduleStatus status : ScheduleStatus.values()) { > enumValueMapper.addEnumValue("task_states", status.getValue(), status.name()); > } > for (ResourceType resourceType : ResourceType.values()) { > enumValueMapper.addEnumValue("resource_types", resourceType.getValue(), resourceType.name()); > } > for (Mode mode : Mode.values()) { > enumValueMapper.addEnumValue("volume_modes", mode.getValue(), mode.name()); > } > createPoolMetrics(); > } > {noformat} > 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 (v6.3.15#6346)