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

fixed ObjectPoolMaxLimitReachedException for many reader threads #1737

Merged
merged 2 commits into from Jan 4, 2019

Conversation

2 participants
@MadKat13
Copy link
Contributor

MadKat13 commented Oct 3, 2018

I posted my error here before:
GoogleGroup

So basically we have a high load of reading events from EventStore. So we need more reader threads. But when we use E.g. 16 Threads (ReaderThreadsCount=16) we have a lot of
Object pool 'ReadIndex readers pool' has reached its max limit for items: 14 logs.

I changed the creation of the readerPool to take notice of how many reader threads are needed.

It should basically work, but I'm not 100% sure.

@shaan1337

This comment has been minimized.

Copy link
Member

shaan1337 commented Nov 5, 2018

@MadKat13 Thanks for your PR, we're going to go through it asap. We're sorry it took so long to get back to you, we were in a migration phase. Could you please rebase your changes against origin/master please ?

@Lougarou Lougarou requested a review from gregoryyoung Nov 13, 2018

@MadKat13 MadKat13 force-pushed the MadKat13:fix-reader-thread-pool branch from 86a1706 to 77c12d5 Nov 14, 2018

@MadKat13

This comment has been minimized.

Copy link
Contributor

MadKat13 commented Nov 14, 2018

Sorry @shaan1337 that it took me so long to rebase my branch. Now it's up to date and I hope it fixes the issue.

@shaan1337

This comment has been minimized.

Copy link
Member

shaan1337 commented Nov 16, 2018

@MadKat13 thanks!

@MadKat13

This comment has been minimized.

Copy link
Contributor

MadKat13 commented Dec 18, 2018

I reverted my naming changes of the ESConst. So now the checks succeed and It's open for @gregoryyoung to check.

@shaan1337 shaan1337 self-requested a review Jan 4, 2019

@shaan1337
Copy link
Member

shaan1337 left a comment

Successfully reproduced the issue with code below:
multireader.zip

Also modified ObjectPool.cs to add a small delay of 10ms when returning items to the object pool to make the issue more likely to happen. You can also monitor the _count and _maxCount variables in ObjectPool.cs to see how it changes.

Steps:

  1. Run EventStore with --reader-threads-count 16
  2. Run multireader
  3. The following error will be thrown regularly:
    Object pool 'ReadIndex readers pool' has reached its max limit for items: 14.

The number of reader threads has a direct relationship with the number of requesters on the "ReadIndex readers pool" object pool:

for(var i=0;i<threadCount;i++){
readerWorkers[i] = new StorageReaderWorker(bus, readIndex, writerCheckpoint, i);

ESConsts.PTableMaxReaderCount needs some rework later on since StorageReaderThreadCount = 4 is not a constant.

        public const int PTableMaxReaderCount = 1 /* StorageWriter */
                                              + 1 /* StorageChaser */
                                              + 1 /* Projections */
                                              + 1 /* Scavenging */
                                              + 1 /* Subscription LinkTos resolving */
                                              + StorageReaderThreadCount
                                              + 5 /* just in case reserve :) */;

With this fix, we will actually have StorageReaderThreadCount = 4 in excess over the number of actual required object pool requesters. For now this solution is good enough as there is not much benefit in having tighter bounds.

@shaan1337 shaan1337 merged commit e35cae5 into EventStore:master Jan 4, 2019

@shaan1337

This comment has been minimized.

Copy link
Member

shaan1337 commented Jan 4, 2019

@MadKat13 thank you! the fix will be included in 5.0.0 RC2 and also backported to v4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment