Skip to content

Commit

Permalink
Fsync translog without writeLock before rolling (#45765)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
dengweisysu authored and dnhatn committed Aug 22, 2019
1 parent c018647 commit 9f654fd
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1641,6 +1641,9 @@ public TranslogGeneration getMinGenerationForSeqNo(final long seqNo) {
* @throws IOException if an I/O exception occurred during any file operations
*/
public void rollGeneration() throws IOException {
// make sure we move most of the data to disk outside of the writeLock
// in order to reduce the time the lock is held since it's blocking all threads
sync();
try (Releasable ignored = writeLock.acquire()) {
try {
final TranslogReader reader = current.closeIntoReader();
Expand Down

0 comments on commit 9f654fd

Please sign in to comment.