summaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)Author
2025-04-01Test: skip inaccessible Unix socket directories.Tatsuo Ishii
Commit 182b65bfc allows to use multiple Unix socket directories: /tmp and /var/run/postgresql. However if the system does not have accessible /var/run/postgresql, pgpool_setup fails unless $PGSOCKET_DIR is explicitly set. Instead of failing, this commit allows pgpool_setup to skip inaccessible directories. Backpatch-through: v4.5
2025-03-27Allow regression tests to use multiple socket directories.Taiki Koshino
Author: Bo Peng Tested by Taiki Koshino Backpatch-through: V4.5
2025-03-04Fix sr check and health check to reopen pool_passwd upon reload.Tatsuo Ishii
The streaming replication check and health check process forgot to reopen pool_passwd upon reload. If sr_check_passwd or health_check_passwd is empty string, the password is obtained from pool_passwd. Thus those process read outdated content of pool_passwd upon reload. Backpatch-through: v4.2
2025-03-04Start 4.7 development.Bo Peng
2025-02-27Update sample script comment.Bo Peng
2025-02-26Remove pg_basebackup from the sample follow primary script.Bo Peng
If pg_rewind fails, the safest way for users is to recover manually.
2025-02-10Fix too many log lines produced by streaming replication check.Tatsuo Ishii
The process started to call get_pg_backend_status_from_leader_wd_node() which unconditionally emits log message: LOG: received the get data request from local pgpool-II on IPC interface LOG: get data request from local pgpool-II node received on IPC interface is forwarded to leader watchdog node every sr_check_period seconds, which is annoying. To fix this, an elog line in process_IPC_data_request_from_leader() is downgraded from LOG to DEBUG1. Reported-by: Bo Peng.
2025-02-10Fix bug in heartbeat.Tatsuo Ishii
Following error message was recorded every wd_heartbeat_deadtime since 65dbbe7a0 was committed. 2025-02-10 10:50:37.990: heart_beat_receiver pid 1060625: ERROR: failed to get socket data from heartbeat receive socket list 2025-02-10 10:50:37.990: heart_beat_receiver pid 1060625: DETAIL: select() got timeout, exceed 30 sec(s) The heartbeat receiver waits for heartbeart packet arrives in select(2) until wd_heartbeat_deadtime is expired. I believe the logic is wrong: it should wait forever until the packet arrives. In v4.5 or earlier, the hearbeart receiver waits in recvfrom() without timeout. So give NULL to select's timeout parameter so that it waits forever. Since 65dbbe7a0 is only in master branch, no backpatch is made. Reported by: Peng Bo
2025-02-10Update sample scripts.Bo Peng
This commit includes: - update sample scripts to PostgreSQL 17 - remove archive settings to disable archive mode
2025-01-31Fix per_node_error_log() error message that is printed with two colons.Bo Peng
Patch is created by Umar Hayat.
2025-01-14Test: stabilize 032.dml_adaptive_loadbalanceTatsuo Ishii
Occasionally the test failed due to: ERROR: relation "t2" does not exist LINE 1: SELECT i, 'QUERY ID T1-1' FROM t2; It seems the cause is that newly created table t2 takes sometime to get replicated to standby. So insert "sleep 1" after the table creation. Backpatch-through: v4.2
2025-01-12Fix pool_signal.Tatsuo Ishii
Previously pool_signal did not set SA_RESTART flag. Thus any system calls interrupted by a signal does not restart. Some of our code are prepared so that they restart if a system call is interrupted by a signal. But not sure all places are prepared too. So add the flag. Note, PostgreSQL always uses the flag.
2025-01-05Update pgpool.spec.Bo Peng
2025-01-05Fix compiler warning:Bo Peng
warning: ‘delete_all_cache_on_memcached’ declared ‘static’ but never defined[-Wunused-function]
2025-01-02Update src/tools/pcp/.gitignoreBo Peng
2024-12-16Feature: Allow logging_collector related parameters to be changed by ↵Bo Peng
reloading the Pgpool-II configurations. The following logging_collector related parameters can now be changed by reloading: - log_truncate_on_rotation - log_directory - log_filename - log_rotation_age - log_rotation_size - log_file_mode
2024-12-14Fix yet another query cache bug in streaming replication mode.Tatsuo Ishii
If query cache is enabled and query is operated in extended query mode and pgpool is running in streaming replication mode, an execute message could return incorrect results. This could happen when an execute message comes with a non 0 row number parameter. In this case it fetches up to the specified number of rows and returns "PortalSuspended" message. Pgpool-II does not create query cache for this. But if another execute message with 0 row number parameter comes in, it fetches rest of rows (if any) and creates query cache with the number of rows which the execute messages fetched. Obviously this causes unwanted results later on: another execute messages returns result from query cache which has only number of rows captured by the previous execute message with limited number of rows. Another trouble is when multiple execute messages are sent consecutively. In this case Pgpool-II returned exactly the same results from query cache for each execute message. This is wrong since the second or subsequent executes should return 0 rows. To fix this, new boolean fields "atEnd" and "partial_fetch" are introduced in the query context. They are initialized to false when a query context is created (also initialized when bind message is received). If an execute message with 0 row number is executed, atEnd is set to true upon receiving CommandComplete message. If an execute message with non 0 row number is executed, partial_fetch is set to true and never uses the cache result, nor creates query cache. When atEnd is true, pgpool will return CommandComplete message with "SELECT 0" as a result of the execute message. Also tests for this case is added to the 006.memqcache regression test. Backpatch-through: v4.2 Discussion: [pgpool-hackers: 4547] Bug in query cache https://www.pgpool.net/pipermail/pgpool-hackers/2024-December/004548.html
2024-12-09Fixed an issue where pg_md5 and pg_enc would not update the password file if ↵Bo Peng
a file other than the default value was specified in the pool_passwd parameter. This issue is reported by Sadhuprasad Patro.
2024-12-05Test: fix 006.memqcache regression test.Tatsuo Ishii
4dd7371c2 added test cases. SQL syntax used in the test was not compatible with PostgreSQL 15 or earlier. Backpatch-through: v4.2
2024-12-05Fix query cache bug in streaming replication mode.Tatsuo Ishii
When query cache is enabled and an execute message is sent from frontend, pgpool injects query cache data into backend message buffer if query cache data is available. inject_cached_message() is responsible for the task. But it had an oversight if the message stream from frontend includes more than one sets of bind or describe message before a sync message. It tried to determine the frontend message end by finding a bind complete or a row description message from backend. But in the case, it is possible that these messages do not indicate the message stream end because there are one more bind complete or row description message. As a result the cached message is inserted at inappropriate positron and pgpool mistakenly raised "kind mismatch" error. This commit changes the algorithm to detect the message stream end: compare the number of messages from backend with the pending message queue length. When a message is read from backend, the counter for the number of message is counted up if the message is one of parse complete, bind complete, close complete, command compete, portal suspended or row description. For other message type the counter is not counted up. If the counter reaches to the pending message queue length, we are at the end of message stream and inject the cahced messages. Test cases for 006.memqcache are added. Backpatch-through: v4.2.
2024-12-02Test: add check using netstat.Tatsuo Ishii
Sometimes we see regression errors like: 2024-12-01 13:55:55.508: watchdog pid 27340: FATAL: failed to create watchdog receive socket 2024-12-01 13:55:55.508: watchdog pid 27340: DETAIL: bind on "TCP:50002" failed with reason: "Address already in use" Before starting each regression test, we use "clean_all" script to kill all remaining process. I suspect that this is not enough to release bound ports. So I add netstat command to check whether some ports are remain bound. For not this commit is master branch only.
2024-12-01Test: fix 039.log_backend_messages.Tatsuo Ishii
Commit 6d4106f9c forgot to add pgproto data which is necessary in the test.
2024-11-30Feature: add log_backend_messages.Tatsuo Ishii
When enabled, log protocol messages from each backend. Possible options are "none", "terse" and "verbose". "none" disables the feature and is the default. "verbose" prints the log each time pgpool receives a message from backend. "terse" is similar to verbose except it does not print logs for repeated message to save log lines. If different kind of message received, pgpool prints a log message including the number of the message. One downside of "terse" is, the repeated message will not be printed if the pgpool child process is killed before different kind of message arrives. For testing, 039.log_backend_messages is added. Discussion: [pgpool-hackers: 4535] New feature: log_backend_messages https://www.pgpool.net/pipermail/pgpool-hackers/2024-November/004536.html
2024-11-26Abort SSL negotiation if backend sends an error message.Tatsuo Ishii
In the client side implementation of SSL negotiation (pool_ssl_negotiate_clientserver()), it was possible for a man-in-the-middle attacker to send a long error message to confuse Pgpool-II or client while in the SSL negotiation phase. This commit rejects the negotiation immediately (issue a FATAL error) and exits the session to prevent such an attack. This resembles PostgreSQL's CVE-2024-10977. Backpatch-through: v4.1
2024-11-25Test: adapt 024.cert_auth test to OpenSSL 3.2.Tatsuo Ishii
In the test we check the error message when the target certificate is revoked. Unfortunately the error message from OpenSSL seems to be changed from v3.0 to v3.2. v3.0 or before: "sslv3 alert certificate revoked" v3.2: "ssl/tls alert certificate revoked" So fix is checking only "alert certificate revoked" part.
2024-11-25Fix the watchdog process not reloading configurations.Bo Peng
The reload_config() function in Pgpool-II should send a SIGHUP signal to the watchdog process.
2024-11-24Test: another attempt to fix 024.cert_auth failure on RockyLinux9.Tatsuo Ishii
Renew cert.sh using examples in PostgreSQL docs.
2024-11-24Revert "Test: fix recent 024.cert_auth regression test failure."Tatsuo Ishii
This reverts commit dd5a79aef8081bea74f9be7c4beb54ef34637ec9. The attempt to fix 024.cert_auth regression test failure on RockyLinux9 was not successful.
2024-11-23Test: fix recent 024.cert_auth regression test failure.Tatsuo Ishii
Starting from Thu, 21 Nov 2024 16:11:06 +0900, buildfarm's 024.cert_auth have started failed on RockyLinux9 regardless the Pgpool-II versions or PostgreSQL versions. It seems at the timing the test platform was updated from RockyLinux9.4 to RockyLinux9.5 and openssl version was updated from 3.0 to 3.2 as well. The test firstly revokes the frontend certificate using openssl ca -revoke, and then generate a separate CRL file using openssl ca -gencrl command. I suspect that openssl 3.2 now checks the revoked certificate itself and decides that it is not valid. Let's see how buildfarm reacts.
2024-11-15Fix bug in do_query.Tatsuo Ishii
Upon receiving DataRow packet, it converts the number of fields from network byte order to host byte order. Unfortunately it used htons() for this purpose instead of ntohs(). This is simply wrong. Similarly it used htonl() instead of htohl() while converting the data length from network byte order to host byte order. This is wrong too. But fortunately both ntohs()/htons() and ntohl()/htonl() swap the byte and they bring the same result (i.e. htonl(data_len) == ntohl(data_len). So actually the bug does not hurt anything. However a bug is a bug. This commit fixes them. Backpatch-through: v4.1
2024-11-13Fix authentication failure after updating pool_passwd and reload.Tatsuo Ishii
If pool_hba.conf is disabled, updating pool_passwd was not recognized by pgpool child process even if pgpool reload was performed. The reload processing function check_config_reload() mistakenly assumed that reopening pool_passwd was only necessary when enable_pool_hba is on. Backpatch-through: v4.1 Discussion: https://www.pgpool.net/pipermail/pgpool-general/2024-November/001944.html
2024-11-12Test: add test for COPY FROM STDIN hang.Tatsuo Ishii
This is a follow up commit for commit: ab091663b09ef8c2d0a1841921597948c597444e Add test case using pgproto to existing 076.copy_hang. Backpatch-through: v4.1
2024-11-11Fix COPY hangs.Tatsuo Ishii
During COPY IN state (i.e. COPY FROM STDIN), frontend can send Flush or Sync messages. According to the F/B protocol specification, they should be ignored but Pgpool-II treated as an invalid message and this causes COPY hung. Discussion: https://github.com/pgpool/pgpool2/issues/79 Backpatch-through: v4.1
2024-11-09Fix Pgpool-II child process crash during shutdown.Tatsuo Ishii
It is reported that pgpool child process crashes during shutdown. [pgpool-general: 9261] Re: Segmentation fault during shutdown The actual crash was in close_all_backend_connections(). close_all_backend_connections() was called because on_system_exit registers child_will_go_down(). At the moment it seems pgpool child had just started up and doing pool_init_cp(). The connection pool object had not been completely initialized, that's cause of the crash. To fix this, introduce a new static variable in child.c and set it true when the connection pool object is initialized. In child_will_go_down() it is checked and close_all_backend_connections() is called only when the variable is set to true. Problem reported and analyzed by: Emond Papegaaij Backpatch-through: v4.2 Discussion: https://www.pgpool.net/pipermail/pgpool-general/2024-November/001938.html
2024-11-09Revert "Fix Pgpool-II child process crash during shutdown."Tatsuo Ishii
This reverts commit 25ad9e6d50343e2cbd4dc337803d231c92141021. Per discussion: [pgpool-general: 9265] Re: Segmentation fault during shutdown https://www.pgpool.net/pipermail/pgpool-general/2024-November/001942.html
2024-11-08Fix Pgpool-II child process crash during shutdown.Tatsuo Ishii
It is reported that pgpool child process crashes during shutdown. [pgpool-general: 9261] Re: Segmentation fault during shutdown The actual crash was in close_all_backend_connections(). close_all_backend_connections() was called because on_system_exit registers child_will_ho_down(). At the moment it seems pgpool child had just started up and doing pool_init_cp(). The connection pool object had not been completely initialized, that's cause of the crash. To fix this, just remove the call to close_all_backend_connections() in child_will_ho_down(). Although this will prevent the terminate message ('X') being sent to backend, it should be harmless since backend can take care such a disconnection without a terminate message. Problem reported and analyzed by: Emond Papegaaij Backpatch-through: v4.2 Discussion: https://www.pgpool.net/pipermail/pgpool-general/2024-November/001938.html
2024-11-05Refactor pool_config.l.Tatsuo Ishii
There were unnecessary function exporting. This commit fixes them. Also fixes indentations that did not follow our standards. Since this is not a bug fix, appied to only master branch.
2024-10-26Fix sporadic health check failures due to authentication failure.Tatsuo Ishii
It is reported that health check process fails due to authentication failures. [pgpool-general: 9236] Sporadic health check failures due to authentication failure https://www.pgpool.net/pipermail/pgpool-general/2024-October/001913.html When health_check_password is empty string, health check process looks for the password from pool_passwd file. Problem is, the file descriptor for the file is inherited from parent pgpool process. This means that pgpool main and health check process (possibly multiple process) share the same descriptor, which causes various problem including the issue reported here. To fix the problem, re-open the file when health check process starts so that each health check process owns its own file descriptor. Note that pgpool child process (responsible for frontend sessions) already re-opens the file descriptor and they are related to the issue. Problem reported and analyzed by Emond Papegaaij. Backpatch-through: v4.1 Discussion: https://www.pgpool.net/pipermail/pgpool-general/2024-October/001913.html
2024-10-23Test: add test cases for new "PGPOOL SET CACHE DELETE".Tatsuo Ishii
2024-10-22Optimize query cache invalidation for ALTER ROLE.Tatsuo Ishii
Commit 6b7d585eb1c693e4ffb5b8e6ed9aa0f067fa1b89 invalidates query cache if any ALTER ROLE/USER statement is used. Actually this is an overkill. Because following queries do not affect the privilege of the role. - ALTER ROLE user WITH [ENCRYPTED] PASSWORD - ALTER ROLE user WITH CONNECTION LIMIT So do not invalidate query cache if those commands are used. Backpatch-through: v4.1 Discussion: https://www.pgpool.net/pipermail/pgpool-hackers/2024-October/004532.html
2024-10-21Feature: new PGPOOL SET CACHE DELETE command.Tatsuo Ishii
The new PGPOOl SET command allows to delete query cache by specifying the previous query used to create the query cache entry. example usage is: PGPOOL SET CACHE DELETE 'SELECT * FROM t1;' This command is particularly useful for queries that are not invalidated by the auto cache invalidation feature because the query does not have any reference to tables.
2024-10-21Feature: Import PostgreSQL 17 RC1 new parser.Bo Peng
Major changes of PostgreSQL 17 parser include: - Allow MERGE to use NOT MATCHED BY SOURCE and RETURNING clause: MERGE INTO ... WHEN NOT MATCHED BY SOURCE ... MERGE INTO ... RETURNING ... - Add new COPY option ON_ERROR ignore and LOG_VERBOSITY: COPY ... WITH (ON_ERROR ignore); COPY ... WITH (LOG_VERBOSITY verbose); - Allow to use '*' to specify the COPY FROM options FORCE_NOT_NULL and FORCE_NULL for all columns. COPY ... WITH (FORCE_NOT_NULL *); COPY ... WITH (FORCE_NULL *); - Add EXPLAIN option SERIALIZE and MEMORY EXPLAIN (MEMORY) ... EXPLAIN (ANALYZE, SERIALIZE ...) ... - Allow ALTER TABLE to use SET STATISTICS DEFAULT to set a column to the default statistics target ALTER TABLE ... ALTER COLUMN ... SET STATISTICS DEFAULT; - Allow ALTER TABLE to change a column's generation expression ALTER TABLE ... ALTER COLUMN ... SET EXPRESSION; - Add DEFAULT setting for ALTER TABLE .. SET ACCESS METHOD ALTER TABLE ... SET STATISTICS DEFAULT; - Allow event triggers to use login event: CREATE EVENT TRIGGER ... ON login ... - Add event trigger support for REINDEX.
2024-10-17Fix bug in pcp_invalidate_query_cache.Tatsuo Ishii
Buildfarm reported 006.memqcache failure. This was caused by a mistake in the test script (test.sh). It executes pcp_invalidate_query_cache then compares the results of a query calling current_timestamp which is already in query cache (using /*FORCE QUERY CACHE*/ comment). Since pcp_invalidate_query_cache just places an invalidation request and next query processes it, comparing the result right after execution of "SELECT current_timestamp" with the previous cached result indeed returns an equality and the test failed. To fix this, after pcp_invalidate_query_cache, executes a different query. Also I found the test not only fails, but sometimes causes timeout at my local environment. Inspecting the remaining child process showed that it is likely the SIGINT handler was not executed (variable exit_request was not set). I suspect this is because pool_clear_memory_cache(), which is responsible for actually clearing the query cache, blocks all signal including SIGINT. I think this is the reason why the signal handler for SIGINT is not executed. Since pool_clear_memory_cache() already uses pool_shmem_lock() to protect the operation on query cache, the signal blocking is not necessary. In this commit I just removed calls to POOL_SETMASK2 and POOL_SETMASK.
2024-10-16Enhance comment for POOL_CONNECTION_POOL.info.Tatsuo Ishii
2024-10-14Feature: Add new PCP command to invalidate query cache.Tatsuo Ishii
Previously it was not possible to invalidate query cache without restarting pgpool. This commit adds new PCP command "pcp_invalidate_query_cache" to invalidate query cache without restarting pgpool. Note this command only places a query cache invalidate request on shared the shared memory. The actual invalidation is performed by pgpool child process. The reasons for the PCP process cannot remove cache directly are: 1) the connection handle to memcached server is not managed by PCP process. 2) removing shared memory query cache needs an interlock using pool_shmem_ock() which may not work well on PCP process. Also a function used here (pool_clear_memory_cache()) uses PG_TRY, which is only usable in pgpool child process. If pgpool child process finds such a request, the process invalidates all query cache on the shared memory. If the query cache storage is memcached, then pgpool issues memcached_flush() so that all query cache on memcached are flushed immediately. Note that the timing for pgpool child process to check the invalidation request is after processing current query or response from backend. This means that if all pgpool child process sit idle, the request will not be processed until any of them receives a messages from either frontend or backend. Another note is, about query cache statistics shown by "show pool_cache" command. Since the cache invalidation does not clear the statistics, some of them (num_cache_hits and num_selects) continue to increase even after the cache invalidation. Initializing the statistics at the same could be possible but I am not sure if all users want to do it. Discussion:https://www.pgpool.net/pipermail/pgpool-hackers/2024-October/004525.html
2024-10-03Doc: Fix typos in the documentation and sample configuration file.Bo Peng
2024-09-28[New feature] Force to make query cache.Tatsuo Ishii
Recognize /*FORCE QUERY CACHE*/ SQL statement comment so that any read only SELECT/with queries are cached. This is opposite to /*NO QUERY CACHE*/ comment. This feature should be used carefully. See the manual for more details. Discussion: https://github.com/pgpool/pgpool2/issues/56
2024-09-18Fix pgpool crash when pgpool child process exits.Tatsuo Ishii
When a pgpool child process exits, close_all_backend_connections() is called, which is responsible for closing all connections to backend in the connection pool. It used mistakenly MAIN_CONNECTION macro, which is fine for current active connections but is not good for pooled connections because a main node could be different at the time when the connection pool was created. Fix is using in_use_backend() instead. Reported-by: Emond Papegaaij Backpatch-through: v4.2
2024-09-14Fix resource leaks in pool_memqcache.c.Tatsuo Ishii
These leaks were brought in by commit 6fdba5c33 " Use psprintf() instead of snprintf()." Since the commit was backpatched through 4.1, this needs to be backpatched through 4.1 too. Per Coverity (CID 1559726). Backpatch-through: 4.1.
2024-09-14Fix pool_push_pending_data().Tatsuo Ishii
Fix "insecure data handling". Per Coverity (CID 1559731)