You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I generate a large amount of data using FasterKV (with the number of keys exceeding 300 million), and then save a checkpoint and load it again, an error occurs, and I can no longer recover the original data. What could be the issue?
Here is the source code:
usingFASTER.core;usingSystem.Diagnostics;classProgram{constintDataSize=300000000;//const int DataSize = 100000;staticasyncTaskMain(){CleanData();awaitCreateLargeData();awaitLoadDataAndVerify();}privatestaticvoidCleanData(){varsw=Stopwatch.StartNew();Console.WriteLine("Cleaning data ...");if(Directory.Exists("./data")){Directory.Delete("./data",true);}sw.Stop();Console.WriteLine($" - Cleaning data done. (Elapsed: {sw.Elapsed.TotalSeconds:f2}s)");}privatestaticFasterKV<long,long>CreateStore(booltryRecoverLatest=false){varlog=Devices.CreateLogDevice("./data/hlog.log");varobjlog=Devices.CreateLogDevice("./data/hlog.obj.log");varstore=newFasterKV<long,long>(// 1L << 20, 1L<<18,newLogSettings{LogDevice=log,ObjectLogDevice=objlog},newCheckpointSettings{CheckpointDir="./data/checkpoint"},tryRecoverLatest:tryRecoverLatest);returnstore;}// Generate a large amount of dataprivatestaticasyncTaskCreateLargeData(){Console.WriteLine($"Creating large data: size:{DataSize} ...");// Create FasterKV instancevarstore=CreateStore();usingvarsession=store.NewSession(newSimpleFunctions<long,long>());// Write datavarsw=Stopwatch.StartNew();varlastShowProgress=0;for(longi=0;i<DataSize;i++){session.Upsert(i,i);vartotalSeconds=(int)sw.Elapsed.TotalSeconds;if(totalSeconds-lastShowProgress>5){// Display progresslastShowProgress=totalSeconds;varcurrentSpeed=i/sw.Elapsed.TotalSeconds;Console.WriteLine($" - Creating progress: {i}/{DataSize} ({i*100.0/DataSize:f2}%) (Elapse: {totalSeconds}, Speed: {currentSpeed:f2} ops/s) ...");}}// Write checkpointvarwriteCheckpointSw=Stopwatch.StartNew();Console.WriteLine(" - Writing checkpoint ...");awaitstore.TakeFullCheckpointAsync(CheckpointType.Snapshot);awaitsession.CompletePendingAsync();// store.Log.Flush(true);writeCheckpointSw.Stop();Console.WriteLine($" - Writing checkpoint done. (Elapsed: {writeCheckpointSw.Elapsed.TotalSeconds:f2}s)");ShowStoreInfo(store);// Dispose resourcessession.Dispose();store.Dispose();varspeed=DataSize/sw.Elapsed.TotalSeconds;Console.WriteLine($" - All done. (Elapsed: {sw.Elapsed.TotalSeconds:f2}s, Speed: {speed:f2} ops/s)");}staticasyncTaskLoadDataAndVerify(){Console.WriteLine($"Loading data and verify: size:{DataSize} ...");varloadSw=Stopwatch.StartNew();varstore=CreateStore(tryRecoverLatest:true);loadSw.Stop();Console.WriteLine($" - Loading data done. (Elapsed: {loadSw.Elapsed.TotalSeconds:f2}s)");ShowStoreInfo(store);usingvarsession=store.NewSession(newSimpleFunctions<long,long>());// Read & verify datavarsw=Stopwatch.StartNew();varlastShowProgressTime=0;varlastShowErrorTime=-100;varerrorCount=0;for(longi=0;i<DataSize;i++){var(status,output)=(awaitsession.ReadAsync(i)).Complete();if(!status.Found){if(sw.Elapsed.TotalSeconds-lastShowErrorTime>5){lastShowErrorTime=(int)sw.Elapsed.TotalSeconds;Console.WriteLine($" - Error: key {i} not found. (Status: {status}) (ErrorCount: {errorCount})");}errorCount++;continue;}if(output!=i){if(sw.Elapsed.TotalSeconds-lastShowErrorTime>5){lastShowErrorTime=(int)sw.Elapsed.TotalSeconds;Console.WriteLine($" - Error: key {i} value is {output}, but expect is {i}. (ErrorCount: {errorCount})");}errorCount++;}vartotalSeconds=(int)sw.Elapsed.TotalSeconds;if(totalSeconds-lastShowProgressTime>5){// Display progresslastShowProgressTime=totalSeconds;varcurrentSpeed=i/sw.Elapsed.TotalSeconds;Console.WriteLine($" - Creating progress: {i}/{DataSize} ({i*100.0/DataSize:f2}%) (Elapse: {totalSeconds}, Speed: {currentSpeed:f2} ops/s) ...");}}// Write checkpointawaitstore.TakeFullCheckpointAsync(CheckpointType.Snapshot);awaitsession.CompletePendingAsync();ShowStoreInfo(store);// Dispose resourcessession.Dispose();store.Dispose();varspeed=DataSize/sw.Elapsed.TotalSeconds;Console.WriteLine($" - All done. (ErrorCount: {errorCount}, Elapsed: {sw.Elapsed.TotalSeconds:f2}s, Speed: {speed:f2} ops/s)");}staticvoidShowStoreInfo(FasterKV<long,long>store){varsw=Stopwatch.StartNew();// Get FasterKV store infovarentryCount=store.EntryCount;varindexSize=store.IndexSize;varoverflowBucketCount=store.OverflowBucketCount;varmemorySizeBytes=store.Log.MemorySizeBytes;sw.Stop();Console.WriteLine($" - Store info: EntryCount: {entryCount}, IndexSize: {indexSize}, overflowBucketCount: {overflowBucketCount}, "+$"memorySizeBytes: {memorySizeBytes}, (Get info elapse: {sw.Elapsed.TotalSeconds:f2}s)");}}
Run result:
Cleaning data ...
- Cleaning data done. (Elapsed: 2.66s)
Creating large data: size:300000000 ...
- Creating progress: 8333810/300000000 (2.78%) (Elapse: 6, Speed: 1388968.26 ops/s) ...
...
- Creating progress: 299706408/300000000 (99.90%) (Elapse: 2520, Speed: 118931.11 ops/s) ...
- Writing checkpoint ...
- Writing checkpoint done. (Elapsed: 76.84s)
- Store info: EntryCount: 300000000, IndexSize: 262144, overflowBucketCount: 42710337, memorySizeBytes: 7247757312, (Get info elapse: 16.72s)
- All done. (Elapsed: 2619.05s, Speed: 114545.54 ops/s)
Loading data and verify: size:300000000 ...
- Loading data done. (Elapsed: 0.85s)
- Store info: EntryCount: 1835008, IndexSize: 262144, overflowBucketCount: 42710337, memorySizeBytes: 67108864, (Get info elapse: 0.02s)
- Error: key 0 not found. (Status: NotFound) (ErrorCount: 0)
- Error: key 8532049 not found. (Status: NotFound) (ErrorCount: 8532049)
...
- Error: key 299672862 not found. (Status: NotFound) (ErrorCount: 299672862)
- Store info: EntryCount: 1835008, IndexSize: 262144, overflowBucketCount: 42710337, memorySizeBytes: 67108864, (Get info elapse: 0.01s)
- All done. (ErrorCount: 300000000, Elapsed: 175.54s, Speed: 1708998.12 ops/s)
Note: After restoring the data, the EntryCount is noticeably much lower, and all keys cannot be found. (If DataSize = 200000000, then it is normal, with no errors.)
The text was updated successfully, but these errors were encountered:
When I generate a large amount of data using FasterKV (with the number of keys exceeding 300 million), and then save a checkpoint and load it again, an error occurs, and I can no longer recover the original data. What could be the issue?
Here is the source code:
Run result:
Note: After restoring the data, the EntryCount is noticeably much lower, and all keys cannot be found. (If DataSize = 200000000, then it is normal, with no errors.)
The text was updated successfully, but these errors were encountered: