22
33A PostgreSQL streaming logical replication client for Haskell.
44
5+ React to database changes in real-time.
6+
57This library is currently _ EXPERIMENTAL_ and is not ready for
68production yet. Developers are encouraged to test out the library,
79add issues, contribute and make it awesome.
810
9- React to database changes in real-time. Enrich data, send
10- notifications, monitor suspicious activity, etc.
11-
1211## Setup
1312
1413In order to use a logical replication client you need to set the
@@ -17,13 +16,6 @@ in your `postgres.conf` file:
1716
1817 wal_level = logical
1918
20- There is a known issue in the experimental release where the
21- ` wal_sender ` process, if it has a timeout set, will time out a
22- replicant client. This will be fixed in a future release. Unless
23- you're trying to fix it, you can turn it off by setting:
24-
25- wal_sender_timeout = 0
26-
2719Then restart your server, log in as ` postgres ` or another super user
2820and check:
2921
@@ -36,7 +28,7 @@ You will also need a user who is
3628"PostgreSQL user role documentation") to use replication features.
3729
3830Then add a database and your user with the ` REPLICATION ` trait to the
39- database, grant all on it if you need to, etc .
31+ database, grant all on it if you need to.
4032
4133We haven't added authorization support yet to the library so make sure
4234in ` pg_hba.conf ` you ` trust ` local connections:
@@ -46,8 +38,7 @@ in `pg_hba.conf` you `trust` local connections:
4638Caveat emptor.
4739
4840You will also need to install the ` wal2json ` plugin for your
49- PostgreSQL server. For example in Ubuntu-like distributions you can
50- just:
41+ PostgreSQL server. For example in Ubuntu-like distributions you can:
5142
5243 $ sudo apt install postgresql-12-wal2json
5344
@@ -107,4 +98,18 @@ The configuration settings are:
10798You don't have to set up triggers for each table with logical
10899replication. You also don't have the message size limitation. That
109100limitation often forces clients to perform a query for each message to
110- fetch the data. We only use one connection.
101+ fetch the data and can use more than one connection. We only use one
102+ connection.
103+
104+ ### What are the trade offs?
105+
106+ This library uses logical replication slots. If your program loses
107+ the connection to the database and cannot reconnect the server will
108+ hold onto WAL files until your program can reconnect and resume the
109+ replication stream. On a busy database, depending on your
110+ configuration, this can eat up disk space quickly.
111+
112+ It's a good idea to monitor your replication slots. If
113+ ` postgresql-replicant ` cannot reconnect to the slot and resume the
114+ stream you may need to have a strategy for dropping the slot and
115+ recreating it once conditions return to normal. Have a strategy.
0 commit comments