From issues-return-196101-archive-asf-public=cust-asf.ponee.io@flink.apache.org Fri Oct 19 12:01:04 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 2A308180679 for ; Fri, 19 Oct 2018 12:01:04 +0200 (CEST) Received: (qmail 44242 invoked by uid 500); 19 Oct 2018 10:01:03 -0000 Mailing-List: contact issues-help@flink.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@flink.apache.org Delivered-To: mailing list issues@flink.apache.org Received: (qmail 44062 invoked by uid 99); 19 Oct 2018 10:01:03 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 19 Oct 2018 10:01:03 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id D25711A1B4B for ; Fri, 19 Oct 2018 10:01:02 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -109.501 X-Spam-Level: X-Spam-Status: No, score=-109.501 tagged_above=-999 required=6.31 tests=[ENV_AND_HDR_SPF_MATCH=-0.5, KAM_ASCII_DIVIDERS=0.8, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, USER_IN_DEF_SPF_WL=-7.5, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id T414zyGv31ZG for ; Fri, 19 Oct 2018 10:01:01 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id 37E5A5F300 for ; Fri, 19 Oct 2018 10:01:01 +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 D4272E0F39 for ; Fri, 19 Oct 2018 10:01:00 +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 78C352528E for ; Fri, 19 Oct 2018 10:01:00 +0000 (UTC) Date: Fri, 19 Oct 2018 10:01:00 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: issues@flink.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (FLINK-9808) Implement state conversion procedure in state backends MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/FLINK-9808?page=3Dcom.atlassian= .jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D1665= 6559#comment-16656559 ]=20 ASF GitHub Bot commented on FLINK-9808: --------------------------------------- aljoscha commented on a change in pull request #6875: [FLINK-9808] [state b= ackends] Migrate state when necessary in state backends URL: https://github.com/apache/flink/pull/6875#discussion_r226588212 =20 =20 ########## File path: flink-runtime/src/test/java/org/apache/flink/runtime/state/Stat= eBackendMigrationTestBase.java ########## @@ -0,0 +1,775 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied= . + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.flink.runtime.state; + +import org.apache.flink.api.common.JobID; +import org.apache.flink.api.common.state.ValueState; +import org.apache.flink.api.common.state.ValueStateDescriptor; +import org.apache.flink.api.common.typeutils.TypeSerializer; +import org.apache.flink.api.common.typeutils.TypeSerializerSchemaCompatibi= lity; +import org.apache.flink.api.common.typeutils.TypeSerializerSnapshot; +import org.apache.flink.api.common.typeutils.base.IntSerializer; +import org.apache.flink.core.memory.DataInputView; +import org.apache.flink.core.memory.DataOutputView; +import org.apache.flink.runtime.checkpoint.CheckpointOptions; +import org.apache.flink.runtime.checkpoint.StateObjectCollection; +import org.apache.flink.runtime.execution.Environment; +import org.apache.flink.runtime.operators.testutils.DummyEnvironment; +import org.apache.flink.types.StringValue; +import org.apache.flink.util.TestLogger; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + +import java.io.IOException; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.RunnableFuture; + +import static org.junit.Assert.assertEquals; + +/** + * Tests for the {@link KeyedStateBackend} and {@link OperatorStateBackend= } as produced + * by various {@link StateBackend}s. + */ +@SuppressWarnings("serial") +public abstract class StateBackendMigrationTestBase extends TestLogger { + +=09@Rule +=09public final ExpectedException expectedException =3D ExpectedException.= none(); + +=09// lazily initialized stream storage +=09private CheckpointStorageLocation checkpointStorageLocation; + +=09/** +=09 * Different "personalities" of {@link CustomStringSerializer}. Instead= of creating +=09 * different classes we parameterize the serializer with this and +=09 * {@link CustomStringSerializerSnapshot} will instantiate serializers = with the correct +=09 * personality. +=09 */ +=09public enum SerializerVersion { +=09=09INITIAL, +=09=09RESTORE, +=09=09NEW +=09} + +=09/** +=09 * The compatibility behaviour of {@link CustomStringSerializer}. This = controls what +=09 * type of serializer {@link CustomStringSerializerSnapshot} will creat= e for +=09 * the different methods that return/create serializers. +=09 */ +=09public enum SerializerCompatibilityType { +=09=09COMPATIBLE_AS_IS, +=09=09REQUIRES_MIGRATION +=09} + +=09/** +=09 * The serialization timeliness behaviour of the state backend under te= st. +=09 */ +=09public enum BackendSerializationTimeliness { +=09=09ON_ACCESS, +=09=09ON_CHECKPOINTS +=09} + +=09@Test +=09@SuppressWarnings("unchecked") +=09public void testValueStateWithSerializerRequiringMigration() throws Exc= eption { +=09=09CustomStringSerializer.resetCountingMaps(); + +=09=09CheckpointStreamFactory streamFactory =3D createStreamFactory(); +=09=09SharedStateRegistry sharedStateRegistry =3D new SharedStateRegistry(= ); +=09=09AbstractKeyedStateBackend backend =3D createKeyedBackend(In= tSerializer.INSTANCE); + +=09=09ValueStateDescriptor kvId =3D new ValueStateDescriptor<>( +=09=09=09"id", +=09=09=09new CustomStringSerializer( +=09=09=09=09org.apache.flink.runtime.state.StateBackendMigrationTestBase.S= erializerCompatibilityType.REQUIRES_MIGRATION, org.apache.flink.runtime.sta= te.StateBackendMigrationTestBase.SerializerVersion.INITIAL)); =20 Review comment: I think all of them can be shortened. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. =20 For queries about this service, please contact Infrastructure at: users@infra.apache.org > Implement state conversion procedure in state backends > ------------------------------------------------------ > > Key: FLINK-9808 > URL: https://issues.apache.org/jira/browse/FLINK-9808 > Project: Flink > Issue Type: Sub-task > Components: State Backends, Checkpointing > Reporter: Tzu-Li (Gordon) Tai > Assignee: Aljoscha Krettek > Priority: Critical > Labels: pull-request-available > Fix For: 1.7.0 > > > With FLINK-9377 in place and that config snapshots serve as the single so= urce of truth for recreating restore serializers, the next step would be to= utilize this when performing a full-pass state conversion (i.e., read with= old / restore serializer, write with new serializer). > For Flink's heap-based backends, it can be seen that state conversion inh= erently happens, since all state is always deserialized after restore with = the restore serializer, and written with the new serializer on snapshots. > For the RocksDB state backend, since state is lazily deserialized, state = conversion=C2=A0needs to happen for per-registered state on their first acc= ess if the registered new serializer has a different serialization schema t= han the previous serializer. > This task should consist of=C2=A0three parts: > 1. Allow {{CompatibilityResult}} to correctly distinguish between whether= the new serializer's schema is a) compatible with the serializer as it is,= b) compatible after the serializer has been reconfigured, or c) incompatib= le. > 2. Introduce state conversion procedures in the RocksDB state backend. Th= is should occur on the first state access. > 3. Make sure that all other backends no longer do redundant serializer co= mpatibility checks. That is not required because those backends=C2=A0always= perform full-pass state conversions. -- This message was sent by Atlassian JIRA (v7.6.3#76005)