Why is two-phase commit better than naive master-slave replication?

In the context of a distributed database, I’m trying to understand why 2PC (as described in e.g. https://www.cs.princeton.edu/courses/archive/fall16/cos418/docs/L6-2pc.pdf) is better than the following hypothetical protocol between a client, master, and slave:

  • client tells master to commit
  • master commits it
  • master tells client the commit succeeded
  • master tells slave to replicate the commit. If the slave fails, master keeps on trying until it succeeds and gets the slave caught up on all edits.

This seems to me to satisfy the same properties as 2PC:

  • Safety: If the master commits, the slave will also eventually commit. If the slave commits, the master must have committed first. I suppose an advantage of 2PC is that if a participant fails before starting the commit, the transaction will be failed instead of only committing on the TC. However, in the proposed protocol, the commit on the master still eventually gets to the slave.
  • Liveness: This protocol does not hang.
  • Both rely on the master / TC durably recording the decision to commit. Both assume failed slaves / participants eventually wake up and catch up with the master / TC.
  • Both fail if the master / TC goes down.
  • In both protocols, it’s possible to have temporary inconsistencies where the master / TC has finalized a decision, but the slaves / participants haven’t yet committed.

It seems to me that the key theoretical difference in 2PC is that the participant (slave) can vote “no” to the commit, as opposed to merely temporarily failing. That would break the conclusion above where the slave eventually catches up. However, I don’t see why the slave would need to vote “no” in the first place. Given the assumption that the slave / participant does not permanently fail, it seems it should either vote “yes” or fail to respond. (Unlike the bank account example, I expect the slave to blindly replicate the master.)

Distilling all this down, it seems to me that 2PC’s assumption that participants don’t permanently fail makes it unnecessary to give participants a chance to vote “no” in the “prepare” phase.

What am I missing here? Presumably there’s some advantage to 2PC over the above that I’m not understanding, since 2PC is actually used to build distributed databases.

  • Am I incorrect in concluding that a slave shouldn’t need to explicitly vote “no”, as opposed to temporarily failing? (I’m only talking about the data replication use case, rather than the bank account example.)
  • Given the same assumptions as 2PC, and assuming slaves only say “success” or “try again”, is there some guarantee 2PC offers that the naive replication above doesn’t?

For the purpose of the question, I’d like to ignore practicalities, unless they’re critical to the answer. In particular, I’d like to ignore things that could be interpreted as being disallowed by the no-permanent-failure assumption, such as disk full, slave mis-configured, slave corrupt, operator error, buggy software, etc.

Can I install Metasploitable 2 on a machine other than the one running Kali Linux?

I use a kind of POTATO LAPTOP with highly limited resources so when I installed Kali Linux I simply ruled out the idea of using a Virtual Machine (running an OS on an OS is resource-heavy, isnt it?).
Now, I want to install Metaspoitable 2:
1. Can I install it without a VM? (Probably I could not and maybe I should not)
2. Since I can not install Kali on my laptop in a VM (i don’t want many kali, that’s again a waste of space and resources), is there a VM that could be installed in a installed (not in VM) Kali LInux system? (like running metasploitable in VM along with Kali Linux as the base OS) – Maybe that does not make sense at all ๐Ÿ™

Is it easier to wake a character from ‘mundane’ sleep than from ‘magically induced’ sleep?

In DnD 5e, when a character is affected by the spell Sleep, they are:

‘unconscious until [either] the spell ends, the sleeper takes damage, or someone uses an action to shake or slap the sleeper awake.’ (SRD p.180)

For parallel stipulations, see also the spells Eyebite and Symbol, and the draconic Sleep Breath ability.

And, an unconscious person:

‘canโ€™t move or speak, and is unaware of its surroundings'(SRD p.359)

So in summary, the only ways to wake up a creature afflicted by magical sleep (with the exception of the high level spell ‘Prison’) are:

  1. to end the spell affecting them;
  2. to do damage to them; or
  3. for another character to use their action to physically wake them.

Things like loud noises, or flashing lights, which might normally be considered to wake a person, in real life, are (RAW) ineffective because they are considered to be ‘unaware of their surroundings’.

RAW, does it require the same level of intervention to wake someone from a mundane sleep, as from a magical one?

Obviously, mundane sleepers are not under the affect of a spell, so can’t be woken by the spell ending. But, is anything else different?

  1. Are characters that are mundanely asleep considered to be Unconscious in the same way as characters that are magically asleep (i.e. immune to the impact of light and noise)?

  2. Are there any ways to wake someone from a mundane sleep other than doing damage to them or using an action?

In my own research, I have found that the Wizard and Ranger spell Alarm is able to wake its sleeping caster (SRD p.114). However, this an example of the sleeper waking themselves, rather than being woken by something external. It also has a very niche application to the broader question of ‘how can I wake mundanely sleeping people?’.

In this question I am interested only in waking people prematurely from their sleep (ie. being disturbed during their sleep).

An in-game reason for waking characters would be the sentry trying to alert the PCs to a night-time ambush upon their camp. In the past I have treated sleeping PCs as ‘surprised’ in the first round of combat but woken by the sentry’s shouting, and able to act in the second round. I now wonder if this was not the correct way to manage the situation.

How can this Line-Breaking algorithm consider spaces as having width different than 1.0?

The Divide & Conquer Algorithm for Line-Breaking described here is given below, both in Python and in Dart (which is similar to Java/C#).

Line-breaking is also known as “line wrap”, “word wrap”, or “paragraph formation”, and this algorithm is used for achieving minimum raggedness.

This algorithm works, but it considers each space as having exactly width = 1.0 .

My Question:

How can I modify this algorithm so that it ignores spaces? In other words, make it consider spaces as having width 0.0? (or it would also work for me if I could define any width I wanted for the spaces, including 0.0).

Python Implementation:

def divide(text, width):     words = text.split()     count = len(words)     offsets = [0]     for w in words:         offsets.append(offsets[-1] + len(w))      minima = [0] + [10 ** 20] * count     breaks = [0] * (count + 1)      def cost(i, j):         w = offsets[j] - offsets[i] + j - i - 1         if w > width:             return 10 ** 10         return minima[i] + (width - w) ** 2      def search(i0, j0, i1, j1):         stack = [(i0, j0, i1, j1)]         while stack:             i0, j0, i1, j1 = stack.pop()             if j0 < j1:                 j = (j0 + j1) // 2                 for i in range(i0, i1):                     c = cost(i, j)                     if c <= minima[j]:                         minima[j] = c                         breaks[j] = i                 stack.append((breaks[j], j+1, i1, j1))                 stack.append((i0, j0, breaks[j]+1, j))      n = count + 1     i = 0     offset = 0     while True:         r = min(n, 2 ** (i + 1))         edge = 2 ** i + offset         search(0 + offset, edge, edge, r + offset)         x = minima[r - 1 + offset]         for j in range(2 ** i, r - 1):             y = cost(j + offset, r - 1 + offset)             if y <= x:                 n -= j                 i = 0                 offset += j                 break         else:             if r == n:                 break             i = i + 1      lines = []     j = count     while j > 0:         i = breaks[j]         lines.append(' '.join(words[i:j]))         j = i     lines.reverse()     return lines 

Dart implementation:

class MinimumRaggedness {    /// Given some [boxWidths], break it into the smallest possible number   /// of lines such as each line has width not larger than [maxWidth].   /// It also minimizes the difference between width of each line,   /// achieving a "balanced" result.   /// Spacing between boxes is 1.0.   static List<List<int>> divide(List<num> boxWidths, num maxWidth) {      int count = boxWidths.length;     List<num> offsets = [0];      for (num boxWidth in boxWidths) {       offsets.add(offsets.last + min(boxWidth, maxWidth));     }      List<num> minimum = [0]..addAll(List<num>.filled(count, 9223372036854775807));     List<int> breaks = List<int>.filled(count + 1, 0);      num cost(int i, int j) {       num width = offsets[j] - offsets[i] + j - i - 1;       if (width > maxWidth)         return 9223372036854775806;       else         return minimum[i] + pow(maxWidth - width, 2);     }      void search(int i0, int j0, int i1, int j1) {       Queue<List<int>> stack = Queue()..add([i0, j0, i1, j1]);        while (stack.isNotEmpty) {         List<int> info = stack.removeLast();         i0 = info[0];         j0 = info[1];         i1 = info[2];         j1 = info[3];          if (j0 < j1) {           int j = (j0 + j1) ~/ 2;            for (int i = i0; i < i1; i++) {             num c = cost(i, j);             if (c <= minimum[j]) {               minimum[j] = c;               breaks[j] = i;             }           }            stack.add([breaks[j], j + 1, i1, j1]);           stack.add([i0, j0, breaks[j] + 1, j]);         }       }     }      int n = count + 1;     int i = 0;     int offset = 0;      while (true) {       int r = min(n, pow(2, i + 1));       int edge = pow(2, i) + offset;       search(0 + offset, edge, edge, r + offset);       num x = minimum[r - 1 + offset];        bool flag = true;       for (int j = pow(2, i); j < r - 1; j++) {         num y = cost(j + offset, r - 1 + offset);         if (y <= x) {           n -= j;           i = 0;           offset += j;           flag = false;           break;         }       }        if (flag) {         if (r == n) break;         i = i + 1;       }     }      int j = count;      List<List<int>> indexes = [];      while (j > 0) {       int i = breaks[j];       indexes.add(List<int>.generate(j - i, (index) => index + i));       j = i;     }      return indexes.reversed.toList();   } } 

Can you get “Flurry of Blows” (or “Decisive Strike”) from a source other than Monk?

Closely related to this question; I want both Flurry of Blows and Decisive Strike on the same character. Decisive Strike as the main combat strategy for the build, and Flurry of Blows because it’s a requirement for all the feats I can find that would let me Decisive Strike with the weapon I want to use (mind blade, though short sword or longsword would also work).

Are there any classes/feats/etc. other than Monk that grant the class feature “Flurry of Blows”? (It has to be called exactly that, or otherwise count as FoB for prerequisites.)

Or are there any classes/feats/etc. other than Monk that grant an ability like Decisive Strike? This one doesn’t have to be as exact; I just want a shtick like this as my main combat strategy. I would prefer to do so with Decisive Strike from Monk, because this is supposed to be for a Monk competition, and just having FoB for the sake of saying I do while using an unrelated shtick in combat would be lame.


For the sake of completeness, the feats I know of that could make the mind blade a monk-special-weapon are Flowing Blade (web), Unorthodox Flurry (Dragon Compendium), and Whirling Steel Strike (Eberron Campaign Setting). Note how all three have “flurry of blows class feature” as a prerequisite.

Are there more languages than functions?

My gut says “no”, but I don’t know why.

For any function $ f$ over strings on an alphabet, one can define a language in which every word is just the concatenation of a string $ s$ , a delimiter, and $ f(s)$ , or the empty string if $ f(s)$ is undefined. So there at least as many languages as functions. How can we define a function for every language? (Forgive my ignorance about languages, automata, etc. I have not studied in that area. Perhaps my question is poorly constrained.)