games647 / FastLogin

Checks if a minecraft player has a valid paid account. If so, they can skip offline authentication automatically. (premium auto login)
https://www.spigotmc.org/resources/fastlogin.14153
MIT License
494 stars 121 forks source link

Connection is not available #1022

Open SoyDary opened 1 year ago

SoyDary commented 1 year ago

What happened?

When players try to log in, an error is displayed on the console saying that the connection is not available, but this only happens if the players do not have /premium activated. I tried increasing the timeout or using another database, but it didn't work. The plugin starts correctly and does not show any errors but when someone tries to join it happens that.

All this started to happen after updating the waterfall to the latest version

What did you expect?

That the plugin works correctly

Steps to reproduce

connect with a non-premium account to server waterfall #520

Plugin list

floodgate, Geyser, ServerUtils, minimotd, LuckPerms, SkinsRestorer, FastLogin

Configuration file

https://hastebin.com/share/biyewupuyo.yaml

Server log

https://hastebin.com/share/ovijozemov.csharp

Plugin version

1.12-SNAPSHOT-7d7d91f

Platform

BungeeCord

Relevance

games647 commented 1 year ago

Could you test this version? FastLogin-database-leak.zip

I added a leak detection that should warn if an invalid connection doesn't get removed and updated the database pool library, which should detect more invalid connections. The first test value is set to 2 seconds. So please let the server running for at least 1 min after the first connection.

SoyDary commented 1 year ago

https://hastebin.com/share/elabipihog.ruby

FabioZumbi12 commented 1 year ago

The same error here! Tha lest version who worked for me (i have only the version from logs, no more the jar) is FastLogin version 1.11-SNAPSHOT-f17f9d9

Did you have this version to we use for now? Tryed the legacy having the same error from @SoyDary

FabioZumbi12 commented 1 year ago

Forked the code and builded by myself:

[20:28:56 ERROR] [FastLogin]: Failed to query profile: FabioZumbi12
java.sql.SQLTransientConnectionException: FastLogin - Connection is not available, request timed out after 30001ms.
        at fastlogin.hikari.pool.HikariPool.createTimeoutException(HikariPool.java:696) ~[?:?]
        at fastlogin.hikari.pool.HikariPool.getConnection(HikariPool.java:197) ~[?:?]
        at fastlogin.hikari.pool.HikariPool.getConnection(HikariPool.java:162) ~[?:?]
        at fastlogin.hikari.HikariDataSource.getConnection(HikariDataSource.java:100) ~[?:?]
        at com.github.games647.fastlogin.core.storage.SQLStorage.loadProfile(SQLStorage.java:97) ~[?:?]
        at com.github.games647.fastlogin.core.shared.JoinManagement.onLogin(JoinManagement.java:53) ~[?:?]
        at com.github.games647.fastlogin.bungee.task.AsyncPremiumCheck.run(AsyncPremiumCheck.java:65) ~[?:?]
        at com.github.games647.fastlogin.core.AsyncScheduler.process(AsyncScheduler.java:70) ~[?:?]
        at com.github.games647.fastlogin.core.AsyncScheduler.lambda$runAsync$0(AsyncScheduler.java:61) ~[?:?]
        at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1804) ~[?:?]
        at net.md_5.bungee.scheduler.BungeeTask.run(BungeeTask.java:66) ~[waterfall-1.19-520.jar:git:Waterfall-Bootstrap:1.19-R0.1-SNAPSHOT:e0a029e:520]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?]
        at java.lang.Thread.run(Thread.java:833) ~[?:?]

Config:

# Single file SQLite database
driver: MySQL
host: localhost
port: --
database: fastlogin
username: --
password: --
games647 commented 1 year ago

Thank you, @SoyDary. That was helpful.

According to your server log, the connections get immediately stuck.

All this started to happen after updating the waterfall to the latest version

Wait a second. This is similar to #1002. This appears more like a driver issue than an error inside the FastLogin code, which I originally thought. Could you report which Waterfall you used before and using now, so I could bisect the origin.

@FabioZumbi12 Please report if this is also related to the Waterfall/BungeeCord version.

games647 commented 1 year ago

And here is another test version. This time with MySQL specific optimizations disabled. Maybe they trigger the bug.

FastLogin-leak-test-2.zip

I'll need the server log then again.

FabioZumbi12 commented 1 year ago

This is the waterfall version from logs where it worked: Waterfall-Bootstrap:1.18-R0.1-SNAPSHOT:8d64a1a:485

I just cant test if works because it wotn support 1.19 and i cant do a rollback.

FabioZumbi12 commented 1 year ago

I have made some changes on the way the connection is used and it seems to work for me. Check the https://github.com/FabioZumbi12/FastLogin/commit/2354bf1d690b6eb875fd5fbfc3dfeb1ed3696328 and if its ok for you, i can open a pull request.

Basically, i changed to use only one connection, and always close this connection before open again. And prevent the return of the resultsets and statements before return the profiles.

FabioZumbi12 commented 1 year ago

Nah, it wont solve the issue. It gets more time to lost connection but it still the same error. I am trying with BungeeCoord.jar..

SoyDary commented 1 year ago

FastLogin-leak-test-2.zip

I'll need the server log then again.

With that version everything went back to working normally and without errors. Although looking at the database I noticed that the players add them every time they connect, all with id 0.

https://hastebin.com/share/itazoqowub.csharp https://i.imgur.com/6gYmizl.png

games647 commented 1 year ago

@SoyDary That makes no sense. The database scheme FastLogin uses says it should auto increment them when not specified. Could you check the scheme by running describe premium

SoyDary commented 1 year ago

The database is constantly being modified and the users from the last screenshot disappeared and now there are 69 rows with the same user https://i.imgur.com/FBBphpk.png

games647 commented 1 year ago

Please post the database scheme by running describe table_name

SoyDary commented 1 year ago

I just noticed that it's different from a table I have on another server, I have no idea how that happened. https://i.imgur.com/GwsEXrn.png

games647 commented 1 year ago

Your database structure is incorrect. Do you imported or manually created the table? Please let FastLogin create the table again or manually adjust it using:. FastLogin depends on the behavior of the database system.

ALTER TABLE premium CHANGE UserID int(11) AUTO_INCREMENT PRIMARY KEY; ADD CONSTRAINT UNIQUE(Name)`

+-----------+--------------+------+-----+---------------------+----------------+
| Field     | Type         | Null | Key | Default             | Extra          |
+-----------+--------------+------+-----+---------------------+----------------+
| UserID    | int(11)      | NO   | PRI | NULL                | auto_increment |
| UUID      | char(36)     | YES  |     | NULL                |                |
| Name      | varchar(16)  | NO   | UNI | NULL                |                |
| Premium   | tinyint(1)   | NO   |     | NULL                |                |
| LastIp    | varchar(255) | NO   |     | NULL                |                |
| LastLogin | timestamp    | NO   |     | current_timestamp() |                |
+-----------+--------------+------+-----+---------------------+----------------+
SoyDary commented 1 year ago

Thanks!, it works fine now