Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l2OHA-0007yP-7p for pgsql-hackers@arkaria.postgresql.org; Thu, 21 Jan 2021 00:56:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1l2OH6-0000lD-DC for pgsql-hackers@arkaria.postgresql.org; Thu, 21 Jan 2021 00:56:36 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l2OH6-0000l6-1T for pgsql-hackers@lists.postgresql.org; Thu, 21 Jan 2021 00:56:36 +0000 Received: from mail-ed1-x52e.google.com ([2a00:1450:4864:20::52e]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1l2OH1-0002Jh-1F for pgsql-hackers@postgresql.org; Thu, 21 Jan 2021 00:56:34 +0000 Received: by mail-ed1-x52e.google.com with SMTP id bx12so485233edb.8 for ; Wed, 20 Jan 2021 16:56:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=2xppZlGXJcPByt8McAHgZvLe/74W2f2SUiWDrSj6BxU=; b=XyMaLp7NiR+9ngrNx40yLkAoy99T37k53Qvlo2LmG9vRjLbCPEWnFgeBv+5QN2/oYY WxA+XWgJGBAWeBhRyXeDvgo9q6J1Waxl/TGdbNo6NSEsRGcebH3NCDCaPFLZFCeWHZ/j H6ctAH86zw3b+1SMVFy6+XmxJJRwmAttKa4G99rCCyCzCvmhjzFA8MGjb4pWNuPetcv2 rpooEWQLPDvSuSiy1RhR4BvJULF9PaW4lhtAGmDFGHfTzBdoiBpq8jr9Jr/Z1bTinklG QiiWJY9n/ldsI/3odz+v0pzuiaseg9opThmuMUFu/QPU66z5Gu0WrIaebNpdTFeaYCSq pCJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=2xppZlGXJcPByt8McAHgZvLe/74W2f2SUiWDrSj6BxU=; b=TMShjNXdsknVKYstctKYbI3ONS6hwRfgVsCl829st0cW+l5llGAPsTKCLzKRwofMVB zXzUCfZIt85A1tj5PzCQ5Tcw+fQqNd9JcKuz3Up3dIRb5Ubtrz+CCUBOjQiJ1I1OuFM1 fuSVWbW4d7SfbmZiOi27GxCKLm9FoUsGnvDc+0/qCx1ecTyGL+2yEt/h7BiU+AtWWdGP yUzJ+jgCc+/R8eC/c/PL8h83GbY36ntj2YTp66QFOEwiBpQU85SqvYka70HZy73TRRD9 4OidwFY4s0neTgB4jkod7vjT6SkF3lTTalaylZY1dZpSLozEEYivR2A43d/xj1JPvLZT pzBA== X-Gm-Message-State: AOAM530zFrFcE1AY6M1Ofk3TEKJPx0TJ5BYaMX9VT/uzFuqRriQkEl2I CFfIk0fc4iyWxlrEK7398ag4YzFGRa30rqPXQKULuQMrkw5uY8KehhTlywhAneBPRN1E7nLr31B Clskoj6nZISADJRTZjSDyGKfYfJjHl8WegzLCPd03oMKPn2r1w6dTvvn2w+XNS4i9ptht3Z70/J A7umQ5xmL8m3tMvRS9q1/puR3wv29mlA7YXgpjUsQdmMN/mjD+WhRCsU0Ccg9GIfSf18wz5dFVw TSURimUA7Xb+NrOCR9ZqHh3JQZ0mjkQyzP8dg== X-Google-Smtp-Source: ABdhPJxO2nSUjsbefShaM93wXZ8UEfVtdhj2aUcgppn7dUUx2+ZzhpnB/+yCOyu66mQ5XhJ5nPMo2w== X-Received: by 2002:a05:6402:4242:: with SMTP id g2mr9301343edb.103.1611190588994; Wed, 20 Jan 2021 16:56:28 -0800 (PST) Received: from [10.137.0.20] (ip-86-49-253-127.net.upcbroadband.cz. [86.49.253.127]) by smtp.gmail.com with ESMTPSA id n27sm1571208eje.29.2021.01.20.16.56.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 20 Jan 2021 16:56:27 -0800 (PST) Subject: Re: POC: postgres_fdw insert batching To: Zhihong Yu Cc: Amit Langote , "tsunakawa.takay@fujitsu.com" , "Andrey V. Lepikhov" , Tomas Vondra , "pgsql-hackers@postgresql.org" References: <20200628151002.7x5laxwpgvkyiu3q@development> <16fcfd4c-2d5e-67f7-fa69-9b5d119bac52@enterprisedb.com> <9d94c863-ce7c-ea7f-6b84-834c98929e2f@enterprisedb.com> <7e70a11e-cf5d-2e5f-a802-274c5e0e236b@enterprisedb.com> From: Tomas Vondra Message-ID: <3ca9496f-0827-bf21-b709-593de63440a5@enterprisedb.com> Date: Thu, 21 Jan 2021 01:56:25 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-CLOUD-SEC-AV-Info: enterprisedb,google_mail,monitor X-CLOUD-SEC-AV-Sent: true X-Gm-Spam: 0 X-Gm-Phishy: 0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 1/21/21 1:17 AM, Zhihong Yu wrote: > Hi, > The assignment to resultRelInfo is done when junk_filter_needed is true: > >         if (junk_filter_needed) >         { >             resultRelInfo = mtstate->resultRelInfo; > > Should the code for determining batch size access mtstate->resultRelInfo > directly ? > IMO the issue is that code iterates over all plans and moves to the next for each one: resultRelInfo++; so it ends up pointing past the last element, hence the failures. So yeah, either the code needs to move before the loop (per my patch), or we need to access mtstate->resultRelInfo directly. I'm pretty amazed this did not crash during any of the many regression runs I did recently. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company