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

IllegalStateException "Unbalanced enter/exit" in okio AsyncTimeout #1061

Closed
madisp opened this issue Apr 4, 2024 · 0 comments · Fixed by #1063
Closed

IllegalStateException "Unbalanced enter/exit" in okio AsyncTimeout #1061

madisp opened this issue Apr 4, 2024 · 0 comments · Fixed by #1063
Assignees
Labels
bug This issue is a bug. p2 This is a standard priority issue

Comments

@madisp
Copy link

madisp commented Apr 4, 2024

Describe the bug

Running lots of SQS client calls in parallel throws java.lang.IllegalStateException at AsyncTimeout.kt:58 when canceling the scope. Follow-up on my last few comments in #962 .

Expected Behavior

Exception not thrown

Current Behavior

Exception thrown :)

Steps to Reproduce

Start with an empty c7gd.xlarge instance running ami-0c5789c17ae99a2fa

Install java and docker:

sudo apt install default-jdk
sudo snap install docker
sudo groupadd docker
sudo usermod -aG docker $USER

(Reboot the ec2 instance at this point)

Clone the example project and run the tests:

git clone https://github.com/madisp/aws-kotlin-threads.git
cd aws-kotlin-threads
./gradlew test

Possible Solution

I think the issue is the Job#invokeOnCompletion call here -

. The completion handler will probably be called on the dispatcher thread of whoever is doing the cancel. ResponseBody.close will try to consume any unconsumed bytes and this can lead to multiple threads working with the same ResponseBody, correctly triggering a precondition check failure in AsyncTimeout.

Context

I'm using aws-sdk-kotlin in a backend project and was experimenting with the limits of SQS clients in a single process.

Your Environment

  • Smithy Kotlin version used: 1.1.1
  • Platform (JVM/JS/Native): JVM, Linux ARMv8
  • Operating System and version: Ubuntu 22.04 LTS Jammy running on c7gd.xlarge.
@madisp madisp added the bug This issue is a bug. label Apr 4, 2024
@madisp madisp changed the title IllegalStateException in okio AsyncTimeout IllegalStateException in Unbalanced enter/exit okio AsyncTimeout Apr 4, 2024
@madisp madisp changed the title IllegalStateException in Unbalanced enter/exit okio AsyncTimeout IllegalStateException "Unbalanced enter/exit" in okio AsyncTimeout Apr 4, 2024
@ianbotsf ianbotsf added the p2 This is a standard priority issue label Apr 4, 2024
@ianbotsf ianbotsf self-assigned this Apr 8, 2024
sullis pushed a commit to sullis/smithy-kotlin that referenced this issue Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. p2 This is a standard priority issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants