Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rwkS1-003x8S-OC for pgsql-hackers@arkaria.postgresql.org; Tue, 16 Apr 2024 15:10:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rwkRy-00497v-GZ for pgsql-hackers@arkaria.postgresql.org; Tue, 16 Apr 2024 15:10:22 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rwkRy-00497m-3U for pgsql-hackers@lists.postgresql.org; Tue, 16 Apr 2024 15:10:22 +0000 Received: from mail-pg1-x52d.google.com ([2607:f8b0:4864:20::52d]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rwkRt-0039L7-RN for pgsql-hackers@lists.postgresql.org; Tue, 16 Apr 2024 15:10:20 +0000 Received: by mail-pg1-x52d.google.com with SMTP id 41be03b00d2f7-5e152c757a5so2509317a12.2 for ; Tue, 16 Apr 2024 08:10:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713280216; x=1713885016; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=c6vRD13YJ4rKibM5oZo8sX2xhbwpuSgCIm63BD3qd8w=; b=Kc/o0KfyK4M43R/8+QzeARBJ6n0KSSf1LERXQP87nEMeJwT367osQwmrXAvIIY729b cJj1PFpNil2UwsUdFe8/+j2BzYCQgx7UNlsJ+CtlgR961pgbuisXxhlo3uH+ozaUVs/l By5Tzpa6GJYg+1L2aYpK4h7ojTQ3VXQwzrq8rkafvqZZzmxjo0IzHMswdTFqENxQCOY+ 0N3WA1UpIPBxfVwzpD+Is4SO0Xk1jhGbjqmoHg31HHgXwMEJ40KyPTNG6d8BcASCNeQT TzK+bSsxLptXIHXbEHZtf0YufIc9CovQjXS8sqtJQZv0znVX+Rcy94FljeRCDbY9Mc/F nNjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713280216; x=1713885016; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=c6vRD13YJ4rKibM5oZo8sX2xhbwpuSgCIm63BD3qd8w=; b=E+Y4l3McXFlnrdpYJTAC8c8MEBMT1pXzLfEir8WC7pD7qUy9Au8/RZjlm2ViCaEUKn icThip9QBCmG4Fb+i0blvM3jVK0kACtijWSY7U8fAc/VtAHHGOd00IQe8lmFYb5gURRf iOWKfzmu2fxzUsgFlBcUCbWZ8k6PHSFRWaxbXAPap77zqivn+1qmNgJsfV7572qNtLOi 8/L6qI3fcQIu1KYLrZpiKpjfzzJvZkqrmGCaxl/6tQiZS+yv9bbg50pAdDVgPHqyZOEn UmDa9ZFE+ZHPAgTmrEqss297SDf/412+0EvWZ3GkOFDfiT+nVuZ/gLf7EOQVxfvs6VGE n95Q== X-Forwarded-Encrypted: i=1; AJvYcCUNHC1GN6ikUyzD5Z27iEtExyELWf2tsxC4VUHao/aKlPPJHGFgQsKznYuS05paCjCPssdKZbqkul7rZULZhOtRz0c+RZMbY1PdV/YeUi6Hkwn2 X-Gm-Message-State: AOJu0Yy6/AgOopgnGxChI+va2NY6vezg4iAa+PV/lmqiyuF6nlopymgI 2OTG7XYOq0MOnkKTGM/MeGe50XqoQfuOG6TeZZMyAi4zEAOJ9VVE8rz/OlgYWBO83ADHGrPszr9 SvJMiQhV/rsROk1W1jNO8GiA96uk= X-Google-Smtp-Source: AGHT+IEwmp0Bk+mqBUR3y3I0jdfuqnI/SQDr+WnWX29X4RguaC5Ft14sXPmL5rni9HxDIp+HYSu59Au9jT5ol6QcJvU= X-Received: by 2002:a17:90a:2d83:b0:2a2:a9af:9197 with SMTP id p3-20020a17090a2d8300b002a2a9af9197mr10356856pjd.3.1713280216042; Tue, 16 Apr 2024 08:10:16 -0700 (PDT) MIME-Version: 1.0 References: <20240327201523.ub4htr6jr4zhcfjs@liskov> In-Reply-To: From: Nazir Bilal Yavuz Date: Tue, 16 Apr 2024 18:10:04 +0300 Message-ID: Subject: Re: Use streaming read API in ANALYZE To: Heikki Linnakangas Cc: Melanie Plageman , PostgreSQL Hackers , jakub.wartak@enterprisedb.com Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On Wed, 3 Apr 2024 at 22:25, Nazir Bilal Yavuz wrote: > > Hi, > > Thank you for looking into this! > > On Wed, 3 Apr 2024 at 20:17, Heikki Linnakangas wrote: > > > > On 03/04/2024 13:31, Nazir Bilal Yavuz wrote: > > > Streaming API has been committed but the committed version has a minor > > > change, the read_stream_begin_relation function takes Relation instead > > > of BufferManagerRelation now. So, here is a v5 which addresses this > > > change. > > > > I'm getting a repeatable segfault / assertion failure with this: > > > > postgres=# CREATE TABLE tengiga (i int, filler text) with (fillfactor=10); > > CREATE TABLE > > postgres=# insert into tengiga select g, repeat('x', 900) from > > generate_series(1, 1400000) g; > > INSERT 0 1400000 > > postgres=# set default_statistics_target = 10; ANALYZE tengiga; > > SET > > ANALYZE > > postgres=# set default_statistics_target = 100; ANALYZE tengiga; > > SET > > ANALYZE > > postgres=# set default_statistics_target =1000; ANALYZE tengiga; > > SET > > server closed the connection unexpectedly > > This probably means the server terminated abnormally > > before or while processing the request. > > > > TRAP: failed Assert("BufferIsValid(hscan->rs_cbuf)"), File: > > "heapam_handler.c", Line: 1079, PID: 262232 > > postgres: heikki postgres [local] > > ANALYZE(ExceptionalCondition+0xa8)[0x56488a0de9d8] > > postgres: heikki postgres [local] > > ANALYZE(heapam_scan_analyze_next_block+0x63)[0x5648899ece34] > > postgres: heikki postgres [local] ANALYZE(+0x2d3f34)[0x564889b6af34] > > postgres: heikki postgres [local] ANALYZE(+0x2d2a3a)[0x564889b69a3a] > > postgres: heikki postgres [local] ANALYZE(analyze_rel+0x33e)[0x564889b68fa9] > > postgres: heikki postgres [local] ANALYZE(vacuum+0x4b3)[0x564889c2dcc0] > > postgres: heikki postgres [local] ANALYZE(ExecVacuum+0xd6f)[0x564889c2d7fe] > > postgres: heikki postgres [local] > > ANALYZE(standard_ProcessUtility+0x901)[0x564889f0b8b9] > > postgres: heikki postgres [local] > > ANALYZE(ProcessUtility+0x136)[0x564889f0afb1] > > postgres: heikki postgres [local] ANALYZE(+0x6728c8)[0x564889f098c8] > > postgres: heikki postgres [local] ANALYZE(+0x672b3b)[0x564889f09b3b] > > postgres: heikki postgres [local] ANALYZE(PortalRun+0x320)[0x564889f09015] > > postgres: heikki postgres [local] ANALYZE(+0x66b2c6)[0x564889f022c6] > > postgres: heikki postgres [local] > > ANALYZE(PostgresMain+0x80c)[0x564889f06fd7] > > postgres: heikki postgres [local] ANALYZE(+0x667876)[0x564889efe876] > > postgres: heikki postgres [local] > > ANALYZE(postmaster_child_launch+0xe6)[0x564889e1f4b3] > > postgres: heikki postgres [local] ANALYZE(+0x58e68e)[0x564889e2568e] > > postgres: heikki postgres [local] ANALYZE(+0x58b7f0)[0x564889e227f0] > > postgres: heikki postgres [local] > > ANALYZE(PostmasterMain+0x152b)[0x564889e2214d] > > postgres: heikki postgres [local] ANALYZE(+0x4444b4)[0x564889cdb4b4] > > /lib/x86_64-linux-gnu/libc.so.6(+0x2724a)[0x7f7d83b6724a] > > /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x85)[0x7f7d83b67305] > > postgres: heikki postgres [local] ANALYZE(_start+0x21)[0x564889971a61] > > 2024-04-03 20:15:49.157 EEST [262101] LOG: server process (PID 262232) > > was terminated by signal 6: Aborted > > I realized the same error while working on Jakub's benchmarking results. > > Cause: I was using the nblocks variable to check how many blocks will > be returned from the streaming API. But I realized that sometimes the > number returned from BlockSampler_Init() is not equal to the number of > blocks that BlockSampler_Next() will return as BlockSampling algorithm > decides how many blocks to return on the fly by using some random > seeds. I wanted to re-check this problem and I realized that I was wrong. I tried using nblocks again and this time there was no failure. I looked at block sampling logic and I am pretty sure that BlockSampler_Init() function correctly returns the number of blocks that BlockSampler_Next() will return. It seems 158f581923 fixed this issue as well. -- Regards, Nazir Bilal Yavuz Microsoft