Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fnp2X-0005tX-7A for pgsql-hackers@arkaria.postgresql.org; Thu, 09 Aug 2018 17:48:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fnp2T-00058C-CK for pgsql-hackers@arkaria.postgresql.org; Thu, 09 Aug 2018 17:47:57 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fnp2T-00057o-1u for pgsql-hackers@lists.postgresql.org; Thu, 09 Aug 2018 17:47:57 +0000 Received: from mail-qt0-x242.google.com ([2607:f8b0:400d:c0d::242]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1fnp2L-0007b6-H6 for pgsql-hackers@postgresql.org; Thu, 09 Aug 2018 17:47:55 +0000 Received: by mail-qt0-x242.google.com with SMTP id n6-v6so7468759qtl.4 for ; Thu, 09 Aug 2018 10:47:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=QWIO4xWDXJ9wkiiOiUIVVCCrodWT7rds7CqVzFH+H9o=; b=PiKnuoOP3Bk+3w+g2n3YHJNHWLH5s3vpUmKxo00eBNW4IIoj6p8pCVgKqVvq3uLwrF x7MwKNBjDxZQbCvUlpCQyzQuQQXVsCFLS/Db1dIjnzhcKplgSAN7NEF6AYcCFVRJEvnY aEU8lkcvVLsCuLlCCZHMz4tLTziThhFgxA90ycnDtYRyDzHqCUXhaKNeT3TRzIsjKEkJ hfAftnrpGc2iH+qhLuifs1zn/aTNV+GnsWGsW6BodSOKQZ9DFsMGS/O0RrAEpid3ysUu 3P2ucf7zeZCq/wTf4UzkJeeoFYrPvByrmudCwXmvrRK8gG86VeLu29L63bmwPuSXySg5 8y4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=QWIO4xWDXJ9wkiiOiUIVVCCrodWT7rds7CqVzFH+H9o=; b=TVy0tmouDM6gxvN2gkmdlfcTQzhWWqplwfonx/DeSpik40kFuCtPEUevpgxy8nmcsB hv9BwTmGnTx5at0Eae6Gw16QTAXb0P4/znSyADWe1I4Kfe3CVqa4gnHW3O9BZhNW2YLH SaAdRRPo/Bh5l5Al51/jkQnuGkI+zJVILvcmqG5BAAsM42WuVma6aO6G5VM2rUuDlT8M 2c7Dud7NtXT6bUlhkAKaGjZkOWn4n1Mg4sElUOWq3AVTuA15BP7ecVD5EYKLu9X6UoNv Ftvak41zBoI59OKaIDZMQeg3S3UnDcPluF2BaT5dY1Orx8rJxenYNPRRn9oUcNb7TPtQ 4euA== X-Gm-Message-State: AOUpUlEQLuNiyxssTrhyLf9j9ltknkgUUl2SYTOGjzAkZOSzIsK98aLl VOflDz7yFaOhd5G9Z7GT7nKcZQ== X-Google-Smtp-Source: AA+uWPxkxWG5LDzCE0wMzrmkBuHb5JvKdcURgfRNoMJ+CRCJGPVngD+iqikvc8KfbY3RzTw7ZAKaTg== X-Received: by 2002:ac8:117:: with SMTP id e23-v6mr3084696qtg.262.1533836868883; Thu, 09 Aug 2018 10:47:48 -0700 (PDT) Received: from alvin.alvh.no-ip.org ([190.121.29.3]) by smtp.gmail.com with ESMTPSA id z18-v6sm5598393qtz.89.2018.08.09.10.47.48 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 09 Aug 2018 10:47:48 -0700 (PDT) Received: by alvin.alvh.no-ip.org (Postfix, from userid 1000) id 454A6465; Thu, 9 Aug 2018 13:47:46 -0400 (-04) Date: Thu, 9 Aug 2018 13:47:46 -0400 From: Alvaro Herrera To: Tomas Vondra Cc: PostgreSQL-development Subject: Re: logical decoding / rewrite map vs. maxAllocatedDescs Message-ID: <20180809174746.aa6rbpsu4zjipzif@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <738a590a-2ce5-9394-2bef-7b1caad89b37@2ndquadrant.com> User-Agent: NeoMutt/20170306-137-4415bd-dirty (1.8.0) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2018-Aug-09, Tomas Vondra wrote: > I suppose there are reasons why it's done this way, and admittedly the test > that happens to trigger this is a bit extreme (essentially running pgbench > concurrently with 'vacuum full pg_class' in a loop). I'm not sure it's > extreme enough to deem it not an issue, because people using many temporary > tables often deal with bloat by doing frequent vacuum full on catalogs. Actually, it seems to me that ApplyLogicalMappingFile is just leaking the file descriptor for no good reason. There's a different OpenTransientFile call in ReorderBufferRestoreChanges that is not intended to be closed immediately, but the other one seems a plain bug, easy enough to fix. > But wait, there's more - what happens after hitting the limit? We restart > the decoding process, and end up getting this: > > ERROR: 53000: exceeded maxAllocatedDescs (492) while trying to open > file "pg_logical/mappings/map-4000-4eb-1_60DE1E08-5376b5-537c6b" > LOCATION: OpenTransientFile, fd.c:2161 > LOG: 00000: starting logical decoding for slot "s" > DETAIL: streaming transactions committing after 1/6097DD48, reading > WAL from 1/60275848 > LOCATION: CreateDecodingContext, logical.c:414 > LOG: 00000: logical decoding found consistent point at 1/60275848 > DETAIL: Logical decoding will begin using saved snapshot. > LOCATION: SnapBuildRestore, snapbuild.c:1872 > ERROR: XX000: subtransaction logged without previous top-level txn > record Hmm, I wonder if we introduced some bug in f49a80c481f7. > I'd say this implies the "can't open file" is handled in a way that corrupts > the mapping files, making it impossible to restart the decoding. AFAICS the > only option at this point is to drop the subscription and start over. Wow, that seems pretty serious. Clearly that's a different bug that must be fixed. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services