Open michelmoorlag opened 4 months ago
mark
Same 5.0.20 works but 5.0.21 gives this error.
I also have the same problem, I updated from version 5.0.17 to 5.0.21 and I encounter several problems with deleting and updating collections.
var col = db.GetCollection
var document = BsonMapper.Global.ToDocument(item); var col = db.GetCollection(type.Name); col.Upsert(document);
Error: LiteDB.LiteException: 'ReadFull must read PAGE_SIZE bytes [{0}]'
I can consistently get the error by spamming the following, two FindById calls on two seperate LiteDb files and then an UpsertCall on one of the LiteDb files.
Doesn't happen in 5.0.20
5.0.21 seems to have a dependency on System.Buffer, maybe the issue?
@Blue101black Can you please provide a repro?
@JKamsker I cannot provide a repo sorry, but I can give some details.
Using Xamarin Forms (4.8.0.1687) as a hybrid app with a webview that runs Vue.js. Only build/run the app on Android (We should definitely upgrade to .Net Android)
I communicate back to C# land from Vue via Javascript interface on the WebView. I have a lock in place to make sure only one request can take place at a time.
Spamming a UI button that sends a request and does the below, interacting with two LiteDb instances. Here is an example of the code (renaming things randomly for privacy):
public Item AddItem(Guid parentId)
{
var newItem = new Item()
{
Id = Guid.NewGuid(),
ParentId = parentId,
Quantity = 1,
RecordedAt = _recordTimeService.GetCurrentDateTimeOffset()
};
_database.Upsert<Item>(newItem);
return newItem;
}
GetOrDefault just a wrapper around FindById
public T GetOrDefault<T>(Guid id) where T : class, IEntity, new()
{
return GetCollection<T>().FindById(id);
}
public DateTimeOffset GetCurrentDateTimeOffset()
{
var timeItem = _database.GetOrDefault<TimeItem>(_state.CurrentRecordId);
if (timeItem == null || !timeItem.ShiftId.HasValue || !timeItem.StartAt.HasValue)
{
return _timeService.DateTimeOffsetNow;
}
var shift = _database2.GetOrDefault<Shift>(timeItem.ShiftId.Value);
if (shift == null || !shift.StartTime.HasValue || !shift.EndTime.HasValue)
{
return _timeService.DateTimeOffsetNow;
}
var timeDate = (DateTimeOffset)timeItem.StartAt;
var currentDate = _timeService.DateTimeOffsetNow;
var time = new TimeSpan(currentDate.Hour, currentDate.Minute, currentDate.Second);
// Shift spans over midnight
if (shift.StartTime > shift.EndTime)
{
// Time is outside shift bounds.
if (time < shift.StartTime && time > shift.EndTime)
{
time = (TimeSpan)shift.StartTime;
return new DateTimeOffset(timeDate.Year, timeDate.Month, timeDate.Day, time.Hours, time.Minutes, time.Seconds, timeDate.Offset);
}
// Time is between midnight and endTime
else if (time < shift.EndTime && time > new TimeSpan(0, 0, 0))
{
var newDate = timeDate.AddDays(1);
return new DateTimeOffset(newDate.Year, newDate.Month, newDate.Day, time.Hours, time.Minutes, time.Seconds, newDate.Offset);
}
}
// Time is outside shift bounds.
else if (time < shift.StartTime || time > shift.EndTime)
{
time = (TimeSpan)shift.StartTime;
return new DateTimeOffset(timeDate.Year, timeDate.Month, timeDate.Day, time.Hours, time.Minutes, time.Seconds, timeDate.Offset);
}
// Time is within shift bounds.
return new DateTimeOffset(timeDate.Year, timeDate.Month, timeDate.Day, time.Hours, time.Minutes, time.Seconds, timeDate.Offset);
}
DiskService.cs file...
public int WriteLogDisk(IEnumerable
Shouldn't there be a stream.FlushToDisk(); line before the function returns?
Version On 5.0.20 everything works fine but when I upgrade to 5.0.21 I can't save anything
Describe the bug When I try this code:
it will throw this exception: {LiteDB.Async.LiteAsyncException: LiteDB encounter an error. Details in the inner exception. ---> LiteDB.LiteException: ReadFull must read PAGE_SIZE bytes [{0}]
Code to Reproduce I have a repositry that implements this code that used to run fine:
where _liteDatabaseAsync is of type: ILiteDatabaseAsync created like this
_liteDatabaseAsync = new LiteDatabaseAsync(_connectionString);
Expected behavior I expect that the new versions are backwards comaptible and that above code inserts or updates the given entity without exception.
Screenshots/Stacktrace