-
-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
System.OverflowException when backward iterating #1
Comments
Hi, I need to be able to reproduce this exception. We don't have such problem on a very big park of machines and databases. |
Is it so, that some threads are writing data into the table, while other reading backward? As more info you supply - as better. |
@hhblaze this appears to occur with a number of customers on various hardware so it's not an isolated incident. We've also managed to have a single dev reproduce the issue locally. However, since the issue doesn't appear to persist in the actual table files, it's almost impossible to reproduce. You are correct however that this is in a multithreaded scenario. Our application uses heavy multithreading with multiple readers and writers concurrently. Multithreaded support was the main reason for adopting DBreeze. I'll see about providing code samples. In the meantime, the most common scenario is the following:
|
I would say, that we need an emulator of your business case or, may be, your team can enhance source code with more informative exception handling. |
Some more questions:
|
During 24 hours was running a test that showed no mistakes. Once per second was an insert of 5 values (key is string from Guid, value is byte[400]). 10 threads were trying to get single existing value in random time interval from 700ms up 2500ms. And other 10 threads in random time interval were trying to get SelectBackward last 150 values. using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using DBreeze;
using DBreeze.Utils;
namespace testB
{
public partial class Form1 : Form
{
DBreezeEngine engine = null;
public Form1()
{
InitializeComponent();
engine = new DBreezeEngine(@"E:\temp\DBreezeTest\DBR1");
}
List<string> d = new List<string>();
int eq = 10000000;
private void button1_Click(object sender, EventArgs e)
{
for (int i = 0; i < eq; i++)
{
d.Add(Guid.NewGuid().ToString());
}
Console.WriteLine("Filled");
System.Threading.Tasks.Task.Run(() =>
{
while (true)
{
Insert();
System.Threading.Thread.Sleep(1000);
}
});
Random rnd = new Random();
for (int ti = 0; ti < 10; ti++)
{
System.Threading.Tasks.Task.Run(() =>
{
while (true)
{
SingleReader();
System.Threading.Thread.Sleep(700 + rnd.Next(2000));
}
});
}
for (int i = 0; i < 5; i++)
{
System.Threading.Tasks.Task.Run(() =>
{
while (true)
{
BackReader();
System.Threading.Thread.Sleep(1500 + rnd.Next(2000));
}
});
}
for (int i = 0; i < 5; i++)
{
System.Threading.Tasks.Task.Run(() =>
{
while (true)
{
BackReader2();
System.Threading.Thread.Sleep(1500 + rnd.Next(2000));
}
});
}
}
private void BackReader()
{
try
{
using (var tran = engine.GetTransaction())
{
foreach(var row in tran.SelectBackward<string, byte[]>("t1").Take(150))
{
var val = row.Value;
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
private void BackReader2()
{
try
{
using (var tran = engine.GetTransaction())
{
tran.ValuesLazyLoadingIsOn = false;
foreach (var row in tran.SelectBackward<string, byte[]>("t1").Take(150))
{
var val = row.Value;
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
int jj = 0;
private void SingleReader()
{
try
{
if (jj < 1)
return;
using (var tran = engine.GetTransaction())
{
var rnd = new System.Random();
var p = rnd.Next(jj - 1);
var rrr = tran.Select<string, byte[]>("t1", d[p]);
var val = rrr.Value;
}
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
private void Insert()
{
try
{
using(var tran = engine.GetTransaction())
{
for (int i = 0; i < 5; i++)
{
tran.Insert<string, byte[]>("t1", d[jj++], new byte[400]);
}
tran.Commit();
}
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
}
} |
@hhblaze I'll be sure to send you a sample that reproduces exactly our usage pattern as soon as possible. I'm currently away from the office for the holidays but as soon as I can, I'll send something your way. This is not an issue that occurs frequently. It's pretty much assuredly a race condition since we barely see it in our customers and it's running essentially continuously for hours at a time across all of our customers. Repro cases are rare but we've gotten to the point where we do get a significant enough number of occurrences since we have a large customer base. |
@hhblaze I've written code that pretty much systematically reproduces the case. You must just be sure to use an empty directory. It appears that it's the act of adding multiple tables that is causing the problem. At any rate, start with an empty folder and run the following code and it will fail every single time (at least, I've been able to reproduce 100%).
|
@hhblaze Another note: this only reproduces in the case where there are multiple tables involved. Looking at the code it appears that it is possible for it to occur even in the case of a single session but I haven't been able to reproduce it as such. It also appears that the system eventually recovers since later requests function correctly. |
Very well, will take a look |
Issue was fixed in uploaded version 1.073. Please, try it. |
@hhblaze I've merged your changes into our fork and it appears to be working well! I'll let you know if we run into other issues but the fix looks good! Thanks! |
Good luck! |
We are getting OverflowExceptions intermittently. It does not happen often but it's been reproduced a number of times by different machines meaning it is not an isolated incident. You'll find the stack below.
We're using <string, byte[]> for key/value store (string for key, byte[] since it's a custom serializer using JSON.NET).
Only occurs during execution. If we reload the database from the disk, the error no longer occurs.
The text was updated successfully, but these errors were encountered: