After Hours Academic

Question 11: Diverging replicas

Anjali is building an replicated database management system (DBMS). She wants to maintain two copies of data in two servers (primary and secondary server).

She decides to implement replication by replicating any page in the primary server to the secondary server.

As an example, consider that the DBMS client performs the following query:

UPDATE table_name
SET column1=val1, column7=val7
WHERE columns4=val4

If 10 rows satisfy column4=val4, this query will update two columns for those 10 rows. These rows might be spread across 3 different pages. Anjali's design will then replicate all these pages to the secondary server.

Anjali thinks that she can make replication more efficient. Instead of replicating the pages, she decides to replicate the query and let each of the server operate on the query independently. So, in the above example, instead of replicating the three pages, the primary server will just tell the secondary server about the query and then both of them will perform the updates independently.

Can you think of a scenario wherein the two replicas might deviate with Anjali's new replication design?

Hint: What kind of queries can lead to different result on different servers?

Solution coming up in the next post.

Solution for fast failure recovery:

Gloria's approach of choosing two disks at random to replicate any piece of data is a better approach for recovering from a disk failure.

When a disk fails, a new disk is introduced to take the place of the failed disk. This new disk needs to be populated with all the data that was in the failed disk. Moreover, this recovery process should ideally be done without stopping any other non-recovery related reads.

In Jay's solution, following a disk failure, the new replacement disk would need to populated using data from the other disk in its replica. This would place a high demand for read bandwidth on the functioning disk in the group. Not only will it slow down the recovery process, it might also hurt the performance of non-recovery reads for data belonging to that group of disks. This is because all reads would be bottlenecked by the read bandwidth of the surviving disk in the group.

In contrast, Gloria's solution spreads out the replicas across disk. So to reconstruct data for a failed disk, some parts of the data would be read from each of the remaining functioning disks as opposed to a single disk.

This idea is similar to spreading out parity across disks in RAID-5 to improve write performance, as discussed in this blog post.

#databases #qna #replication