ConcurrentModificationException errors

So today I finally released by bot to production, which was scary because it meant going from 3 servers to 16k servers... so of course I expected errors. This error is popping up on various places on my bot when accessing stuff from Discord. I'm using: defaultStrategy = EntitySupplyStrategy.cacheWithCachingRestFallback. This is happening in various functions that interact with Discord data in some way, in the particular stacktrace I attached, it refers to this call:
private suspend fun EventContext<MemberLeaveEvent>.onMemberLeft() {
val world = nabBot.serverWorldMapping[event.guild.longId]
val botMember = event.guild.selfMember() // <-- this line
webhookManager.sendLogMessage(event.guild) {
// More code
}
}
private suspend fun EventContext<MemberLeaveEvent>.onMemberLeft() {
val world = nabBot.serverWorldMapping[event.guild.longId]
val botMember = event.guild.selfMember() // <-- this line
webhookManager.sendLogMessage(event.guild) {
// More code
}
}
event { action { onMemberLeft() } }
event { action { onMemberLeft() } }
This is happening in many different places, with stuff that interacts with the entity supplier or with Flows.
Solution:
Message Not Public
Sign In & Join Server To View
Jump to solution
48 Replies
gdude
gdude•6mo ago
That looks like a problem with Kord, so I'll have to defer to @Kord Team Members While you wait, make sure you're using the latest KordEx snapshot and not providing your own Kord version
Unknown User
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
SchlaubiBus
SchlaubiBus•6mo ago
We should as I published 0.5.1 a few days ago
Unknown User
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
SchlaubiBus
SchlaubiBus•6mo ago
yeah I think this was largely resolved by changing it in kord, however cache doesn't change it for now
Unknown User
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
Galarzaa
GalarzaaOP•6mo ago
I will give this a try I'm actually in the 1.8.0 SNAPSHOT, tried 1.8.1, but I was getting these issues: https://canary.discord.com/channels/1121419906995458098/1252310860551028767
Unknown User
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
gdude
gdude•6mo ago
you got that while matching the kordex build environment? is 0.5.1 not part of 0.14.0-SNAPSHOT?
Unknown User
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
gdude
gdude•6mo ago
was there a new cycle that I missed?
Unknown User
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
gdude
gdude•6mo ago
Oh huh, was the new cycle announced? Maybe I forgot about it
Unknown User
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
gdude
gdude•6mo ago
That's not explicit enough imo haha But yeah, fair
Unknown User
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
gdude
gdude•6mo ago
Yeah, I think there's been some releases I should test But I kinda wanna get a web PoC merged first before I go doing more mainline
Unknown User
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
gdude
gdude•6mo ago
Ah nice, that's good news Thanks
Galarzaa
GalarzaaOP•6mo ago
Just switched to temurin image, added useKSP2 and other gradle.properties flags you are using, Kotlin 1.9.22 But what I get is a different error:
114.5 Execution failed for task ':nabbot-discord-bot:kspKotlin'.
114.5 > A failure occurred while executing com.google.devtools.ksp.gradle.KspAAWorkerAction
114.5 > javaslang/collection/HashMap
114.5 Execution failed for task ':nabbot-discord-bot:kspKotlin'.
114.5 > A failure occurred while executing com.google.devtools.ksp.gradle.KspAAWorkerAction
114.5 > javaslang/collection/HashMap
(should I continue this specific discussion on the other thread or here?)
gdude
gdude•6mo ago
The other thread if you would
SchlaubiBus
SchlaubiBus•6mo ago
javaslang/collection/HashMap 🤔
gdude
gdude•6mo ago
Huh, yeah
SchlaubiBus
SchlaubiBus•6mo ago
running with --stacktrace might help
Galarzaa
GalarzaaOP•6mo ago
Ok, I got over the KSP2 issues, I'm on 1.81 snapshot now. I upgraded kotlin (and ksp) to 1.9.24 and that did it. Now, when trying to add kord cache, it is not resolved, am I missing a maven repository? I'm using the ones in Kord's README
Unknown User
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
SchlaubiBus
SchlaubiBus•6mo ago
The artifact stuff should be fixed in 5-10 mins, I am working on it, but Maven central changed their publishing and since different projects are on different hosts it caused issues
SchlaubiBus
SchlaubiBus•6mo ago
But the core issue should be fixed since this commit
SchlaubiBus
SchlaubiBus•6mo ago
0.5.3 should be available in around 10 minutes (maven central sync) and then it should work
Solution
Unknown User
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
Galarzaa
GalarzaaOP•6mo ago
So I tried with 0.5.3 and it builds fine, but it fails on startup
Galarzaa
GalarzaaOP•6mo ago
Galarzaa
GalarzaaOP•6mo ago
(fixed extension)
Unknown User
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
Galarzaa
GalarzaaOP•6mo ago
This is looking good, haven't seen any ConcurrentModificationExceptions so far, thanks!
SchlaubiBus
SchlaubiBus•6mo ago
I think the jdk concurrenthashmap can't even throw such an exception
Unknown User
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
SchlaubiBus
SchlaubiBus•6mo ago
I mean the ConcurrentMutableMap is called concurrent too I wonder how the ConcurrentHashMap works since it's supposed to be lock free
Unknown User
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
SchlaubiBus
SchlaubiBus•6mo ago
I wonder whether that's a jvm specific bug or a general stately bug
Unknown User
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
SchlaubiBus
SchlaubiBus•6mo ago
GitHub
java.util.ConcurrentModificationException:, even when using statel...
Exception java.util.ConcurrentModificationException: at java.util.ArrayList$Itr.next (ArrayList.java:860) at co.touchlab.stately.collections.ConcurrentMutableIterator$next$1.invoke (ConcurrentMutab...
Unknown User
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
SchlaubiBus
SchlaubiBus•6mo ago
that makes sense
Unknown User
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
SchlaubiBus
SchlaubiBus•6mo ago
LockSupport 👀 wonder how loom changes it
Unknown User
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
SchlaubiBus
SchlaubiBus•6mo ago
Yeah they rewrote LockSupport for loom they said that in some talks
Want results from more Discord servers?
Add your server