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 1rBoWj-00CUSe-PU for pgsql-hackers@arkaria.postgresql.org; Sat, 09 Dec 2023 04:01:17 +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 1rBoVh-00EYCx-Kf for pgsql-hackers@arkaria.postgresql.org; Sat, 09 Dec 2023 04:00:13 +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 1rBoVh-00EY7m-7g for pgsql-hackers@lists.postgresql.org; Sat, 09 Dec 2023 04:00:13 +0000 Received: from mail-lf1-x133.google.com ([2a00:1450:4864:20::133]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rBoVa-009Vtc-KA for pgsql-hackers@postgresql.org; Sat, 09 Dec 2023 04:00:12 +0000 Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-50bf898c43cso2695560e87.1 for ; Fri, 08 Dec 2023 20:00:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702094404; x=1702699204; darn=postgresql.org; h=content-transfer-encoding:subject:from:to:content-language :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=2eVnJTJgdZv7SXkqJtIJL0EBjz5I6fPH0+eYYd80YG4=; b=K1axfyjAeANJ5c4uVdK+hPjxM0mN0kpWoexXXifnALRQOkfApL/6cCk1qKmMu0WGsI u9Ouv2f8unXXYRed8U7nqYLgLZM3LJownIGKl+FzSnpUmXH68XMwM5lGuY/Gow7Cs46i ZpN/sVZpZjerEZB8CARLvHRdHcIeblu4t9PaYs/00FIxk43/Ml1OTjML1mNo51ju3UQE hfn81ZFSBuSeUgVXTE38CLuBlkjC8AeCKjKD0KDVzb6MCIf4ZqtkZLtIoptzQsggmhOQ tX3w+hvUxPpSH7C6CTAvRbEMRgUaVbbmC8qMRMPR7lgfOoD2nZQygpEcc7uvp97h2joj rvvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702094404; x=1702699204; h=content-transfer-encoding:subject:from:to:content-language :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=2eVnJTJgdZv7SXkqJtIJL0EBjz5I6fPH0+eYYd80YG4=; b=JNNKzyXtbZuIm9oSNlcO+B6xMbjPMS5ChcpiGm3KTs9GSMWr7vJNgsVdaCcHMe+8ca qb5gYx7wb5ANoR8gzNV8Jxie4UjyD8zDxJeu7BksBVgQFrZTeyzyeS3jkwsmTwGrq4yn Ql2DoMXce22UuaaMPt+BBiquMBWEF7MZdcy9V2OLVyvdkntAGDVYiKkom2c7yYh20YZG 5WKhnlmx6ZM4uplRCWXO2ykWQFqwhLxFYDA19euod0zcrUstG7J3IGpm0YH5kv3MIPX5 ZGKS8iOcVZai/+RbX+TSFO91q2bK2nACu262FKu4itkQ4k69JNfjLF0fcopub1M3MQNX pagw== X-Gm-Message-State: AOJu0YwUhi9EdhMEJJeMztdp7fwfL0O1orYIb8xZdpvcbCYfEY7Zhzy7 X84q18GsABLeDtYs8eKd3Z9KpxvbKf8= X-Google-Smtp-Source: AGHT+IHYu4v7AFi2FVvIuUNIm21Kvn592iMm560ZyWpuieogN3Cn86IuZEQp52TX4XxW00ejk9R9zg== X-Received: by 2002:ac2:5f59:0:b0:50b:f300:204 with SMTP id 25-20020ac25f59000000b0050bf3000204mr262028lfz.70.1702094403713; Fri, 08 Dec 2023 20:00:03 -0800 (PST) Received: from [1.0.0.7] ([178.155.18.102]) by smtp.gmail.com with ESMTPSA id m17-20020a195211000000b0050bbdf9616bsm392019lfb.217.2023.12.08.20.00.02 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 08 Dec 2023 20:00:03 -0800 (PST) Message-ID: <290b9ae3-98a2-0896-a957-18d3b60b6260@gmail.com> Date: Sat, 9 Dec 2023 07:00:01 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Content-Language: en-US To: pgsql-hackers From: Alexander Lakhin Subject: How abnormal server shutdown could be detected by tests? Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hello hackers, While studying bug #18158, I've come to the conclusion that the existing testing infrastructure is unable to detect abnormal situations. of some kind. Just a simple example: With Assert(0) injected in walsender (say: sed "s/WalSndDone(send_data)/Assert(0)/" -i src/backend/replication/walsender.c ), I observe the following: $ make -s check -C src/test/recovery PROVE_TESTS="t/012*" t/012_subtransactions.pl .. ok All tests successful. (The same with meson: 1/1 postgresql:recovery / recovery/012_subtransactions OK                3.24s   12 subtests passed) But: $ grep TRAP src/test/recovery/tmp_check/log/* src/test/recovery/tmp_check/log/012_subtransactions_primary.log:TRAP: failed Assert("0"), File: "walsender.c", Line: 2528, PID: 373729 src/test/recovery/tmp_check/log/012_subtransactions_primary.log:TRAP: failed Assert("0"), File: "walsender.c", Line: 2528, PID: 373750 src/test/recovery/tmp_check/log/012_subtransactions_primary.log:TRAP: failed Assert("0"), File: "walsender.c", Line: 2528, PID: 373821 src/test/recovery/tmp_check/log/012_subtransactions_standby.log:TRAP: failed Assert("0"), File: "walsender.c", Line: 2528, PID: 373786 src/test/recovery/tmp_check/log/012_subtransactions_primary.log contains: ... 2023-12-09 03:23:20.210 UTC [375933] LOG:  server process (PID 375975) was terminated by signal 6: Aborted 2023-12-09 03:23:20.210 UTC [375933] DETAIL:  Failed process was running: START_REPLICATION 0/3000000 TIMELINE 3 2023-12-09 03:23:20.210 UTC [375933] LOG:  terminating any other active server processes 2023-12-09 03:23:20.210 UTC [375933] LOG:  abnormal database system shutdown 2023-12-09 03:23:20.211 UTC [375933] LOG:  database system is shut down ... So the shutdown definitely was considered abnormal, but we missed that. With log_min_messages = DEBUG3, I can see in the log: 2023-12-09 03:26:50.145 UTC [377844] LOG:  abnormal database system shutdown 2023-12-09 03:26:50.145 UTC [377844] DEBUG:  shmem_exit(1): 0 before_shmem_exit callbacks to make 2023-12-09 03:26:50.145 UTC [377844] DEBUG:  shmem_exit(1): 5 on_shmem_exit callbacks to make 2023-12-09 03:26:50.145 UTC [377844] DEBUG:  cleaning up orphaned dynamic shared memory with ID 2898643884 2023-12-09 03:26:50.145 UTC [377844] DEBUG:  cleaning up dynamic shared memory control segment with ID 3446966170 2023-12-09 03:26:50.146 UTC [377844] DEBUG:  proc_exit(1): 2 callbacks to make 2023-12-09 03:26:50.146 UTC [377844] LOG:  database system is shut down 2023-12-09 03:26:50.146 UTC [377844] DEBUG:  exit(1) 2023-12-09 03:26:50.146 UTC [377844] DEBUG:  shmem_exit(-1): 0 before_shmem_exit callbacks to make 2023-12-09 03:26:50.146 UTC [377844] DEBUG:  shmem_exit(-1): 0 on_shmem_exit callbacks to make 2023-12-09 03:26:50.146 UTC [377844] DEBUG:  proc_exit(-1): 0 callbacks to make The postmaster process exits with exit code 1, but pg_ctl can't get the code and just reports that stop was completed successfully. Should this be improved? And if yes, how it can be done? Maybe postmaster shouldn't remove it's postmaster.pid when it exits abnormally to let pg_ctl know of it? Best regards, Alexander