Giter Club home page Giter Club logo

Comments (2)

kuujo avatar kuujo commented on May 23, 2024

bTW the conversation referenced is in #29

from copycat.

kuujo avatar kuujo commented on May 23, 2024

Actually, the description above is somewhat wrong...

https://github.com/atomix/copycat/blob/master/server/src/main/java/io/atomix/copycat/server/storage/Log.java#L331

Entries where index <= majorIndex (i.e. globalIndex) are returned as null if cleaned. But normal entries where index > majorIndex can be null as well if they index <= minorIndex and they were removed from disk. So, I think that condition above should actually be:

// For non-null entries, we determine whether the entry should be exposed to the Raft algorithm
// based on the type of entry and whether it has been cleaned.
if (entry != null) {
  // If the entry has not been cleaned by the state machine, return it. Note that the call to isClean()
  // on the segment will be done in O(1) time since the search was already done in the get() call.
  if (!segment.isClean(index)) {
    return entry;
  }
  // For tombstone entries, if the entry index is greater than the majorIndex, return the entry. This ensures that entries
  // are replicated until persisted on all available servers.
  else if (entry.isTombstone()) {
    if (index > compactor.majorIndex()) {
      return entry;
    }
  }
  // If the entry is not a tombstone, return the entry if the index is greater than minorIndex. If the entry is less than minorIndex,
  // that indicates that it has been committed and events have been received for the entry, so we can safely stop replicating it.
  else {
    if (index > compactor.minorIndex()) {
      return entry;
    }
  }
}

This hides entries for which events have been received and tombstones that have been stored on all servers as necessary. But an additional condition needs to be added to handle the case of the last committed entry:

if (index >= segments.commitIndex()) {
  return entry;
}

The last case will ensure that AppendRequest consistency checks can be completed on a non-null entry. The last committed entry will always remain visible in the log. I'll have to double check log compaction to ensure this guarantee still holds there as well.

from copycat.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.