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 90212200CBD for ; Thu, 22 Jun 2017 06:12:09 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 8E9B3160BF0; Thu, 22 Jun 2017 04:12:09 +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 D89CD160BD5 for ; Thu, 22 Jun 2017 06:12:08 +0200 (CEST) Received: (qmail 60500 invoked by uid 500); 22 Jun 2017 04:12:07 -0000 Mailing-List: contact issues-help@drill.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@drill.apache.org Delivered-To: mailing list issues@drill.apache.org Received: (qmail 60491 invoked by uid 99); 22 Jun 2017 04:12:07 -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; Thu, 22 Jun 2017 04:12:07 +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 219441A7A10 for ; Thu, 22 Jun 2017 04:12:07 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -99.202 X-Spam-Level: X-Spam-Status: No, score=-99.202 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, 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 ocuqEjVfxj_b for ; Thu, 22 Jun 2017 04:12:06 +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 11FE15F3A1 for ; Thu, 22 Jun 2017 04:12:06 +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 05B88E0069 for ; Thu, 22 Jun 2017 04:12:04 +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 0B13C2193F for ; Thu, 22 Jun 2017 04:12:01 +0000 (UTC) Date: Thu, 22 Jun 2017 04:12:00 +0000 (UTC) From: "Paul Rogers (JIRA)" To: issues@drill.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (DRILL-5602) Vector corruption when allocating a repeated, variable-width vector MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Thu, 22 Jun 2017 04:12:09 -0000 [ https://issues.apache.org/jira/browse/DRILL-5602?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Paul Rogers updated DRILL-5602: ------------------------------- Summary: Vector corruption when allocating a repeated, variable-width vector (was: Vector corruption when allocating a repeated map vector) > Vector corruption when allocating a repeated, variable-width vector > ------------------------------------------------------------------- > > Key: DRILL-5602 > URL: https://issues.apache.org/jira/browse/DRILL-5602 > Project: Apache Drill > Issue Type: Bug > Affects Versions: 1.10.0 > Reporter: Paul Rogers > Assignee: Paul Rogers > Fix For: 1.11.0 > > > The query in DRILL-5513 highlighted a problem described in DRILL-5594: that the external sort did not properly allocate its spill batch vectors, and instead allowed them to grow by doubling. While fixing that issue, a new issue became clear. > The method to allocate a repeated map vector, however, has a serious bug, as described in DRILL-5530: value vectors do not zero-fill the first allocation for a vector (though subsequent reallocs are zero-filled.) > If the code worked correctly, here is the behavior when writing to the first element of the list: > * Access the offset vector at offset 0. Should be 0. > * Write the new value at that offset. Since the first offset is 0, the first value is written at 0 in the value vector. > * Write into offset 1 the value at offset 0 plus the length of the new value. > But, the offset vector is not initialized to zero. Instead, offset 0 contains the value 16 million. Now: > * Access the offset vector at offset 0. Value is 16 million. > * Write the new value at that offset. Write at position 16 million. This requires growing the value vector from its present size to 16 MB. > The problem is here in {{RepeatedMapVector}}: > {code} > public void allocateOffsetsNew(int groupCount) { > offsets.allocateNew(groupCount + 1); > } > {code} > Notice that there is no code to set the value at offset 0. > Then, in the {{UInt4Vector}}: > {code} > public void allocateNew(final int valueCount) { > allocateBytes(valueCount * 4); > } > private void allocateBytes(final long size) { > ... > data = allocator.buffer(curSize); > ... > {code} > The above eventually calls the Netty memory allocator, which explicitly states that, for performance reasons, it does not zero-fill its buffers. > The code works in small tests because the new buffer comes from Java direct memory, which *does* zero-fill the buffer. -- This message was sent by Atlassian JIRA (v6.4.14#64029)