SLONIK_MERGE_SET(7)
β¨ SLONIK MERGE SET β¨
okay bestie, welcome to the SLONIK MERGE SET(7) page π this is from the Slony-I 2.2.11 documentation and it's lowkey one of the most useful little spells in the whole book, so let's get into it π«Ά
π« NAME π«
MERGE SET β merge Slony-I replication sets together π¦
πΈ SYNOPSIS πΈ
MERGE SET (options);
π DESCRIPTION π
So here's the vibe: you're merging a set of tables and sequences into another one. That's it, that's the whole job β¨
But why, you ask? Because β and this is the iconically annoying part β it is not possible to add tables/sequences to sets that are already subscribed. Literally cannot be done. So this function is the workaround π
Here's the play, step by step, no cap:
- create a temporary set
- add the new objects to that temporary set
- subscribe all the nodes that are currently subscribed to the other set to this new one
- then merge the two together, eliminating the set ID that was being added π
And like, one major heads-up before you go wild: this operation will refuse to be run if the two sets do not have exactly the same set of subscribers. Exactly. Same. Subscribers. No wiggle room π
Now the options, and yes they're all required-shaped, don't skip any:
ID = ivalβ the unique ID of the set that will contain the union of the two formerly separate sets. Like, the surviving set. The main character πADD ID = ivalβ the unique ID of the set whose objects should be transferred into the above set. This one's getting absorbed π«ΆORIGIN = ivalβ the current origin node for both sets β
Under the hood this uses βschemadocmergeset(p_add_id integer, p_set_id integer)β β and nope, that one is not available as a man page. Sorry bestie π
π EXAMPLE π
Here's what it looks like irl:
# Assuming that node 1 is the origin of set 999 that has direct subscribers 2 and 3
SUBSCRIBE SET (ID = 999, PROVIDER = 1, RECEIVER = 2);
SUBSCRIBE SET (ID = 999, PROVIDER = 1, RECEIVER = 3);
MERGE SET ( ID = 1, ADD ID = 999, ORIGIN = 1 );
see how clean that is? subscribed everyone first, then merged. that's the way β¨
π LOCKING BEHAVIOUR π
No application-visible locking should take place. that's it, that's the section, we love a low-drama locking story π§
π DANGEROUS/UNINTUITIVE BEHAVIOUR π
okay this is the part where I hold your hand, bestie π«Ά
Merging takes place based on the configuration on the origin node. That's the whole thing it looks at. So if you request a merge while subscriptions are still being processed, you can cause in-progress subscribers' replication to break π β because they'll be out here looking for configuration for this set, and the merge request has literally deleted that configuration. gone. poof.
Do not be too quick to merge sets. fr fr. let the subscriptions finish. patience is the vibe πΈ
β³ SLONIK EVENT CONFIRMATION BEHAVIOUR β³
Here's the waiting game, and slonik plays it so well:
- Slonik waits for the command submitted to the previous event node to be confirmed on the specified event node before submitting this command β¨
- Slonik will also wait for any in progress subscriptions involving the
ADD IDto be subscribed before submitting theMERGE SETcommand π
so it's genuinely out here protecting you from yourself. icon behaviour, honestly π
π VERSION INFORMATION π
- This command was introduced in Slony-I 1.0.5 β
- In 1.2.1, a race condition was rectified where the merge request would be submitted while subscriptions were still in process on subscribers; it refuses to merge before subscriptions are complete π₯
like, the fix literally built in the "wait for subscriptions" behaviour so you don't have to think about it. ate. periodt π
and that's the whole page, bestie π
this was Slony-I 2.2.11 Documentation, dated 19 September 2024 β mwah, go merge responsibly, and remember: not too quick ππ¦β¨
π¦ where this page comes from
- debian trixie: slony1-2-doc 2.2.11-6
- ubuntu questing: slony1-2-doc 2.2.11-6
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms