Ayende @ Rahien

My name is Oren Eini
Founder of Hibernating Rhinos LTD and RavenDB.
You can reach me by phone or email:


+972 52-548-6969

, @ Q c

Posts: 6,007 | Comments: 44,761

filter by tags archive

Didja know, RavenDB include a proxy server

time to read 1 min | 124 words

This is one of those things that I had to read several times to realize what was actually going on.

The code for that is here: https://github.com/ayende/ravendb/blob/c0c9ccf98011fb64b5eb5406a900ec1338ea78e4/Raven.Tests/Issues/RavenDB_1603.cs#L32

And it appears that along with every else, RavenDB also include a proxy server.

Now, to be fair, this is required for our tests, to see what happens when we have a forced disconnect / timeout at the network level, so it make sense. And the whole thing is under 100 lines of code.

This sort of thing explains why we really need to do a whole bunch of work on our tests. We want to get to a 500 – 1000 tests (currently we have close to 3,200) that run in under 5 minutes.



Nice proxy, and some clever use of async I yet have to get used to. But for a beginning, what's the difference between

var read = await incomingStream.ReadAsync(buffer, 0, 4096, token);


var read = incomingStream.Read(buffer, 0, 4096)

is the first one any better?

Andy Pook

It looks like there are a couple of "bugs". Two of the while(true) loops look like will never exit (except on exception). In Forward it should probably use "!cancellationTokenSource.IsCancellationRequested" In the writeTask it should probably "break" when "read == 0" as the readTask does. An "extract method" refactoring would help.

Without these I think there's a task leak. Though as this is "just test code" it's safe enough :)

Ayende Rahien

Rafal, The first one is better because it will yield the thread for the duration of the actual IO, leaving it free to do other work.

Comment preview

Comments have been closed on this topic.


No future posts left, oh my!


  1. Speaking (3):
    23 Sep 2015 - Build Stuff 2015 (Lithuania & Ukraine), Nov 18 - 24
  2. Production postmortem (11):
    22 Sep 2015 - The case of the Unicode Poo
  3. Technical observations from my wife (2):
    15 Sep 2015 - Disk speeds
  4. Find the bug (5):
    11 Sep 2015 - The concurrent memory buster
  5. Buffer allocation strategies (3):
    09 Sep 2015 - Bad usage patterns
View all series



Main feed Feed Stats
Comments feed   Comments Feed Stats