You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/core_concepts/46_postgres_triggers/index.mdx
+89-1Lines changed: 89 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,7 +18,7 @@ Postgres triggers are not available on the [Cloud](/pricing).
18
18
19
19
Windmill's Postgres trigger feature is built on Postgres's logical replication protocol, which allows changes to a database to be streamed in real time to subscribers. Logical replication provides fine-grained control over what data is replicated by allowing the user to define publications and subscribe to specific changes.
20
20
21
-
####How logical replication works:
21
+
### How logical replication works
22
22
1.**Publications**: Define what changes (e.g., INSERT, UPDATE, DELETE) should be made available for replication. Publications allow you to select specific tables or schemas to track.
23
23
2.**Replication slots**: Ensure that all changes from a publication are retained until they are successfully delivered to the subscriber (e.g., Windmill triggers). This guarantees data reliability and prevents data loss.
24
24
@@ -27,8 +27,96 @@ Windmill uses logical replication to efficiently stream database changes to your
27
27
For more details, see the [Postgres documentation on logical replication](https://www.postgresql.org/docs/current/logical-replication.html).
28
28
For more details, see the [Postgres documentation on logical replication streaming protocol](https://www.postgresql.org/docs/current/protocol-logical-replication.html).
29
29
30
+
31
+
## Requirements
32
+
33
+
Before using Postgres triggers with Windmill, your database must be properly configured for logical replication. The primary requirement is setting the Write-Ahead Log (WAL) level to `'logical'`.
34
+
35
+
### Setting `wal_level` to `logical`
36
+
37
+
You have two options to configure this setting. Both options require a restart of your Postgres instance to take effect.
38
+
39
+
#### Option 1: Using SQL (requires database restart)
40
+
41
+
1. Run the following SQL command to set `wal_level` to `'logical'`:
42
+
43
+
```sql
44
+
ALTER SYSTEM SET wal_level ='logical';
45
+
```
46
+
47
+
2. After executing the command, restart your Postgres instance for the changes to take effect.
48
+
49
+
#### Option 2: Editing the `postgresql.conf` file (requires database restart)
50
+
51
+
1. Locate and open your `postgresql.conf` file. The location of this file may vary depending on your installation.
52
+
53
+
2. Look for the `wal_level` setting. If it's not already present, **add** the following line to the file:
54
+
55
+
```ini
56
+
wal_level = logical
57
+
```
58
+
59
+
If the setting is already there, **update** it to `logical`.
60
+
61
+
3. Save the file and restart your Postgres instance for the changes to take effect.
62
+
63
+
### Verifying Logical Replication
64
+
65
+
You can verify that logical replication is enabled by running the following query:
66
+
67
+
```sql
68
+
SHOW wal_level;
69
+
```
70
+
71
+
This should return:
72
+
73
+
```plaintext
74
+
wal_level
75
+
-----------
76
+
logical
77
+
```
78
+
79
+
### Impact of Enabling Logical Replication
80
+
81
+
Enabling logical replication turns on detailed logging, which is essential for supporting the replication process. Be aware that this will increase the amount of data written to the Write-Ahead Log (WAL). Typically, you can expect a 10% to 30% increase in the amount of data written to the WAL, depending on the volume of write activity in your database.
82
+
83
+
---
84
+
85
+
## Additional Configuration for Logical Replication
86
+
87
+
For logical replication to work properly, you need to configure additional parameters in your `postgresql.conf` file. These parameters control the number of replication processes and slots available for replication. Both settings require a restart of your Postgres instance to take effect.
88
+
89
+
#### `max_wal_senders`
90
+
91
+
The `max_wal_senders` setting determines the maximum number of **walsender** processes that can run concurrently. A **walsender** is responsible for sending the Write-Ahead Log (WAL) data to subscribers for logical replication. The default value is 10, but you can increase this based on your replication needs.
92
+
93
+
```ini
94
+
#max_wal_senders = 10 # max number of walsender processes (change requires restart)
95
+
```
96
+
97
+
-**Impact on Triggers**: Each active trigger in logical replication will use a **walsender** process. So, if `max_wal_senders` is set to 10, only 10 active triggers can be used at the same time. If you reach this limit, you will need to increase the `max_wal_senders` value to accommodate more active triggers.
98
+
99
+
#### `max_replication_slots`
100
+
101
+
The `max_replication_slots` setting determines how many **replication slots** can be created. Replication slots are used to maintain state for each logical replication subscription. This setting also limits the number of triggers that can be created for logical replication.
102
+
103
+
```ini
104
+
#max_replication_slots = 10 # max number of replication slots (change requires restart)
105
+
```
106
+
107
+
-**Impact on Trigger Creation**: You can only create as many triggers as there are replication slots available. So if `max_replication_slots` is set to 10, you will be able to create a maximum of 10 triggers. If you need more triggers, you will need to increase the `max_replication_slots` value.
108
+
109
+
### Summary of Limits
110
+
111
+
-**Active triggers**: The number of active triggers you can have is limited by `max_wal_senders`. If you set `max_wal_senders` to 10, only 10 active triggers can be running simultaneously.
112
+
113
+
-**Trigger creation**: The number of triggers you can create is limited by `max_replication_slots`. If you set `max_replication_slots` to 10, you can only create 10 triggers in total.
114
+
30
115
---
31
116
117
+
### Final Considerations
118
+
119
+
When configuring these settings, make sure to account for the number of active triggers and replication slots needed for your application. If you expect to have many triggers or high replication activity, you may need to increase both `max_wal_senders` and `max_replication_slots`.
32
120
## How to use
33
121
Learn how to set up and configure Postgres triggers in Windmill through these key steps.
Copy file name to clipboardExpand all lines: docs/getting_started/8_triggers/index.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -271,7 +271,7 @@ Windmill can connect to WebSocket servers and trigger runnables (scripts, flows)
271
271
272
272
### Postgres triggers
273
273
274
-
Windmill can connect to postgres database servers and trigger runnables (scripts, flows) when a message is received.
274
+
Windmill can connect to a [Postgres](https://www.postgresql.org/)database and trigger runnables (scripts, flows) in response to database transactions (INSERT, UPDATE, DELETE) on specified tables, schemas, or the entire database.
Copy file name to clipboardExpand all lines: docs/script_editor/settings.mdx
+12Lines changed: 12 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -244,6 +244,18 @@ Windmill can connect to WebSocket servers and trigger runnables (scripts, flows)
244
244
/>
245
245
</div>
246
246
247
+
### Postgres
248
+
249
+
Windmill can connect to a [Postgres](https://www.postgresql.org/) database and trigger runnables (scripts, flows) in response to database transactions (INSERT, UPDATE, DELETE) on specified tables, schemas, or the entire database.
250
+
251
+
<divclassName="grid grid-cols-2 gap-6 mb-4">
252
+
<DocCard
253
+
title="Postgres triggers"
254
+
description="Trigger scripts and flows from postgres database servers."
255
+
href="/docs/core_concepts/postgres_triggers"
256
+
/>
257
+
</div>
258
+
247
259
### Kafka
248
260
249
261
Windmill can connect to Kafka brokers and trigger scripts or flows when messages are received on specific topics. This enables real-time processing of events from your Kafka ecosystem.
0 commit comments