You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have found a race condition when you create a SQSSession and inmediatly close it (For example when I only send a message I don't need any thread for listen messages).
In a production system after 2 days sending around 10000 messages, I have more than 100 threads in waiting state in line 102 of SQSSessionCallbackScheduler class (I see it using jstack command)
At construct a SQSSession, it construct an object SQSSessionCallbackScheduler and execute in a ExecutorService object tha make a thread. So, I have 2 threads: main thread and SQSSessionCallbackScheduler thread, the execution order is:
SQSSessionCallbackScheduler thread check "closed" variable and it is false (line 95 to line 97), context switch occurs
before the synchronized section in line 98.
main thread call close() method, change "closed" variable to true
main thread enter to synchronized section
main thread call notify() and it is never received by the QSSessionCallbackScheduler thread
main thread exit of synchronized section, context switch occurs
SQSSessionCallbackScheduler thread enter to synchronized section (line 98)
That looks similar to what I saw during an AWS SQS outage a couple of days ago, where the DNS lookup of the SQS endpoint were failing with UnknownHostException. The number of threads was rising very quickly until OOM errors occured after 15 minutes - reaching 30k of those threads. Since the DNS lookup fails quickly, I guess it has the same issue like explained here. I will take a deeper look.
I have found a race condition when you create a SQSSession and inmediatly close it (For example when I only send a message I don't need any thread for listen messages).
In a production system after 2 days sending around 10000 messages, I have more than 100 threads in waiting state in line 102 of SQSSessionCallbackScheduler class (I see it using jstack command)
At construct a SQSSession, it construct an object SQSSessionCallbackScheduler and execute in a ExecutorService object tha make a thread. So, I have 2 threads: main thread and SQSSessionCallbackScheduler thread, the execution order is:
before the synchronized section in line 98.
I propose check "closed" variable too into the synchronized section (after line 98)


I attach an image of code explaining it.
The text was updated successfully, but these errors were encountered: