Skip to content

Instantly share code, notes, and snippets.

@itn3000
Last active January 11, 2022 00:11
Show Gist options
  • Save itn3000/5cbfd41d166ae41173a45d5d4792c03e to your computer and use it in GitHub Desktop.
Save itn3000/5cbfd41d166ae41173a45d5d4792c03e to your computer and use it in GitHub Desktop.
old file did not deleted in FasterLog
using FASTER.core;
// all old files are deleted after truncating in same session
{
using var device = Devices.CreateLogDevice("test.log", recoverDevice: true);
using var log = new FasterLog(new FasterLogSettings()
{
LogDevice = device,
SegmentSizeBits = 20,
MemorySizeBits = 15,
PageSizeBits = 10,
});
Console.WriteLine($"{log.BeginAddress}, {log.TailAddress}");
var data = new byte[512];
// inserting data
for (int i = 0; i < 10000; i++)
{
log.Enqueue(data);
}
log.Commit(true);
log.TruncateUntil(log.TailAddress);
log.Commit(true);
}
// expected: after running this, There is only last log segment.
// actual: after running this, old file is not deleted.
using FASTER.core;
{
using var device = Devices.CreateLogDevice("test.log", recoverDevice: true);
using var log = new FasterLog(new FasterLogSettings()
{
LogDevice = device,
SegmentSizeBits = 20,
MemorySizeBits = 15,
PageSizeBits = 10,
});
Console.WriteLine($"{log.BeginAddress}, {log.TailAddress}");
var data = new byte[512];
// inserting data
for (int i = 0; i < 10000; i++)
{
log.Enqueue(data);
}
log.Commit(true);
}
{
using var device = Devices.CreateLogDevice("test.log", recoverDevice: true);
using var log = new FasterLog(new FasterLogSettings()
{
LogDevice = device,
SegmentSizeBits = 20,
MemorySizeBits = 15,
PageSizeBits = 10,
});
Console.WriteLine($"{log.BeginAddress}, {log.TailAddress}");
log.TruncateUntil(log.TailAddress);
log.Commit(true);
}
@itn3000
Copy link
Author

itn3000 commented Jan 11, 2022

This is fixed in microsoft/FASTER#627

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment