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 1sGg8B-00Fqfi-5b for pgsql-general@arkaria.postgresql.org; Mon, 10 Jun 2024 14:36:19 +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 1sGg89-00Cphw-9A for pgsql-general@arkaria.postgresql.org; Mon, 10 Jun 2024 14:36:18 +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 1sGg88-00Cpho-Uf for pgsql-general@lists.postgresql.org; Mon, 10 Jun 2024 14:36:17 +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 1sGg87-000dtG-74 for pgsql-general@postgresql.org; Mon, 10 Jun 2024 14:36:16 +0000 Received: by mail-ot1-x32f.google.com with SMTP id 46e09a7af769-6f99555c922so898415a34.3 for ; Mon, 10 Jun 2024 07:36:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718030174; x=1718634974; darn=postgresql.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=w3uZlbJpf3mOs0oQx/IadlpPQMGozYfJU5WZtZGa0W0=; b=PtECEAX/r6pwbGt/lyG1REFgbArosa93e9LrpTckHifmLPkuF//NBV90QOKMb2uzxs VWkxSQZ9RKdfUccM8AyzTU+8OZmGadraYHYY79nFEYDulH4o5B8RSHGFpKbYhh9/HbEm Y+OfcBwvJaj1FqQ3XyzpBgCtGPOYh2WDWQJ8jzdsk06Voa49iQE0wUGHvTrxfTyX9HGu wf92m5RS+36j0pU6C9uqMAKbcQDLUf9FWx3Ilr2yoN6+36ZtiYNtOBotwUO85HFdJ9ND jRdPxLuDZKdUZD8kk6yYwG0AO2tARDDt01c5XuUvQxKxA9oe0BmfMfoWZRB8ZEXtmRXo gdTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718030174; x=1718634974; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=w3uZlbJpf3mOs0oQx/IadlpPQMGozYfJU5WZtZGa0W0=; b=Mtq9l6QNu6EGN8+6PGGfcwTeGse01lufLQeV44Muy9OWNeqN0+PDJFfuq+Asou7Xku wZ652rQdwO3aVkVe00iwucTPBJ4kJst+y4RXUcTRyebAQteiM5tKnDvbtOlA1Lo8b1LC rs47uqowsIeIE8gT9OQfIAmzqW43L0vBT0lih2BLQfaiJyF0rNcgZfwXl0PEyGkZ0X8y 9Y75x6PdKiw8wR4VnfGAp5PjHsGU0LzmPGKRB+oB7q+QQ3tNWZYEVlSjrSgGk7Hrh9/i rk6AXa8Rwjd2AM6af9YxJxXI1Pi7hmhEsBxH28LHUnt8udBF+FsZRgWrzulwp0DnbOq1 g1Tg== X-Gm-Message-State: AOJu0YwzUW9YwDmZGFSnjGqfQT0p4FwASw0POJGK0Vqs3mq+bys+Neq5 JBN1//p4Yx4x8IWMezgbNcI2rvCJvnS/JoBSy7imeqYjlsubCScwNWUIv6ZClUQ07Qy+rKdFMT1 6NP7mKBSjvY5cWHbIWN8irSLTEjh24joy X-Google-Smtp-Source: AGHT+IGrjI+ZD4X5uRZk0VYVrDlyMNllKEI9Dvf+BN+jak5xvtJaUGsJA2LdVGBP76mLTxYFpvlCGp1p0qCXwvNmcGY= X-Received: by 2002:a05:6870:420e:b0:254:b455:2bf6 with SMTP id 586e51a60fabf-254b45532cbmr4301775fac.53.1718030174227; Mon, 10 Jun 2024 07:36:14 -0700 (PDT) MIME-Version: 1.0 From: Dominique Devienne Date: Mon, 10 Jun 2024 16:36:03 +0200 Message-ID: Subject: libpq v17 PQsocketPoll timeout is not granular enough To: pgsql-general@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've noticed [that libpq API in v17 beta1][1], and wanted to use it to replace an existing Boost.ASIO-based async polling of the connection's socket, waiting for notifications. The use case being using PostgreSQL LISTEN/NOTIFY for a simple message queue. The code needs to be cross-platform Windows and Linux. My goal would be to eliminate that Boost.ASIO dependency for that, to use just libpq. PQsocketPoll() being based on time_t, it has only second resolution, AFAIK. Despite the [underlying implementation in fe-misc.c][2] supporting at least milliseconds. My use case is clients posting "requests" to the "queue" (i.e. a PostgreSQL table), which trigger NOTIFY messages, waited on by "servers"; and those servers informing back clients via further notifications (on per-request channels) about the processing status of their requests. In that use case, second-resolution on long-lived servers is OK. But OTOH, for the client side, waiting 1s or more to know whether a server picked up their request is "too long / slow". I'd need millisecond timeouts for that. The doc for PQsocketPoll() mentions a different use case for that API. But I think it would a pity if that unreleased API couldn't be made to accomodate sub-second timeouts and more use-cases, like above. Especially given that libpq v17 isn't out yet. I may come late to the game, but hopefully it is not too late. Thoughts? Thanks, --DD [1]: https://www.postgresql.org/docs/17/libpq-connect.html#LIBPQ-PQSOCKETPOLL [2]: https://github.com/postgres/postgres/blob/master/src/interfaces/libpq/fe-misc.c#L1086