---
title: "Patching the PostgreSQL JDBC Driver"
description: "Postgres logical replication slots for clients watching low-traffic tables never advance, so the server retains all WAL generated by other tables until disk fills and the node goes read-only."
url: "https://swe.quest/articles/patching-the-postgresql-jdbc-driver-47e9400eaa77f0d2"
canonical: "https://engineering.zalando.com/posts/2023/11/patching-pgjdbc.html"
source: "Zalando Engineering"
published: "2023-11-08"
difficulty: "medium"
kind: "Case study"
reading_minutes: 10
tags: ["postgres","replication","event-driven","jvm","open-source"]
---

# Patching the PostgreSQL JDBC Driver

A post on [Zalando Engineering](https://swe.quest/sources/zalando.md), published 2023-11-08, 10 min read, Case study. Original: [https://engineering.zalando.com/posts/2023/11/patching-pgjdbc.html](https://engineering.zalando.com/posts/2023/11/patching-pgjdbc.html)

## Summary

Postgres logical replication slots for clients watching low-traffic tables never advance, so the server retains all WAL generated by other tables until disk fills and the node goes read-only. Zalando fixed this upstream in PgJDBC: the driver now tracks the last received and last confirmed replication LSNs, and when they match and a KeepAlive message reports a higher server LSN, it confirms that LSN, safely advancing the slot without skipping relevant events. The fix, merged for PgJDBC 42.7.0, removes the need for the common dummy-write workaround and was validated by comparing WAL size graphs before and after a patched Debezium image rollout across hundreds of event streams.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [PostgreSQL](https://swe.quest/tags/postgres.md) (Data & databases)
- [Replication](https://swe.quest/tags/replication.md) (Distributed systems)
- [Event-driven architecture](https://swe.quest/tags/event-driven.md) (Backend & APIs)
- [Java & JVM](https://swe.quest/tags/jvm.md) (Languages)
- [Open source](https://swe.quest/tags/open-source.md) (Engineering practices)

## Prerequisites

- PostgreSQL WAL basics ([easy posts on PostgreSQL](https://swe.quest/tags/postgres.md?difficulty=easy))
- logical replication ([easy posts on Replication](https://swe.quest/tags/replication.md?difficulty=easy))
- change data capture

## Keywords

PgJDBC, Debezium, PostgreSQL logical replication, replication slots, Write-Ahead Log, LSN

## Related posts

- [Contributing to Debezium: Fixing Logical Replication at Scale](https://swe.quest/articles/contributing-to-debezium-fixing-logical-replication-at-scale-9a91b621ec2af98e.md): Zalando Engineering · 2025-12-18 · Hard · 9 min read · PostgreSQL, Event-driven architecture, Replication, Open source, Data pipelines
  Zalando contributed two configuration options to Debezium's PostgreSQL connector, released in 3.4.0.Final.
- [Fan-out from Postgres with Change Data Capture using Debezium and Upstash Redis](https://swe.quest/articles/fan-out-from-postgres-with-change-data-capture-using-debezium-and-upstash-redis-1afcb52ed56a9566.md): Neon · 2024-02-14 · Medium · 9 min read · Event-driven architecture, PostgreSQL, Queues & messaging, Replication
  Streaming committed Postgres changes from the write-ahead log via a logical replication slot avoids the dual-write problem, where an application writes to the database and a message broker separately and can leave them inconsistent.
- [Don't add a read replica until you've read this](https://swe.quest/articles/don-t-add-a-read-replica-until-you-ve-read-this-a990a2b0dc14e87b.md): incident.io · 2026-07-21 · Medium · 18 min read · PostgreSQL, Replication, Consistency models, Go, Scaling
  incident.io moved nearly all Postgres read traffic to a read replica and had to preserve read-after-write consistency without hand-routing each query.
- [A Guide to Logical Replication and CDC in PostgreSQL with Airbyte](https://swe.quest/articles/a-guide-to-logical-replication-and-cdc-in-postgresql-with-airbyte-4e37edf2ac1b986b.md): Neon · 2024-01-11 · Medium · 9 min read · PostgreSQL, Replication, Event-driven architecture, Data pipelines
  PostgreSQL logical replication builds on the write-ahead log: logical decoding turns byte-level WAL records into row-level INSERT/UPDATE/DELETE changes, and replication slots track each subscriber's LSN while retaining WAL until it is consumed.
- [What you get when you think of Postgres storage as a transaction journal](https://swe.quest/articles/what-you-get-when-you-think-of-postgres-storage-as-a-transaction-journal-a74912c90f281399.md): Neon · 2024-05-01 · Medium · 9 min read · PostgreSQL, Storage engines, Replication, Distributed databases
  Neon treats Postgres storage as a transaction journal: the write-ahead log becomes the source of truth instead of a recovery aid.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
