Problem:

The client regularly ran large batch-processing jobs. During each run, the batch process was initiated and connected to the database cluster with multiple concurrent streams. However, upon starting the process, both the replication and the batch process failed, displaying the following error: “Could not send data to the client: Connection reset by peer.” Reducing the number of streams by half did not help. As a temporary workaround, other daemon processes that normally run in parallel with the batch process were stopped during the runs.

Process:

Step 1: Initial Investigation

To address this issue, the experts requested the PostgreSQL and Pgpool logs for further investigation.

Step 2: Further Investigation

Further investigation produced the following findings:

  • Connection Reset Error: Connection resets occurred during bulk database processing and affected both logical and physical replication. Initial network checks found no issues, so the database was suspected first.
  • Database Issues: Despite ruling out other components, the exact cause within the database remained unidentified.
  • Network Utilization: Grafana monitoring during an incident showed no significant network anomalies, leaving the error cause unclear.
  • Database Connection Issues: Missing database parameters were suspected of causing dropped connections and Pgpool issues affecting replication.
  • Performance Degradation: Performance improved after running ANALYZE and VACUUM during a process run.

Step 3: Deeper Investigation

The next stage focused on the network:

  • Connection Reset Issue: Connection resets during bulk operations were most likely caused by the network. Extended packet loss monitoring was suggested to diagnose the problem.
  • Network Analysis: More in-depth network analysis with tools like tcpdump was recommended to uncover unusual parameters that might cause connection resets.
  • Subnet Configuration: Pgpool and the database were confirmed to be on the same subnet, but further network analysis was needed.
  • Evidence Gathering: To definitively determine whether the issue was network or PostgreSQL-related, comprehensive evidence collection from both sides was necessary.
  • TCP Zero Window Packets: tcpdump captured TCP zero window packets, pointing to issues with the source or destination machines rather than PostgreSQL.
  • Network Issue: Network problems were impacting application performance as well as logical and streaming replication, with a complex virtual network architecture being a factor.
  • Replication Process: Data was replicated from production to standby databases using streaming and logical replication.
  • Connection Resets: Network issues caused connection resets that affected databases, applications, and replication processes.
  • Upgrading Network Drivers: Upgrading network drivers was planned to address connection resets.
  • Operating System Tuning: OS tuning was suggested for better network, memory, and routing performance.
  • Database Tuning: Pgpool load-balancing configurations were reviewed to identify necessary fine-tuning.

Solution:

The experts found that the issue was not related to the database. The logs pointed to a network issue: not only client connections but also streaming replication connections were being dropped.

Conclusion:

After investigating, the team of experts concluded that the problem wasn’t related to the database. The main issue was with the network; the recommended fixes were to upgrade the system, adjust the network configuration, and update the network drivers.