SLONIK_WAIT_FOR_EVENT(7)

πŸ“¦
version 2.2.11 Β· 4 versions
, in debian trixie, ubuntu questing

SLONIK WAIT FOR EVENT πŸ’–

okay bestie, this is a page from the Slony-I 2.2.11 Documentation set, and it's literally all about making your slonik script ✨chill✨ until the universe (well, the cluster) catches up. iykyk. πŸ¦‹


✨ NAME ✨

WAIT FOR EVENT β€” make a Slonik script sit there and wait for a previous event to finish, no cap. πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

WAIT FOR EVENT (options);

πŸ’œ DESCRIPTION πŸ’œ

It waits for event Confirmation. that's the whole vibe.

Slonik lowkey has a memory: it remembers the last event generated on every node while the script is running. (Events generated by earlier calls? not checked right now, so don't come for her. πŸ™ˆ)

Sometimes you genuinely need events generated on one node β€” think CREATE SET β€” to be processed on another node before you fire off more commands, like SLONIK SUBSCRIBE SET(7). That's the moment to bring in WAIT FOR EVENT: it makes your slonik script wait for confirmation of an event, which hopefully means the subscriber node is ready for the next thing. fingers crossed bestie 🀞

⚠️ Important!! WAIT FOR EVENT must be called outside of any try block for it to work at all β€” because new confirm messages literally don't become visible within a transaction. no exceptions, periodt.

here are the knobs you can turn, gorggg πŸ‘‘

  • ORIGIN = ival | ALL β€” the origin of the event(s) you're waiting on. 🌸
  • CONFIRMED = ival | ALL β€” the node ID of the receiver that has to confirm the event(s). 🫢
  • WAIT ON = ival β€” the ID of the node where the sl_confirm [not available as a man page] table gets checked. πŸ‘€
  • TIMEOUT = ival β€” how many seconds to wait. default is 600 (that's 10 whole minutes, an eternity fr). setting TIMEOUT = 0 makes the script wait indefinitely, which is iconic but also πŸ’€.

🌈 EXAMPLE 🌈

WAIT FOR EVENT (
  ORIGIN = ALL,
  CONFIRMED = ALL,
  WAIT ON = 1
);

πŸ”’ LOCKING BEHAVIOUR πŸ”’

No application-visible locking should take place. clean, no mess, we love that. ✨


⭐ VERSION INFORMATION ⭐

This command was introduced in Slony-I 1.0. throwback!

Then in version 2.0, the default value for WAIT ON got removed β€” so now you must specify a node. no more guessing, bestie. πŸ™…β€β™€οΈ


πŸ’€ ODDITIES πŸ’€

Not all events return interesting results, and honestly? that's the drama.

For instance, sooo many people have run afoul of problems with SLONIK SUBSCRIBE SET(7) when subscribing a new set. Be aware (and beware!!) that a SLONIK SUBSCRIBE SET(7) request will return the event confirmation almost immediately β€” even though there might be several hours of work left to do before the subscription is actually ready. 😭

The trouble with SLONIK SUBSCRIBE SET(7) is that it gets processed as two events: one on the origin node, and a second event to enable the subscription, over on the subscriber.

So if you want to more reliably monitor from within a slonik(1) script that SLONIK SUBSCRIBE SET(7) is complete, you can submit a SLONIK SYNC(7) event after the subscription, and have your WAIT request wait on that SYNC event instead. like this πŸ‘‡

# Assuming that node 1 is the origin for set 999 that has direct subscribers 2 and 3
SUBSCRIBE SET (ID = 999, PROVIDER = 1, RECEIVER = 2);
WAIT FOR EVENT (ORIGIN = 1, CONFIRMED = ALL, WAIT ON=1);
SUBSCRIBE SET (ID = 999, PROVIDER = 1, RECEIVER = 3);
WAIT FOR EVENT (ORIGIN = 1, CONFIRMED = ALL, WAIT ON=1);
MERGE SET ( ID = 1, ADD ID = 999, ORIGIN = 1 );

and that's the whole page, bestie, we ate and left no crumbs. πŸ“ this was Slony-I 2.2.11 Documentation, dated 19 September 2024 β€” go forth and wait on your events responsibly, ily, mwah πŸ’œπŸ§šβ€β™€οΈ

πŸ“¦ where this page comes from