juicedata / juicefs

JuiceFS is a distributed POSIX file system built on top of Redis and S3.
https://juicefs.com
Apache License 2.0
10.95k stars 967 forks source link

Avoid txn conflicts between write and compact on the same inode #5308

Closed polyrabbit closed 2 days ago

polyrabbit commented 3 days ago

We observed many txn conflicts between write and compact when using TiKV, especially when users have many small IOs. TiKV's txn conflicts are very expensive, we can avoid them on the client side by using inode-granularity locks. One downside of this change is that compaction between chunks within an inode cannot be performed concurrently, but considering chunks are 64M, so the probability of small IOs spanning multiple chunks is relatively low.

method: doCompactChunk, error: write conflict { start_ts:453879141784617034 conflict_ts:453879141784617033 primary:"xia\375A\013\000\003\000\000\000\000\000C\000\000\000\000" reason:Optimistic