bchavez / RethinkDb.Driver

:headphones: A NoSQL C#/.NET RethinkDB database driver with 100% ReQL API coverage.
http://rethinkdb.com/api/java
Other
384 stars 134 forks source link

Consistency issues. #24

Closed mrinc closed 8 years ago

mrinc commented 8 years ago
while (true) {
  Console.Write("START");
  var _r = RethinkDB.r;
  var conn = _r.connection()
      .hostname("IP")
      .port(RethinkDBConstants.DEFAULT_PORT)
      .timeout(60)
      .connect();
  var x = _r.db("DB")
      .table("TABLE")
      .count();
  long resCount = x.run(conn);
  Console.Write(" - C: " + resCount);
  conn.close();
  conn = null;
  _r = null;
  Console.WriteLine("FINISH");
  Console.WriteLine();
  Console.WriteLine();
}

So with that code I keep getting

"An unhandled exception of type 'System.AggregateException' occurred in mscorlib.dll
Additional information: One or more errors occurred."
Inner: 
Object reference not set to an instance of an object.
"   at RethinkDb.Driver.Net.SocketWrapper.SendQuery(Int64 token, String json, Boolean awaitResponse)
   at RethinkDb.Driver.Net.Connection.SendQuery(Query query, Boolean awaitResponse)
   at RethinkDb.Driver.Net.Connection.<RunQueryAsync>d__30`1.MoveNext()"

Any ideas why?

Thanks

bchavez commented 8 years ago

Hi there. What version are you using? CoreCLR or Full?

bchavez commented 8 years ago

I created a unit test with your code, and I'm not seeing any AggregateException on an empty table.

I also ran your test in 4 parallel threads and still cant reproduce the issue. Anymore information you can provide to help reproduce the issue would be very helpful.

mrinc commented 8 years ago

Hey,

Thanks for the quick reply.

I installed the ReThinkDb.Driver v2.2.3

Not sure which one is included in the nuget package.

Thanks

bchavez commented 8 years ago

I cant seem to reproduce the error. Do you have a sample project I could use to test?

mrinc commented 8 years ago

Uploaded csproj - https://onedrive.live.com/redir?resid=4581A44EC3B61ED9!351940&authkey=!AB0RzlgUXltaI4A&ithint=file%2czip

Could it be my server is out of date or something?

bchavez commented 8 years ago

@mrinc , thanks so much for your sample project. I'm able to reproduce the issue. Seems to be concurrency related with using TPL. Give me a few to investigate. I'll keep you updated.

bchavez commented 8 years ago

Hey @mrinc , thanks for reporting this. This one was a tricky bug. Basically, we were late setting a CancellationToken in that tight loop which caused the null reference exception.

This should be fixed in 2.2.4 Full .NET Framework and 2.2.4-beta-1 for CoreCLR.

Please let me know if it fixes your issue.

mrinc commented 8 years ago

A+

All looks good on my side :)

Thanks for the help!