Skip to content

Conversation

yapei123
Copy link

  • Change JedisFactory to public
  • add a new method to reset password

@marcosnils
Copy link
Contributor

dupe of #1605 ?

@yapei123
Copy link
Author

yapei123 commented Sep 13, 2017

@marcosnils I removed that branch since of something messed up. I have closed #1605.

@yapei123
Copy link
Author

yapei123 commented Sep 13, 2017

@marcosnils I would love to add it to JedisCluster also add tests. Can I have some helps from you or other members on how to run the tests? I've tried to run 'make start', 'make test' but failed.

@marcosnils
Copy link
Contributor

@yapei123 sure, please share your erros and I'll try to help you to get the tests passed.

@marcosnils
Copy link
Contributor

@yapei123 do you have maven installed?. Seems like the makefile is complaining that maven is not installed. Which linux distribution are you using?

@marcosnils
Copy link
Contributor

@yapei123 maybe some weird race condition or something. If tests pass on you IDE then it's ok. Is this PR ready to be reviewed?. Can you please squash the commits?

@marcosnils
Copy link
Contributor

As you can see this PR has 15 commits. It's simpler to review if you just squash them all together and you just send few of them. Check https://stackoverflow.com/questions/5189560/squash-my-last-x-commits-together-using-git

@yapei123 yapei123 force-pushed the master branch 6 times, most recently from 59f4f03 to 15aadd1 Compare September 15, 2017 23:04
@yapei123
Copy link
Author

@marcosnils just realized the JedisCluster might not be able to add the feature of 'reset password at runtime' since the JedisFactory needs to be created for each node and put into a List and it's hard to get hold of the JedsFactory for each node.

@yapei123 yapei123 force-pushed the master branch 7 times, most recently from a5370bb to 404d4d6 Compare September 22, 2017 06:59
@yapei123
Copy link
Author

ready for code reviewing. Thanks!

@chrisribble
Copy link

It would be really cool to get this merged so that an application can update the Redis password at runtime. @marcosnils is there anything holding up merging this?

Copy link
Contributor

@HeartSaVioR HeartSaVioR left a comment

Choose a reason for hiding this comment

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

Left minor comments but overall LGTM. @marcosnils Please continue review this.

Copy link
Contributor

Choose a reason for hiding this comment

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

add fail() below pool.getResource()

Copy link
Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's wrap with try-catch and remove expected statement. The test will pass even JedisConnectionException is thrown from obj1.

Copy link
Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's wrap with try-catch and remove expected statement. The test will pass even JedisConnectionException is thrown from obj1.

Copy link
Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor

Choose a reason for hiding this comment

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

add fail() below pool.getResource()

Copy link
Author

Choose a reason for hiding this comment

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

done

@HeartSaVioR HeartSaVioR added this to the 2.10.0 milestone Oct 22, 2017
@yapei123 yapei123 force-pushed the master branch 2 times, most recently from f04f266 to fb581c7 Compare October 23, 2017 16:01
@sazzad16
Copy link
Contributor

@chrisribble IMO, both scenarios should be successful. Choosing only one doesn't sound right to me.

Waiting for your response on my query about creating new pool.

@yapei123 yapei123 force-pushed the master branch 2 times, most recently from b6b0a07 to 813cb62 Compare January 24, 2018 17:22
@yapei123
Copy link
Author

yapei123 commented Jan 24, 2018

@chrisribble @sazzad16 There are two tests: one tests resetting password from bad to good, another from good to bad. The first one has no issue.

@chrisribble
Copy link

@sazzad16 Yes, the purpose of this PR is to avoid creating a new pool when you want to change the password that is used for new connections (resources).

The purpose of the PR is not to force the existing resources to be closed/released/etc when the password is changed.

Instead of creating a new pool in the test, what if we request a second resource while holding the first resource? That will ensure that the pool has to create a new connection with the bad password.

Sequence of actions:

  1. Create pool with good password
  2. Request resource
  3. Pool uses good password to make connection
  4. Pool adds resource to pool and hands out to caller
  5. Change password to bad password
  6. Without closing first resource (and thus avoiding release back to pool), request another resource
  7. Pool uses bad password to attempt to make connection
  8. Pool throws exception and caller verifies thrown

How does that sound?

@yapei123 yapei123 force-pushed the master branch 2 times, most recently from a875867 to 5394045 Compare January 24, 2018 22:14
@sazzad16
Copy link
Contributor

@chrisribble

Without closing first resource (and thus avoiding release back to pool), request another resource

I'm strongly against this idea that already requested resources would enforced to be unclosed for a valid operation in Pool.getResource(). I hope you'd understand my viewpoint.

PS: This is my own view. Other collaborators may agree with you. We can wait for them to respond.

@chrisribble
Copy link

chrisribble commented Jan 27, 2018

@sazzad16 I guess I don't understand completely because it's not that the underlying code has to enforce that the requested resource is unclosed; it's just that there's no straightforward way to validate that the password has been changed without keeping the previously-requested resource unclosed because there is no external way for the caller to tell the pool to evict a closed resource.

Without the closed (released) resource being evicted from the pool, we will get it again the next time we call getResource. Do you have any other ideas on a safe way to evict the resource from the pool without resorting to clearing the entire pool?

I think maybe it's a mistake to be writing a test for this behavior (switching good password to bad password) using JedisPool and that the test should be directly validating the behavior on JedisFactory. What do you think?

@gkorland gkorland modified the milestones: 2.10.0, 3.1.0 Dec 6, 2018
Copy link
Contributor

@sazzad16 sazzad16 left a comment

Choose a reason for hiding this comment

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

@yapei123 I know it has been a long time, but would you be able to address change requests only within this review?

JedisPool pool = new JedisPool(new JedisPoolConfig(), factory);
Jedis obj = null;
try {
pool.getResource();
Copy link
Contributor

Choose a reason for hiding this comment

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

Get this resource and close it properly, just to avoid any possible connection leak.

JedisSentinelPool pool = new JedisSentinelPool(MASTER_NAME, sentinels, new JedisPoolConfig(), factory);
Jedis obj = null;
try {
pool.getResource();
Copy link
Contributor

Choose a reason for hiding this comment

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

Get this resource and close it properly, just to avoid any possible connection leak. try-with-resources can be used for convenience.

fail("Could not get resource from pool");
} catch (JedisConnectionException e) {
factory.setPassword("foobared");
obj = pool.getResource();
Copy link
Contributor

Choose a reason for hiding this comment

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

Close obj within this catch block. Optionally, you can declare obj (aka Jedis obj = pool.getResource();) here with/without try-with-resources.

fail("Could not get resource from pool");
} catch (JedisConnectionException e) {
factory.setPassword("foobared");
obj = pool.getResource();
Copy link
Contributor

Choose a reason for hiding this comment

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

Close obj within this catch block. Optionally, you can declare obj (aka Jedis obj = pool.getResource();) here with/without try-with-resources.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants