Back to all scenarios
Scenario #372
Storage
Kubernetes v1.22, NFS with ReadWriteMany

File Locking Issue Between Multiple Pods on NFS

Two pods wrote to the same file concurrently, causing lock conflicts and data loss.

Find this helpful?
What Happened

Lack of advisory file locking on the NFS server led to race conditions between pods.

Diagnosis Steps
  • 1Log files had overlapping, corrupted data.
  • 2File locks were not honored.
Root Cause

POSIX locks not enforced reliably over NFS.

Fix/Workaround
• Introduced flock-based locking in application code.
• Used local persistent volume instead for critical data.
Lessons Learned

NFS doesn’t guarantee strong file locking semantics.

How to Avoid
  • 1Architect apps to handle distributed file access carefully.
  • 2Avoid shared writable files unless absolutely needed.