Skip to content

Commit 9f654fd

Browse files
dengweisysudnhatn
authored andcommitted
Fsync translog without writeLock before rolling (#45765)
Today, when rolling a new translog generation, we block all write threads until a new generation is created. This choice is perfectly fine except in a highly concurrent environment with the translog async setting. We can reduce the blocking time by pre-sync the current generation without writeLock before rolling. The new step would fsync most of the data of the current generation without blocking write threads. Close #45371
1 parent c018647 commit 9f654fd

File tree

1 file changed

+3
-0
lines changed
  • server/src/main/java/org/elasticsearch/index/translog

1 file changed

+3
-0
lines changed

server/src/main/java/org/elasticsearch/index/translog/Translog.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1641,6 +1641,9 @@ public TranslogGeneration getMinGenerationForSeqNo(final long seqNo) {
16411641
* @throws IOException if an I/O exception occurred during any file operations
16421642
*/
16431643
public void rollGeneration() throws IOException {
1644+
// make sure we move most of the data to disk outside of the writeLock
1645+
// in order to reduce the time the lock is held since it's blocking all threads
1646+
sync();
16441647
try (Releasable ignored = writeLock.acquire()) {
16451648
try {
16461649
final TranslogReader reader = current.closeIntoReader();

0 commit comments

Comments
 (0)