19.1 Discuss the relative advantages of centralized and distributed databases.
Answer:
• A distributed database allows a user convenient and transparent access to data which is not stored at the site, while allowing each site control over its own local data. A distributed database can be made more reliable than a centralized system because if one site fails, the database can continue functioning, but if the centralized system fails, the database can no longer continue with its normal operation. Also, a distributed database allows parallel execution of queries and possibly splitting one query into many parts to increase throughput.
• A centralized system is easier to design and implement. A centralized system is cheaper to operate because messages do not have to be sent.
19.2 Explain how the following differ: fragmentation transparency, replication transparency, and location transparency.
Answer:
a. With fragmentation transparency, the user of the system is unaware of any fragmentation the system has implemented. A user may formulate queries against global relations and the system will perform the necessary transformation to generate correct output.
b. With replication transparency, the user is unaware of any replicated data. The system must prevent inconsistent operations on the data. This requires more complex concurrency control algorithms.
c. Location transparency means the user is unaware of where data are stored. The system must route data requests to the appropriate sites.
19.3 How might a distributed database designed for a local-area network differ from one designed for a wide-area network?
Answer: Data transfer on a local-area network (LAN) is much faster than on a wide-area network (WAN). Thus replication and fragmentation will not increase throughput and speed-up on a LAN, as much as in aWAN. But even in a LAN, replication has its uses in increasing reliability and availability.
19.4 When is it useful to have replication or fragmentation of data? Explain your answer.
Answer: Replication is useful when there are many read-only transactions at different sites wanting access to the same data. They can all execute quickly in parallel, accessing local data. But updates become difficult with replication. Fragmentation is useful if transactions on different sites tend to access different parts of the database.
19.5 Explain the notions of transparency and autonomy. Why are these notions desirable from a human-factors standpoint?
Answer: Autonomy is the amount of control a single site has over the local database. It is important because users at that site want quick and correct access to local data items. This is especially true when one considers that local data will be most frequently accessed in a database. Transparency hides the distributed nature of the database. This is important because users should not be required to know about location, replication, fragmentation or other implementation aspects of the database.
19.6 To build a highly available distributed system, you must know what kinds of failures can occur.
a. List possible types of failure in a distributed system.
b. Which items in your list from part a are also applicable to a centralized system?
Answer:
a. The types of failure that can occur in a distributed system include
i. Computer failure (site failure).
ii. Disk failure.
iii. Communication failure.
b. The first two failure types can also occur on centralized systems.
19.7 Consider a failure that occurs during 2PC for a transaction. For each possible failure that you listed in Exercise 19.6a, explain how 2PC ensures transaction atomicity despite the failure.
Answer: A proof that 2PC guarantees atomic commits/aborts inspite of site and link failures, follows. The main idea is that after all sites reply with a <ready T> message, only the co-ordinator of a transaction can make a commit or abort decision. Any subsequent commit or abort by a site can happen only after it ascertains the co-ordinator’s decision, either directly from the coordinator, or indirectly from some other site. Let us enumerate the cases for a site aborting, and then for a site committing.
a. A site can abort a transaction T (by writing an <abort T> log record) only under the following circumstances:-
i. It has not yet written a <ready T> log-record. In this case, the coordinator could not have got, and will not get a<ready T> or <commit T> message from this site. Therefore only an abort decision can be made by the co-ordinator.
ii. It has written the <ready T> log record, but on inquiry it found out that some other site has an <abort T> log record. In this case it is correct for it to abort, because that other site would have ascertained the co-ordinator’s decision (either directly or indirectly) before actually aborting.
iii. It is itself the co-ordinator. In this case also no site could have committed, or will commit in the future, because commit decisions can be made only by the co-ordinator.
b. A site can commit a transaction T (by writing an <commit T> log record) only under the following circumstances:-
i. It has written the <ready T> log record, and on inquiry it found out that some other site has a <commit T> log record. In this case it is correct for it to commit, because that other site would have ascertained the co-ordinator’s decision (either directly or indirectly) before actually committing.
ii. It is itself the co-ordinator. In this case no other participating site can abort/ would have aborted, because abort decisions are made only by the co-ordinator.
19.8 Consider a distributed system with two sites, A and B. Can site A distinguish among the following?
• B goes down.
• The link between A and B goes down.
• B is extremely overloaded and response time is 100 times longer than normal.
What implications does your answer have for recovery in distributed systems?
Answer: Site A cannot distinguish between the three cases until communication has resumed with site B. The action which it performs while B is inaccessible must be correct irrespective of which of these situations has actually occurred, and must be such that B can re-integrate consistently into the distributed system once communication is restored.
19.9 The persistent messaging scheme described in this chapter depends on timestamps combined with discarding of received messages if they are too old. Suggest an alternative scheme based on sequence numbers instead of timestamps.
Answer: We can have a scheme based on sequence numbers similar to the scheme based on timestamps. We tag each message with a sequence number that is unique for the (sending site, receiving site) pair. The number is increased by 1 for each new message sent from the sending site to the receiving site.
The receiving site stores and acknowledges a received message only if it has received all lower numbered messages also; the message is stored in the received-messages relation.
The sending site retransmits a message until it has received an ack from the receiving site containing the sequence number of the transmitted message, or a higher sequence number. Once the acknowledgment is received, it can delete the message from its send queue.
The receiving site discards all messages it receives that have a lower sequence number than the latest stored message from the sending site. The receiving site discards from received-messages all but the (number of the) most recent message from each sending site (message can be discarded only after being processed locally).
Note that this scheme requires a fixed (and small) overhead at the receiving site for each sending site, regardless of the number of messages received. In contrast the timestamp scheme requires extra space for every message. The timestamp scheme would have lower storage overhead if the number of messages received within the timeout interval is small compared to the number of sites, whereas the sequence number scheme would have lower overhead otherwise.
19.11 If we apply a distributed version of the multiple-granularity protocol to a distributed database, the site responsible for the root of the DAG may become a bottleneck. Suppose we modify that protocol as follows:
• Only intention-mode locks are allowed on the root.
• All transactions are given all possible intention-mode locks on the root automatically.
Show that these modifications alleviate this problem without allowing any nonserializable schedules.
Answer: Serializability is assured since we have not changed the rules for the multiple granularity protocol. Since transactions are automatically granted all intention locks on the root node, and are not given other kinds of locks on it, there is no need to send any lock requests to the root. Thus the bottleneck is relieved.
19.12 Explain the difference between data replication in a distributed system and the maintenance of a remote backup site.
Answer: In remote backup systems all transactions are performed at the primary site and the data is replicated at the remote backup site. The remote backup site is kept synchronized with the updates at the primary site by sending all log records. Whenever the primary site fails, the remote backup site takes over processing.
The distributed systems offer greater availability by having multiple copies of the data at different sites whereas the remote backup systems offer lesser availability at lower cost and execution overhead.
In a distributed system, transaction code runs at all the sites whereas in a remote backup system it runs only at the primary site. The distributed system transactions follow two-phase commit to have the data in consistent state whereas a remote backup system does not follow two-phase commit and avoids related overhead.
24.4 Like database systems, workflow systems also require concurrency and recovery management. List three reasons why we cannot simply apply a relational database system using 2PL, physical undo logging, and 2PC.
Answer:
a. The tasks in a workflow have dependencies based on their status. For example the starting of a task may be conditional on the outcome (such as commit or abort) of some other task. All the tasks cannot execute independently and concurrently, using 2PC just for atomic commit.
b. Once a task gets over, it will have to expose its updates, so that other tasks running on the same processing entity don’t have to wait for long. 2PL is too strict a form of concurrency control, and is not appropriate for workflows.
c. Workflows have their own consistency requirements, i.e. failure-atomicity. An execution of a workflow must finish in an acceptable termination state. Because of this, and because of early exposure of uncommitted updates, the recovery procedure will be quite different. Some form of logical logging and compensation transactions will have to be used. Also to perform forward recovery of a failed workflow, the recovery routines need to restore the state information of the scheduler and tasks, not just the updated data items. Thus simple WAL cannot be used.
24.5 If the entire database fits in main memory, do we still need a database system to manage the data? Explain your answer.
Answer: Even if the entire database fits in main memory, a DBMS is needed to perform tasks like concurrency control, recovery, logging etc, in order to preserve ACID properties of transactions.
24.6 Consider a main-memory database system recovering from a system crash. Explain the relative merits of
• Loading the entire database back into main memory before resuming transaction processing
• Loading data as it is requested by transactions
Answer:
• Loading the entire database into memory in advance can provide transactions which need high-speed or realtime data access the guarantee that once they start they will not have to wait for disk accesses to fetch data. However no transaction can run till the entire database is loaded.
• The advantage in loading on demand is that transaction processing can start right away; however transactions may see long and unpredictable delays in disk access until the entire database is loaded into memory.
24.10 Explain why it may be impractical to require serializability for long-duration transactions.
Answer: In the presence of long-duration transactions, trying to ensure serializability has several drawbacks:-
a. With a waiting scheme for concurrency control, long-duration transactions will force long waiting times. This means that response time will be high, concurrency will be low, so throughput will suffer. The probability of deadlocks is also increased.
b. With a time-stamp based scheme, a lot of work done by a long-running transaction will be wasted if it has to abort.
c. Long duration transactions are usually interactive in nature, and it is very difficult to enforce serializability with interactiveness.
Thus the serializability requirement is impractical. Some other notion of database consistency has to be used in order to support long duration transactions.
No comments:
Post a Comment