spand
04/02/2025, 8:47 AM<http://Dispatchers.IO|Dispatchers.IO>
?
Context: I am debugging a deadlocked application. I have a threaddump with 96 ( = number of cores) DefaultDispatcher-worker
threads all locked doing IO but I am unsure if they are running on Dispatchers.Default
(which is obviously a problem) or <http://Dispatchers.IO|Dispatchers.IO>
since the documentation mentions that they share threads.spand
04/02/2025, 9:01 AMDispatchers.Default
thread set ? (in debugger, hacky way or otherwise). I assume there isnt a public Map<Thread,CoroutineContext>
map anywhere.ephemient
04/02/2025, 10:52 AMinternal
protections to call)ephemient
04/02/2025, 10:57 AMval isIO = Class.forName("kotlinx.coroutines.EventLoopKt").getDeclaredMethod("isIoDispatcherThread", Thread::class.java)
for (thread in Thread.getAllStackTraces().keys) {
println("$thread isIO=${isIO.invoke(null, thread)}")
}
Joe
04/03/2025, 12:43 AMcoroutineContext[CoroutineDispatcher].toString() !== "<http://Dispatchers.IO|Dispatchers.IO>"
from within a suspend function. you mention "thread in non suspend code" so not sure this helpsspand
04/03/2025, 6:36 AMephemient
04/03/2025, 9:06 AMephemient
04/03/2025, 9:08 AMlimitedParallelism
view of IO for itspand
04/03/2025, 9:10 AMephemient
04/03/2025, 9:13 AMspand
04/03/2025, 9:23 AMuli
04/03/2025, 9:33 AM// 100 threads for MySQL connection
val myMysqlDbDispatcher = Dispatchers.IO.limitedParallelism(100)
// 60 threads for MongoDB connection
val myMongoDbDispatcher = Dispatchers.IO.limitedParallelism(60)