Skip to content

Commit

Permalink
DiskWriterQueue resiliency
Browse files Browse the repository at this point in the history
  • Loading branch information
ltetak committed Jan 26, 2024
1 parent f21cd84 commit fab1a40
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion LiteDB/Engine/Disk/DiskWriterQueue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,25 @@ private async Task ExecuteQueue()
_queueHasItems.Reset();
if (_shouldClose) return;
}
_stream.FlushToDisk();
TryFlushStream();

await _queueHasItems.WaitAsync();
}
}
}

private void TryFlushStream()
{
try
{
_stream.FlushToDisk();
}
catch (IOException)
{
// Disk is probably full. This may be unrecoverable problem but until we have enough space in the buffer we may be ok.
}
}

private void WritePageToStream(PageBuffer page)
{
if (page == null) return;
Expand Down

0 comments on commit fab1a40

Please sign in to comment.