SimpleClans icon indicating copy to clipboard operation
SimpleClans copied to clipboard

Discord, duplicating clan channels at reboot

Open TomLewis opened this issue 1 year ago • 9 comments

Describe the bug I had this bug previously, https://github.com/RoinujNosde/SimpleClans/issues/434 And it was disagnosed as Clan channels duplicating along with simpleclans needing to be the latest dev build.

After reboot yesterday, SimeplClans randomly decided to create a bunch of duplicates for a clan "ee", nothing has changed on the server or discord, it just decided to do it at reboot.

Theres a bug somewhere thats duplicating channels, and in this case its created 3 all at once for one clan, this in turn breaks ALL of the discod chat for every single clan, not just this clan.

Can we please get some logic thats checking for existing channels, there must be some sort of API issue with discord that happens randomly, and then you tell it to make new channels over and over until it can check it exists, and then theres 3 or 4 etc.

image

To Reproduce Steps to reproduce the behavior:

  1. Reboot the server

Expected behavior To not do this

Software (please complete the following information):

  • Server: Purpur 1.18.2
  • Plugin version 427

TomLewis avatar Aug 05 '24 20:08 TomLewis

Can I ask you to enable SimpleClans' debug and try to reproduce your issue? SimpleClans should throw an error in console when there are duplicated channels appears at server boot.

Tomut0 avatar Aug 05 '24 23:08 Tomut0

Are you running SimpleClans in 3 servers? All connected to the same Discord server?

RoinujNosde avatar Aug 06 '24 16:08 RoinujNosde

Are you running SimpleClans in 3 servers? All connected to the same Discord server?

Nope, just 1 server.

Can I ask you to enable SimpleClans' debug and try to reproduce your issue?

Yeah sure, its already on from the last issue! haha

https://gist.github.com/TomLewis/bddcda8ec67c035aa4457b134f1b3153

And boot https://gist.github.com/TomLewis/7036d0a2b38d318fa595dd1488a675db

TomLewis avatar Aug 06 '24 17:08 TomLewis

You told us those discord channels were created on boot, However, I am sure they were created earlier. It follows from the error exception you sent us:

java.lang.IllegalStateException: Duplicate key ee (attempted merging values <#1092075569082015764> and <#1269260858488389694>)

Which means SimpleClans somehow passed through 2 layers of protection: 1 Layer: It removes already used discord channels from the creation. 2 Layer: It actually does checking on channel existence before the creation.

I am going to add some more debug messages to this process at #437.

Tomut0 avatar Aug 06 '24 18:08 Tomut0

Weird! Sounds good to me, If you add debug messages at boot at every stage to output to console, then I can wait for my reboot and see what its checking for what and I can report back, then we can see if its doing things at the right time!

Does it cache these channels from discord or is it doing a fresh check each reboot? Because these discord channels shouldnt ever be touched outside of this plugin by anything or anyone, silly question but shouldnt each discord channel have an ID thats unique? then each clan can just have that as their discord channel ID, and not its name being unique, that solves the bug where if there is another channel created its not going to fully break.

I just dont know how you solve bad API calls back from discord, if they are temp down, or if theres some sort of issue in the pipeline if its checking for a channel to see if it exists already and keeps trying..

TomLewis avatar Aug 08 '24 11:08 TomLewis

clan can just have that as their discord channel ID, and not its name being unique

It was made on purpose. Storing Clan <-> Discord ID in a separated file or in config.yaml is an unnecessary I/O task.

how you solve bad API calls back from discord, if they are temp down

It actually doesn't happen much, but even so, simple server restart should fix any troubles.

Tomut0 avatar Aug 08 '24 14:08 Tomut0

@TomLewis It was just merged, can you try it? It was uploaded on Jenkins.

Tomut0 avatar Aug 08 '24 15:08 Tomut0

Sorry, I completely forgot about this.

So I just noticed today, I have 6 new channels for the Crew "EE" image

So I wondered, if its always EE why not see if a crew leader is running the command.

Looked on my coreprotect web UI and, low and behold a crew leader for EE is spamming the command, ignore their username, the coreprotect web UI is ancient and displays old usernames.

image

They used it 7 times, but when I look at my log, there is no simpleclans feedback on what its doing.

[10:36:39] [Server thread/INFO]: Tulipss issued server command: /crew discord create
[10:36:39] [Server thread/INFO]: [Matrix] (Via) Player Exoticial joined with (1.21.X/767) client
[10:36:41] [Server thread/INFO]: Tulipss issued server command: /crew discord create
[10:36:42] [Async Chat Thread - #1/INFO]: *--------- Rule match (chat) for Nick_A_Naut --------- 
[10:36:42] [Async Chat Thread - #1/INFO]: MATCH: \bwb\b
[10:36:42] [Async Chat Thread - #1/INFO]: CATCH: wb
[10:36:42] [Async Chat Thread - #1/INFO]: UPDATE: welcome back
[10:36:42] [Async Chat Thread - #1/INFO]: [global] Nick_A_Naut: welcome back
[10:36:42] [Async Chat Thread - #1/INFO]: [global] Dim30: I am back
[10:36:42] [Server thread/INFO]: Tulipss issued server command: /crew discord create
[10:36:43] [Server thread/INFO]: Tulipss issued server command: /crew discord create

so now, im thinking, maybe its stuck somewhere doing a check when they run the command, its also suppose to charge them to do this, but I can't see any logs that that, happened either.

Im going to ask the player why they did this and what feedback they had from the plugin, otherwise im in the dark with no logs in the console.

but thought I would update as this popped out to me today!

I will get that jenkins build added now for tomorrows reboot.

TomLewis avatar Aug 16 '24 20:08 TomLewis

if you have enabled show-debug-info in SimpleClans config and use the latest development build (from Jenkins). You should see something like this after command execution:

[23:52:23 INFO]: Tomut0 issued server command: /clan discord create
[23:52:23 INFO]: [SimpleClans] [51] Creating a discord text channel for test clan
[23:52:23 INFO]: [SimpleClans] Added view permission to null (194521791824265216) discord member
[23:52:23 INFO]: [SimpleClans] Added leader role to null (194521791824265216) discord member

However, if the clan was already created, it will return nothing to the console.

Tomut0 avatar Aug 16 '24 20:08 Tomut0

We still have issues where players can re-run the command and it creates another channel, in turn this breaks Crew chat entirely, so they are using it to grief the server as it breaks a fundamental part of using crews.

TomLewis avatar Nov 15 '24 23:11 TomLewis

We still have issues where players can re-run the command and it creates another channel, in turn this breaks Crew chat entirely, so they are using it to grief the server as it breaks a fundamental part of using crews.

Still waiting for debug info. 😄

Tomut0 avatar Nov 16 '24 01:11 Tomut0