Recall that the fully distributed locking algorithm is parameterized by three numbers:
Answer the following questions:
What are the constraints on these numbers?
x > n/2, which guarantees no two transactions can acquire a global exclusive lock at one time
s > n - x, which guarantees that if one transaction has a global exclusive lock, another can’t have a global shared lock, and vice versa
Explain how write-all replication obeys these constraints.
If we substitute for x and s using the above equations, the locking constraints become n > n/2 (which is true) and 1 > n - n (which is true). This implies that write-all replication always obeys the distributed locking discipline.
Explain how voting replication can obey these constraints.
Therefore, when using voting with fully distributed locking:
Here the first equation above is the same as an original constraint, and the second equation above is equivalent to s > n - x, which is also the same as an original constraint. This implies that voting replication obeys the distributed locking discipline.
What are other possible values for n, s, and x?
Imagine that you are hired as a database administrator for a new chain of banks. Your job is to design a database to hold customer and account data. Your manager explains to you that he thinks asynchronous replication of data should be used between the various branches because he wants the database to be faster than those of competing banks. As a graduate of CSCI E-66, you know this could be a bad idea.
What is the primary reason that asynchronous replication in a bank database would be a bad idea?
Come up with an alternate distributed database scheme to present to your manager. In particular:
Which would be the better form of synchronous replication: read-any/write-all or voting? Think about what must take place for balance queries and withdrawal/deposit transactions.
Which would be the best form of distributed concurrency control: centralized locking, primary-copy locking, or fully distributed locking? You can assume that speed is still important, and it is expected that there will be many bank branches.
Using pseudocode, design the mapper and reducer functions for counting the occurrences of words in a set of input files.
mapper(key, line): words[] = split(line) for each word in words: emit(word, 1)
The reducer also accepts a (key, value) pair, where the key is a word and the value is a list of counts for that word. In this application, all of the counts will be 1. After the counts for the word are summed, the word and the total is output.
reducer(word, counts[]): total = 0 for each count in counts: total += count emit(word, total)
Last updated on November 2, 2024.