From dev-return-95554-archive-asf-public=cust-asf.ponee.io@kafka.apache.org Wed Jun 27 21:23: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 61C9118066B for ; Wed, 27 Jun 2018 21:23:04 +0200 (CEST) Received: (qmail 95061 invoked by uid 500); 27 Jun 2018 19:23:03 -0000 Mailing-List: contact dev-help@kafka.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@kafka.apache.org Delivered-To: mailing list dev@kafka.apache.org Received: (qmail 94953 invoked by uid 99); 27 Jun 2018 19:23: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; Wed, 27 Jun 2018 19:23: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 8C1231A2037 for ; Wed, 27 Jun 2018 19:23:02 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -110.301 X-Spam-Level: X-Spam-Status: No, score=-110.301 tagged_above=-999 required=6.31 tests=[ENV_AND_HDR_SPF_MATCH=-0.5, 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 6OnzCTu90XCX for ; Wed, 27 Jun 2018 19:23: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 35FFB5F542 for ; Wed, 27 Jun 2018 19:23: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 B5B8BE0FD0 for ; Wed, 27 Jun 2018 19:23: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 30B5F23F97 for ; Wed, 27 Jun 2018 19:23:00 +0000 (UTC) Date: Wed, 27 Jun 2018 19:23:00 +0000 (UTC) From: "Shawn Nguyen (JIRA)" To: dev@kafka.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Created] (KAFKA-7110) Windowed changelog keys not deserialized properly by TimeWindowedSerde MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 Shawn Nguyen created KAFKA-7110: ----------------------------------- Summary: Windowed changelog keys not deserialized properly by = TimeWindowedSerde Key: KAFKA-7110 URL: https://issues.apache.org/jira/browse/KAFKA-7110 Project: Kafka Issue Type: Bug Reporter: Shawn Nguyen Fix For: 1.1.0 Currently the TimeWindowedSerde does not deserialize the windowed keys from= a changelog topic properly. There are a few assumptions made in the TimeWi= ndowedDeserializer that prevents the changelog windowed keys from being cor= rectly deserialized. 1) In the from method of WindowKeySchema (called in deserialize in TimeWind= owedDeserializer), we extract the window from the binary key, but we call g= etLong(binaryKey.length -TIMESTAMP_SIZE). However, the changelog for Change= LoggingWindowBytesStore will log the windowed key as: =C2=A0 {noformat} changeLogger.logChange(WindowKeySchema.toStoreKeyBinary(key, timestamp, may= beUpdateSeqnumForDups()), value); {noformat} =C2=A0 In toStoreKeyBinary, we store the key in=C2=A0 {noformat} final ByteBuffer buf =3D ByteBuffer.allocate(serializedKey.length + TIMESTA= MP_SIZE + SEQNUM_SIZE); {noformat} with the seqnum (used for de-duping). So the eventual result is that when w= e deserialize, we do not assume the windowed changelog key has a seq_num, a= nd the window extracted will be gibberish values since the bytes extracted = won't be alligned. The fix here is to introduce a new Serde in WindowSerdes that will handle e= xplicitly, windowed changelog input topic.=C2=A0 =C2=A0 2) In the constructor of TimeWindowedDeserializer, the windowSize is fixed = to Long.MAX_VALUE: =C2=A0 {noformat} // TODO: fix this part as last bits of KAFKA-4468 public TimeWindowedDeseri= alizer(final Deserializer inner) { this(inner, Long.MAX_VALUE); }=20 public TimeWindowedDeserializer(final Deserializer inner, final long win= dowSize) { this.inner =3D inner; this.windowSize =3D windowSize; } {noformat} This will cause the end times to be giberrish when we extract the window si= nce the windowSize is subtracted from the start time in: =C2=A0 {noformat} public static Windowed from(final byte[] binaryKey, final long windo= wSize, final Deserializer deserializer, final String topic) { final byte= [] bytes =3D new byte[binaryKey.length - TIMESTAMP_SIZE]; System.arraycopy(= binaryKey, 0, bytes, 0, bytes.length); final K key =3D deserializer.deseria= lize(topic, bytes); final Window window =3D extractWindow(binaryKey, window= Size); return new Windowed<>(key, window); }=20 private static Window extractWindow(final byte[] binaryKey, final long wind= owSize) { final ByteBuffer buffer =3D ByteBuffer.wrap(binaryKey); final lon= g start =3D buffer.getLong(binaryKey.length - TIMESTAMP_SIZE); return timeW= indowForSize(start, windowSize); } {noformat} So in the new serde, we will make windowSize a constructor param that can b= e supplied. =C2=A0 =C2=A0 -- This message was sent by Atlassian JIRA (v7.6.3#76005)