Skip to content

Conversation

@geminiKim
Copy link
Contributor

@geminiKim geminiKim commented May 2, 2019

Hi :D
I found the bug that min-idle does not work when configure Lettuce with pool config.

You can find out why the problem occurred by looking below link.
https://commons.apache.org/GenericObjectPool.html#setMinIdle

This setting only has an effect if it is positive and BaseGenericObjectPool.getTimeBetweenEvictionRunsMillis() is greater than zero.

TimeBetweenEvictionRunsMillis need to configured greater then zero for the min-idle to working correctly.

Some users can trust settings and use them incorrectly in an environment that does not work properly.
So, I added that property, but I don't know if this is a perfectly good solution.

Please review and let me know what you think about this issue.
Thank you :)

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label May 2, 2019
@wilkinsona wilkinsona changed the title Fix a bug Lettuce min-idle config does not work Redis pooling minIdle property is ignored as timeBetweenEvictionRun defaults to -1 and cannot be configured May 3, 2019
@wilkinsona wilkinsona added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels May 3, 2019
@wilkinsona wilkinsona added this to the 2.1.x milestone May 3, 2019
Copy link
Member

@wilkinsona wilkinsona left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks very much for opening your first Spring Boot PR, @geminiKim. I've left a few comments suggesting some minor improvements that I think could be made.

config.setMaxTotal(properties.getMaxActive());
config.setMaxIdle(properties.getMaxIdle());
config.setMinIdle(properties.getMinIdle());
config.setTimeBetweenEvictionRunsMillis(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Jedis supports the same configuration property. Would you like to make the equivalent change there as well?

Copy link
Contributor Author

@geminiKim geminiKim May 3, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it does not the responsibility of Spring-Boot.
Spring-Boot configured the Jedis-Pool using the below code:

So, I think JedisPoolConfig is the responsibility of Jedis.
JedisPoolConfig sets the default value of TimeBetweenEvictionRunsMillis

https://github.com/xetorthio/jedis/blob/ef4ab403f9d8fd88bd05092fea96de2e9db0bede/src/main/java/redis/clients/jedis/JedisPoolConfig.java#L10

So, I'm not sure I should handle this equally.

I will wait for your opinion, Thank you for your fast feedback and thoughtful review :)

Copy link
Member

@wilkinsona wilkinsona May 3, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I'd missed that JedisPoolConfig sets the property already and, therefore, has a different default to Lettuce.

Unfortunately, this creates a problem as the Pool class is shared between Jedis and Lettuce configuration properties. As currently proposed here, the changes will result in a spring.redis.jedis.pool.time-between-eviction-runs property that has no effect. We need to figure out how to avoid that while also coping with the different defaults.

I think our best option is to declare the timeBetweenEvictionRuns property with a null default value and only map it onto the Lettuce or Jedis pool config if the value is non-null.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that it seems to be the best way now, I modified it.
Thank you for your clear and good feedback. 😄

assertThat(poolConfig.getMaxIdle()).isEqualTo(4);
assertThat(poolConfig.getMaxTotal()).isEqualTo(16);
assertThat(poolConfig.getMaxWaitMillis()).isEqualTo(2000);
assertThat(poolConfig.getTimeBetweenEvictionRunsMillis())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you like to make an equivalent change to the tests for configuring Jedis as well?

Copy link
Contributor Author

@geminiKim geminiKim May 3, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same discussion as comment

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made an equivalent change to the tests for configuring Jedis.

* When positive, the idle object evictor thread starts. When non-positive, no
* idle object evictor thread runs.
*/
private Duration idleEvictPeriod = Duration.ofMillis(-1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this name should align more closely with the setting that it maps to. Something like timeBetweenEvictionRuns, perhaps.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I totally agree with your opinion. 👍

private Duration maxWait = Duration.ofMillis(-1);

/**
* Time of milliseconds to sleep between runs of the idle object evictor thread.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As with the existing description for maxWait, the description shouldn't mention the unit (milliseconds in this case). Using Duration means that you can specify the time in any unit you want.

@geminiKim
Copy link
Contributor Author

geminiKim commented May 8, 2019

@wilkinsona I apologize for the mention.
I think this task is done. Do I have more to do?

And failing tests seem to fail for other reasons, I only worked Spring Boot AutoConfigure, but failing test module is Spring Boot Server Tests. (Oddly, that tests succeed on my local.)

@wilkinsona
Copy link
Member

No need to apologise. There's nothing more for you to do, I'm just a bit snowed under preparing for next week's Spring IO conference.

@geminiKim
Copy link
Contributor Author

Thank you for your quick feedback during the busy time. :D

@wilkinsona
Copy link
Member

@geminiKim Thank you very much for making your first contribution to Spring Boot. The proposed changes have been merged into 2.1.x and master along with a small polishing commit.

@geminiKim
Copy link
Contributor Author

@wilkinsona Thank you for your kind review in busy times. I will continue to contribute.

And i will cheer your session on Spring I/O. :D

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

Labels

type: bug A general bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants