Distributed classic paper read: Bayou

This article is Bayou reading the paper notes, Bayou is more than one copy of a weakly consistent storage system. Bayou predominantly at the mobile computing environment, a weak connection, parallel to the collaborative applications conflict management activities. The weak link in the network environment, in fact, can only achieve weak replica consistency. In Bayou, the client can read the data in any case, even if these data conflict is not completely resolved. The main contribution of this paper is:

  • Introducing data dependency checking and updating the merge process conflict detection and resolution for the application defined above;
  • It defines the update of two states: submit and temptations ;
  • How to manage updates two states;
  • How to copy the final agreement;
  • How to ensure security in the Bayou (notes omitted).

Bayou Application

  • Meeting Room Scheduling : conference room scheduler allows a user to reserve rooms. If the meeting room user application at a given time there is a conflict, it will reschedule to an alternate time period.
  • Document Database : Document database allows users to collaboratively maintain a document database maintains a mapping entry identifier to the document, if there is a conflict in the tag, then the tag will automatically rename conflict.

Bayou basic system model

Bayou data collection system will save a copy on a number of servers, applications through the API and server interaction. API provides two modes of operation: read and write. Bayou copy using weak consistency model provides read and write access to any. Different clients will read and write access to the server, you need to use Session Guanrantees to ensure the consistency of the client observed.

In order to achieve detection and resolution into the application level, the update operation will provide additional information for the detection and resolution of conflict need. Use reverse entropy protocol between the server writes records exchange, as long as there is no permanent division between the server, then the write operation will eventually reach all servers.

Conflict detection and resolution

Support application-defined conflict detection and resolution of design is the focus of Bayou, conflict detection and mechanisms of digestion are dependent on examination and merging process .

  • Execution of the write operation:
Bayou_Write (update, dependency_check, mergeproc) {
    IF (DB_Eval (dependency_check.query) <> dependency_check.expected_result)
        resolved_update = Interpret (mergeproc);
    ELSE
        resolved_update = update;
    DB_Apply (resolved_update);
}
复制代码
  • A write operation:
Bayou_Write(
    update = {insert, Meetings, 12/18/95, 1:30pm, 60min, “Budget Meeting”},
    dependency_check = {
        query = “SELECT key FROM Meetings WHERE day = 12/18/95
AND start < 2:30pm AND end > 1:30pm”,
        expected_result = EMPTY},
    mergeproc = {
        alternates = {{12/18/95, 3:00pm}, {12/19/95, 9:30am}};
        newupdate = {};
        FOREACH a IN alternates {
            # check if there would be a conflict
            IF (NOT EMPTY (
                SELECT key FROM Meetings WHERE day = a.date
 AND start < a.time + 60min AND end > a.time))
CONTINUE;
# no conflict, can schedule meeting at that time
newupdate = {insert, Meetings, a.date, a.time, 60min, “Budget Meeting”};
BREAK;
}
        IF (newupdate = {}) # no alternate is acceptable
newupdate = {insert, ErrorLog, 12/18/95, 1:30pm, 60min, “Budget Meeting”};
        RETURN newupdate;}
)
复制代码

Dependency checking

If the server is a query on the current data did not return the results you want, then it means that generate conflict. Bayou dependency checking can detect write - write conflicts and read - write conflict , because dependency checking can do any query, highly flexible data constraint can be achieved.

Consolidation process

When a collision is detected, the server will perform the merge process. When the conflict can not be automatically merged, the conflict will be logged, so that to eliminate the artificial conflict.

Replica consistency

Bayou final consistency achieved primarily by two principles to ensure that:

  1. Write operation have a consistent order on all servers;
  2. And merge conflict detection process is determined, so each server in the same way to digestion conflict.

Bayou write request received by the server is initially tentative state , it finally becomes committed state . Each write operation will be marked with marks <时间戳, 标记的服务器ID>, the server uses the clock logic, and real time synchronization is usually, but after the server receives a write operation from the inverse entropy process, before its clock needs to be pushed. When the server receives a new written agreement by reverse entropy, it needs to be applied in order to re-write operations by revoking write.

Write and submit stability

When the write operation is the last execution server, writes thought into the steady state , means that the server has received all write operations before writing this.

Checks written by inverse entropy is stable agreement is completed, the most recent time stamp server exchange for a write operation, when a write operation is less than the full server timestamp time stamp, then this is written is stable. For each data, select a master server to allow other servers to exchange it by writing submitted.

Storage system implementation

Storage system consists of three parts: a write log, and the undo log ancestral memory.

  • Written to the log : sorted comprising written request received by the server;
  • Storing tuples : contains the results of the current write;
  • Undo logs : to undo the write operation.

When writing becomes stable, the request can be omitted in the log. Storing tuples implemented using a relational database memory, the stored submission and all the two versions of the database, they are stored with the data, two bytes are used to mark all or submitted. Write changes Ganso previously stored undo log can be revoked. In order to achieve recovery, and need to be saved into the log storage neuron progenitor checkpoint storage stability.

  • Will be written to the database
Receive_Writes (writeset, received_from) {
    IF (received_from = CLIENT) {
        # Received one write from the client, insert at end of WriteLog
        # first increment the server’s timestamp
        logicalclock = MAX(systemclock, logicalclock + 1);
        write = First(writeset);
        write.WID = {logicalclock, myServerID};
        write.state = TENTATIVE;
        WriteLog_Append(write);
        Bayou_Write(write.update, write.dependency_check, write.mergeproc);
    } ELSE {
        # Set of writes received from another server during anti-entropy,
        # therefore writeset is ordered
        write = First(writeset);
        insertionPoint = WriteLog_IdentifyInsertionPoint(write.WID);
        TupleStore_RollbackTo(insertionPoint);
        WriteLog_Insert(writeset);
        # Now roll forward
        FOREACH write IN WriteLog AFTER insertionPoint DO
            Bayou_Write(write.update, write.dependency_check, write.mergeproc);
        # Maintain the logical clocks of servers close
        write = Last(writeset);
        logicalclock = MAX(logicalclock, write.WID.timestamp);
    }
}
复制代码

references

  1. Terry, Douglas B., et al. "Managing update conflicts in Bayou, a weakly connected replicated storage system." SOSP. Vol. 95. 1995.

Guess you like

Origin juejin.im/post/5d21399cf265da1bac403905
Recommended