Skip to content
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

Q: what does "Object has already been returned to this pool or is invalid" mean in lock #71

Open
podholadavid opened this issue Sep 27, 2024 · 5 comments

Comments

@podholadavid
Copy link

podholadavid commented Sep 27, 2024

Hi,

great library, thanks a ton for that!

What I am observing in the production environment is, getting this exception

Failsafe suppressed exception.
java.lang.IllegalStateException: Object has already been returned to this pool or is invalid
at org.apache.commons.pool2.impl.BaseGenericObjectPool.markReturningState(BaseGenericObjectPool.java:1251)
at org.apache.commons.pool2.impl.GenericObjectPool.returnObject(GenericObjectPool.java:1029)
at io.lettuce.core.support.ConnectionPoolSupport$1.returnObject(ConnectionPoolSupport.java:129)
at io.lettuce.core.support.ConnectionPoolSupport$1.returnObject(ConnectionPoolSupport.java:117)
at com.himadieiev.redpulsar.lettuce.abstracts.AbstractLettucePooled.executeSync(AbstractLettucePooled.kt:81)
at com.himadieiev.redpulsar.lettuce.LettucePooled.sync(LettucePooled.kt:37)
at com.himadieiev.redpulsar.lettuce.locks.backends.LettuceLocksBackend.setLock(LettuceLocksBackend.kt:21)
at com.himadieiev.redpulsar.core.locks.abstracts.AbstractLock.lockInstance(AbstractLock.kt:27)
at com.himadieiev.redpulsar.core.locks.SimplifiedMutex.lock(SimplifiedMutex.kt:39)

when trying to lock. Any idea what that can mean and how should I fix that?

Thanks in advance!

@himadieievsv
Copy link
Owner

Hi there! Thanks for stoping by Redpulsar.
Let me get back to you after some investigation.
Can you also share your use case and connection pool config?

@podholadavid
Copy link
Author

The use case is to run a SimplifiedMutex to stop other pods from executing a computing heavy method.
I am not seeing any pool configuration in the code so I assume we use some defaults.

@himadieievsv
Copy link
Owner

Since ObjectPool manages connection in the pool, best thing to do it let it manage.
I attempted to handle IllegalStateException that is caused by borrowed object is not in correct state in v1.3.2 .

Please try using the newest lib: implementation("com.himadieiev:redpulsar-lettuce:1.3.2")

I also recommend to set pool size, by default it have only 8 connections. Here is example in kotlin how to do it:
https://github.com/himadieievsv/distributed-locks/blob/26212f357310e028740115fd962f3a9aa4e20be0/redpulsar-lettuce/src/test/kotlin/TestCommons.kt#L49-L56
Java example is similar, just use setters instead of apply()

@podholadavid
Copy link
Author

Thanks a lot, really impressed.
We will both try the new version and actually set the pool size.

@podholadavid
Copy link
Author

Just wanted to follow-up here, we use the new version, works fine, was not able to update the pool size tho 🙈

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

No branches or pull requests

2 participants