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 1sH34i-002TyQ-3Z for pgsql-general@arkaria.postgresql.org; Tue, 11 Jun 2024 15:06:16 +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 1sH34f-007Ef7-Kw for pgsql-general@arkaria.postgresql.org; Tue, 11 Jun 2024 15:06:14 +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 1sH34f-007EeT-2z for pgsql-general@lists.postgresql.org; Tue, 11 Jun 2024 15:06:14 +0000 Received: from mail-ot1-x32f.google.com ([2607:f8b0:4864:20::32f]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sH34b-000oFT-VE for pgsql-general@lists.postgresql.org; Tue, 11 Jun 2024 15:06:12 +0000 Received: by mail-ot1-x32f.google.com with SMTP id 46e09a7af769-6f97a4c4588so1994148a34.2 for ; Tue, 11 Jun 2024 08:06:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718118369; x=1718723169; darn=lists.postgresql.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=H4l3xcnEztBtEcI6VWctAFpZHpJDnEuZsaUNItEyTUk=; b=NfDVJ2pVg7gtwyfuWf+3M0rOD4itHu4aYMfiFLrCQZUMgQ+nvrxrY1NiVHsSuKfRyf 7yAlf2DPfyz9WFgDgI8qjgeC0yswpMHX3JICnzMpAzGq9wktt7PTpXYnceldyT9zp9eG NZKtu1FOlimLuoV9obdKCOPtmJEaS+KvJthy0lhAWmXnafVniuX7bqb+q0VW6Fx+lv7u MJD+nkJaR5UyOXlQbUu7LRm7/QrqPu/7LLFcoEwFHdfUpSU4BJmc8595sDT6/sf3eNV0 tl7+9fR0YFmYDQbzPqmuRF1mBBV+vV8SPqswkZjRKPNd8W8QFsL+joo8KaHllXibeeXN yxPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718118369; x=1718723169; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=H4l3xcnEztBtEcI6VWctAFpZHpJDnEuZsaUNItEyTUk=; b=ts2CgC9mMpFwbcbr196kdPOIVcdSB9q7pEDGEyGxrA8CtINiDFFAeIMRDQBsnuH1GT mwRsPYYaqTF/DD9RHEQz02PUUtGJTDAly/gZULM4tIb5rZl/24greWb5tJMFkACAC54v nJ87VffXq90q63ZD6Ncol7//INeIpwtV7g/kaN6r77MCyy8rQ16j6b8pBCw6yGb6BM17 OWqME74FvigjonXc5GTTPantOUKk2eSFzD++3LYuSI05QsLUkbYA1C78sp0uOKLsKIxA hLmQ9hpHEWk3e1jE7MmL3zGiaoz/nZIVSjFFO16vulZaMqw0MJolPIZIY2a4ck2R8v1O dbEA== X-Gm-Message-State: AOJu0YydjRQIJgQYemlalK/xlU4PciLSog8mNyxMFwF+eCx2LOmyCK8T R61l0TKRW3HjoQLFTou6B2CrMggRK1/8hg1rfPdCes5abLOIj+D5IJ1wCP0MNYRWvuU4XDEGeiz N0m6kdIjkXHZbhQu2QxXwf52xJlOsEe7R X-Google-Smtp-Source: AGHT+IHBv/SoglEWV94P9W3URMc1mVwEdE6iBKvlCgF3ELX+OLRFoC/g+5WiKiXvaDWFt09ZYS/shiezQ3Fy7ta3WN8= X-Received: by 2002:a9d:3e5c:0:b0:6f9:6577:71c3 with SMTP id 46e09a7af769-6f9657775f7mr10686802a34.6.1718118368812; Tue, 11 Jun 2024 08:06:08 -0700 (PDT) MIME-Version: 1.0 From: Dominique Devienne Date: Tue, 11 Jun 2024 17:05:57 +0200 Message-ID: Subject: Unexpected Backend PID reported by Notification To: pgsql-general@lists.postgresql.org Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi. I have a unit test using a single connection, that simulates a client interacting with a server via a PostgreSQL "queue", i.e. a non-writable table with SECURITY DEFINER procedures to mediate writes to that table, with those PROC-initiated updates triggering pg_notify() messages (via an UPDATE trigger). The test is passing, I get all the side-effects and notifications I expect. BUT... For some reason, the backend_pid reported on the notification object itself (i.e. PGnotify::be_pid), is different from the one reported for the (sole) connection the unit test is using (PQbackendPID()). How can that be? Are Stored PROCs running in a different backend? Are Triggers running in a different backend? Any doc pointers to explain this behavior? Thanks. --DD PS: v14 server on RedHat; v16 libpq on Windows PPS: Below's a snippet of my test code, which shows actual PID values: auto perreq_notif = c.notification(); BOOST_REQUIRE(perreq_notif); BOOST_CHECK_EQUAL(perreq_notif.channel(), req.channel()); /* ** In fact I get perreq_notif.backend_pid() == N + c.backend_pid() !!! ** Is the fact the pg_notify() is done from a trigger the reason??? ** e.g. [4053957 != 4053955] BOOST_CHECK_EQUAL(perreq_notif.backend_pid(), c.backend_pid()); */ BOOST_CHECK_EQUAL(perreq_notif.payload(), "...");