DRBD – Why read-only on secondary resource would cause cache coherency issue

cachedrbd

According to the DRBD9 documentation (https://www.drbd.org/en/doc/users-guide-90/s-resource-roles), reading the device would cause cache coherency issue but i'm not sure about why. (I know i can't access a resource in secondary role but i want understand the reasons)

My hypothesis is (assuming we have DRBD-1 primary and DRBD-2 secondary, filesystem ext4 and "file_a" is a file on the drbd device):

  1. DRBD-2 access file_a and places the file_a offset (or something like that) in his cache. (DRBD-2 have read-only rights, so the system thinks the file can not be modified).
  2. DRBD-1 writes file_b content at the old file_a offset.
  3. DRBD-2 wants to access file_a again, so the system uses the offset he stored in his cache, expecting to find file_a data while accessing file_b data.
  4. We have cache coherency issue.

Thanks in advance for shed light me on about this point.

Best Answer

Yes, what you described it is the exact scenario that can lead to cache coherency issues.

To solve that problem, you had to use a filesystem designed to re-validate any cached entries accessed by other hosts. These are called clustered filesystem, with GFS2 and OCFS being primary examples.

But please note that for this very same reason, clustered filesystems are generally slower than traditional ones.

Related Topic