Module yaque::recovery

source ·
Expand description

Recovery utilities for queues left in as inconsistent state, based on “best effort” strategies. Use these functions if you need to automatically recover from a failure.

We offer two different approaches to queue recovery, which may be suitable to different use cases:

  1. Recover with replay (the standard): we can reconstruct a lower bound of the actual state of the queue during the crash, which consists of the maximum of the following two positions:
    • the bottom of the smallest segment still present in the directory.
    • the position indicated in the metadata file.

Since this is a lower bound, some elements may be replayed. If your processing is idempotent, this will not be an issue and you lose no data whatsoever.

  1. Recover with loss: we can also reconstruct an upper bound for the actual state of the queue: the bottom of the second smallest segment in the queue. In this case, the smallest segment is simply erased and the receiver caries on as if nothing has happened. If replays are intolerable, but some data loss is, this might be the right alternative for you. You can limit data loss by constraining the segment size, configuring this option on crate::SenderBuilder.

Functions

  • Guesses the receive metadata for a given queue, using the “with replay” strategy. This equals to the bottom position in the smallest segment present in the directory or the existing receiver metadata, whichever is greater. The reason for this is that the receive metadata is a lower bound of where the receiver actually was and this guess is always lower than that.
  • Guesses the receive metadata for a given queue, using the “with loss” strategy. This equals to the bottom position in the segment after the smallest one present in the directory. This function will substitute the current receive metadata by this guess upon acquiring the receive lock on this queue.
  • Recovers a queue using the “with replay” strategy.
  • Recovers a queue using the “with loss” strategy.
  • Unlocks a .lock file if the owning process does not exist anymore. This function does nothing if the file does not exist.
  • Unlocks a queue in a given directory for receiving. This function returns an error of kind io::ErrorKind::Other when the process listed in the lockfile still exists.
  • Unlocks a queue in a given directory for sending. This function returns an error of kind io::ErrorKind::Other when the process listed in the lockfile still exists.
  • Unlocks a queue in a given directory for both sending and receiving. This function is the combination of unlock_for_sending and unlock_for_receiving.