Server crash UUID lookup #28

Closed
opened 2015-07-09 13:32:24 -04:00 by Kakifrucht · 19 comments
Kakifrucht commented 2015-07-09 13:32:24 -04:00 (Migrated from github.com)

A player used /inv offlineplayer, which immediately hogged the servers main thread, resulting in a complete crash.
Thread dump stacktrace: http://pastebin.com/8bzySypz

A player used /inv offlineplayer, which immediately hogged the servers main thread, resulting in a complete crash. Thread dump stacktrace: http://pastebin.com/8bzySypz
lishid commented 2015-07-09 23:40:02 -04:00 (Migrated from github.com)

@ShadowRanger seems like the UUID util here. We should add a boolean that prevents the UUID util from looking it up from MC servers and instead rely on just local player lists.

@ShadowRanger seems like the UUID util here. We should add a boolean that prevents the UUID util from looking it up from MC servers and instead rely on just local player lists.
ShadowRanger commented 2015-07-10 00:58:48 -04:00 (Migrated from github.com)

Alright ill look into this a bit later today.

Alright ill look into this a bit later today.
ShadowRanger commented 2015-07-10 03:45:23 -04:00 (Migrated from github.com)

I can't seem to reproduce this problem. I know it's to do with the UUID fetcher system but is it for offline servers or something? Not sure what's causing the error because it currently falls back to using getOfflinePlayer for getting UUID's if it fails with the fetcher.

I can't seem to reproduce this problem. I know it's to do with the UUID fetcher system but is it for offline servers or something? Not sure what's causing the error because it currently falls back to using getOfflinePlayer for getting UUID's if it fails with the fetcher.
lishid commented 2015-07-10 04:14:15 -04:00 (Migrated from github.com)

We shouldn't be doing network calls from the Main thread. If the internet gets slow, or stuck, then we would be stalling the whole server...

We shouldn't be doing network calls from the Main thread. If the internet gets slow, or stuck, then we would be stalling the whole server...
ShadowRanger commented 2015-07-10 04:17:59 -04:00 (Migrated from github.com)

UUIDFetcher runs on a separate thread already, not sure why it would be running on the main?

UUIDFetcher runs on a separate thread already, not sure why it would be running on the main?
lishid commented 2015-07-10 04:19:33 -04:00 (Migrated from github.com)

I don't think it's running on another thread. At least not according to the trace or the code.

I don't think it's running on another thread. At least not according to the trace or the code.
ShadowRanger commented 2015-07-10 04:22:18 -04:00 (Migrated from github.com)

The UUIDFetcher is run through a Callable, so whenever it's call() method is executed, it should perform the logic on another thread.

The UUIDFetcher is run through a Callable, so whenever it's call() method is executed, it should perform the logic on another thread.
lishid commented 2015-07-10 04:23:54 -04:00 (Migrated from github.com)

A callable is only an interface, so there's nothing that actually spawns a separate thread. The stacktrace also passes through directly:
com.lishid.openinv.utils.UUIDFetcher.writeBody(UUIDFetcher.java:57)
com.lishid.openinv.utils.UUIDFetcher.call(UUIDFetcher.java:40)
com.lishid.openinv.utils.UUIDUtil.getUUIDOf(UUIDUtil.java:51)

A callable is only an interface, so there's nothing that actually spawns a separate thread. The stacktrace also passes through directly: com.lishid.openinv.utils.UUIDFetcher.writeBody(UUIDFetcher.java:57) com.lishid.openinv.utils.UUIDFetcher.call(UUIDFetcher.java:40) com.lishid.openinv.utils.UUIDUtil.getUUIDOf(UUIDUtil.java:51)
lishid commented 2015-07-10 04:25:37 -04:00 (Migrated from github.com)

Even if we implement a threading model, we still need to wait on the thread to finish the call to get the result, which is horrible either way since we stall the main thread. I recommend a flag that would restrict getting UUID to only local players, and set it to true when we are on the main thread (handling any events and commands)

Even if we implement a threading model, we still need to wait on the thread to finish the call to get the result, which is horrible either way since we stall the main thread. I recommend a flag that would restrict getting UUID to only local players, and set it to true when we are on the main thread (handling any events and commands)
ShadowRanger commented 2015-07-10 04:31:28 -04:00 (Migrated from github.com)

Yeah right sorry I think I'm confusing myself. Didn't realize it was being run on the main thread.

What if we run the fetcher async with the Bukkit scheduler instead?

Yeah right sorry I think I'm confusing myself. Didn't realize it was being run on the main thread. What if we run the fetcher async with the Bukkit scheduler instead?
lishid commented 2015-07-10 04:40:56 -04:00 (Migrated from github.com)

The problem is that we need it to return the result to the caller of the method, and there's no way that the value is returned instantly since we need to wait for the network call to succeed, but we can't do any waiting on the main thread at all without potentially impacting TPS. I think because of this we'll have to skip the network fetch if we're on the main thread.

The problem is that we need it to return the result to the caller of the method, and there's no way that the value is returned instantly since we need to wait for the network call to succeed, but we can't do any waiting on the main thread at all without potentially impacting TPS. I think because of this we'll have to skip the network fetch if we're on the main thread.
ShadowRanger commented 2015-07-10 04:55:15 -04:00 (Migrated from github.com)

Alright yeah, I understand what you're saying. I'll see what I can produce and let you know how it goes.

Alright yeah, I understand what you're saying. I'll see what I can produce and let you know how it goes.
ShadowRanger commented 2015-07-10 04:58:46 -04:00 (Migrated from github.com)

As for determining whether or not we're on the main thread, do you think using Bukkit.getServer().isPrimaryThread() could be a good option instead of a custom system using flags when running events/commands?

As for determining whether or not we're on the main thread, do you think using Bukkit.getServer().isPrimaryThread() could be a good option instead of a custom system using flags when running events/commands?
lishid commented 2015-07-10 05:16:58 -04:00 (Migrated from github.com)

That sounds ok as well, but I'd say that having an explicit option means
that we can control it if we're on another thread but don't want to be
blocked. Either way it should be fine.
On Jul 10, 2015 1:58 AM, "ShadowRanger" notifications@github.com wrote:

As for determining whether or not we're on the main thread, do you think
using Bukkit.getServer().isPrimaryThread() could be a good option instead
of a custom system using flags when running events/commands?


Reply to this email directly or view it on GitHub
https://github.com/lishid/OpenInv/issues/28#issuecomment-120305765.

That sounds ok as well, but I'd say that having an explicit option means that we can control it if we're on another thread but don't want to be blocked. Either way it should be fine. On Jul 10, 2015 1:58 AM, "ShadowRanger" notifications@github.com wrote: > As for determining whether or not we're on the main thread, do you think > using Bukkit.getServer().isPrimaryThread() could be a good option instead > of a custom system using flags when running events/commands? > > — > Reply to this email directly or view it on GitHub > https://github.com/lishid/OpenInv/issues/28#issuecomment-120305765.
ShadowRanger commented 2015-07-10 05:29:08 -04:00 (Migrated from github.com)

Okay so doing it with flags would you mean something like having a static boolean in the OpenInv main class and then set it to true before any of our logic is executed in the listeners and commands and then back to false once finished?

Okay so doing it with flags would you mean something like having a static boolean in the OpenInv main class and then set it to true before any of our logic is executed in the listeners and commands and then back to false once finished?
lishid commented 2015-07-10 05:30:22 -04:00 (Migrated from github.com)

Can't we just add a parameter to the call...
On Jul 10, 2015 2:29 AM, "ShadowRanger" notifications@github.com wrote:

Okay so doing it with flags would you mean something like having a static
boolean in the OpenInv main class and then set it to true before any of our
logic is executed in the listeners and commands and then back to false once
finished?


Reply to this email directly or view it on GitHub
https://github.com/lishid/OpenInv/issues/28#issuecomment-120317821.

Can't we just add a parameter to the call... On Jul 10, 2015 2:29 AM, "ShadowRanger" notifications@github.com wrote: > Okay so doing it with flags would you mean something like having a static > boolean in the OpenInv main class and then set it to true before any of our > logic is executed in the listeners and commands and then back to false once > finished? > > — > Reply to this email directly or view it on GitHub > https://github.com/lishid/OpenInv/issues/28#issuecomment-120317821.
ShadowRanger commented 2015-07-10 05:33:20 -04:00 (Migrated from github.com)

Sorry if I sound ignorant but a parameter to which call?

Sorry if I sound ignorant but a parameter to which call?
lishid commented 2015-07-10 05:35:07 -04:00 (Migrated from github.com)

Oh I mean when you call UUIDUtil, pass an extra boolean flag.
On Jul 10, 2015 2:33 AM, "ShadowRanger" notifications@github.com wrote:

Sorry if I sound ignorant but a parameter to which call?


Reply to this email directly or view it on GitHub
https://github.com/lishid/OpenInv/issues/28#issuecomment-120319530.

Oh I mean when you call UUIDUtil, pass an extra boolean flag. On Jul 10, 2015 2:33 AM, "ShadowRanger" notifications@github.com wrote: > Sorry if I sound ignorant but a parameter to which call? > > — > Reply to this email directly or view it on GitHub > https://github.com/lishid/OpenInv/issues/28#issuecomment-120319530.
Kakifrucht commented 2015-07-20 22:30:45 -04:00 (Migrated from github.com)

Thanks for fixing it, I guess this can be closed?

Thanks for fixing it, I guess this can be closed?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: minster586/OpenInv#28
No description provided.