Commit Graph

2951 Commits

Author SHA1 Message Date
Rsl1122
fd2e45b204 Test against #934 on MySQL 2019-03-01 11:14:21 +02:00
Rsl1122
c9c696e71d [#935] Made GenerateAnalysisPageRequest run analysis async 2019-03-01 10:26:56 +02:00
Rsl1122
ad2208d7ff [Vuln] Login now blocked for 90s after 5 failed attempts. 2019-03-01 10:16:13 +02:00
Rsl1122
75782562f9 Fixed authentication message showing '/' 2019-03-01 09:41:41 +02:00
Rsl1122
6806e6c98e [#937] Fixed nested transactions that query database.
Nested transactions, Transaction#executeOther(Transaction), where the
inner transaction performed a query ran into NPE since the Database
used for the query had not been defined.
2019-02-28 19:18:17 +02:00
Rsl1122
5eef819308 Fixed bad default value in bungee config 2019-02-28 19:14:52 +02:00
Rsl1122
93e7410ad2 Fix PlanConfig constructor usage in tests 2019-02-28 17:52:05 +02:00
Rsl1122
be8a3b484f PlanConfig#getOrDefault 2019-02-28 17:46:23 +02:00
Rsl1122
233a930c9c Made transaction wait delay configurable 2019-02-28 12:54:31 +02:00
Rsl1122
b9ec70619a Increased database stop wait time: 5s -> 20s
This is to give more time for unfinished data transactions to execute.
2019-02-28 12:47:37 +02:00
dependabot[bot]
abc5296ee2
Bump caffeine from 2.6.2 to 2.7.0 in /Plan (#931) 2019-02-25 12:23:37 +00:00
Rsl1122
af8ff43c39 [#929] Removed custom Sponge DataSource MySQL implementation 2019-02-25 10:48:12 +02:00
Rsl1122
2fc8c7c29b [#930] Null check to WorldTimes#updateState 2019-02-25 10:36:53 +02:00
Rsl1122
42464d503e Moved shutdown session save message to ServerShutdownSave 2019-02-24 12:41:07 +02:00
Risto Lahtela
16e6ef1dc7
[#769, #928] Session save on server shutdown (#927)
* ShutdownHook: No sessions to save check

ShutdownHook now checks if it needs to save any sessions and does not
start the database if no sessions are unsaved.

* SessionCache.getActiveSessions() now immutable

* [#769] Bukkit and Sponge server shutdown save

Implemented following save procedure for Bukkit:
- On plugin disable check if server is shutting down and save sessions
- Shutdown hook triggered on JVM shutdown calls the same session save
- Save clears sessions from cache, so the sessions are not saved twice

Implemented following save procedure for Sponge:
- Listen for GameStoppingServerEvent
- On plugin disable ask listener if shutting down and save sessions
- Shutdown hook triggered on JVM shutdown calls the same session save
- Save clears sessions from cache, so the sessions are not saved twice

Test:
- Tests ShutdownSave on reload
- Tests ShutdownSave on shutdown
- Tests ShutdownSave on JVM shutdown
2019-02-24 12:28:58 +02:00
Risto Lahtela
96564c90be
[Merge] [#818] Organized Database Classes (#920)
These can be summarized in 3 categories of changes:

### Moved SQL queries from `Table` classes to `Queries` classes.

`Table` classes were turned into static information classes that only contain statements and table fields for the tables. Classes with static methods were created that return `Query<T>` objects that can be passed to the Database. This simplifies addition of multi-table queries.

### Changes are now executed via Transactions

A new `Transaction` class was made, and executing row updating statements was limited inside these classes. This allows committing changes once per multiple statements (speedup) and rolling back partial failed transactions (reliability).

### Database ExecutorService and access lock

A single thread executor was added to be in charge of executing Transactions. All submitted transactions will be executed by this one thread.
Queries will be held until database is operational (Patches have been applied). This should alleviate issues such as #893

## Other changes

- SaveOperations, CheckOperations, CountOperations, SearchOperations were all removed. FetchOperations was completely deprecated, but since it is still provided by `PlanAPI` it was kept in place.
`FetchOperations` is scheduled for removal upon implementation of the new PluginData API.

- Database interface was not very useful, so it was changed to make it usable instead of SQLDB.

- [Wrong branch] Moved to using JUnit 5.4 TempDir instead of junitpioneer 

- `DataCache` was split off to a separate class `NicknameCache` and `SessionCache` no longer saves the session when ended, responsibility is now with the caller
2019-02-22 10:49:58 +02:00
Rsl1122
871fa9b979 Added a fail message to web traffic if database is not open 2019-02-22 10:35:36 +02:00
Rsl1122
ac7093237e Added a fail message to commands if database is not open 2019-02-22 10:17:27 +02:00
Rsl1122
8caa8350ca Fix nickname cache call blocking server thread 2019-02-21 21:25:27 +02:00
Risto Lahtela
82fbbb5209
Merge branch 'development' into db-refactoring 2019-02-19 17:45:24 +02:00
dependabot[bot]
97ef1e39ce
Bump mockito-core from 2.24.0 to 2.24.5 in /Plan (#925) 2019-02-19 15:43:50 +00:00
dependabot[bot]
1589a89a6b
Bump slf4jVersion from 1.7.25 to 1.7.26 in /Plan (#924) 2019-02-19 15:24:26 +00:00
dependabot[bot]
28940f3ef7
Bump mockito-junit-jupiter from 2.24.0 to 2.24.5 in /Plan (#923) 2019-02-19 15:23:41 +00:00
Rsl1122
4e65f99228 Added missing license header 2019-02-19 13:01:17 +02:00
Rsl1122
1e87145767 Fixed sonar smells:
Level major:
- Specified exception in ServerServerInfo

Level minor:
- Unnecessary parentheses removed in BukkitUserImportRefiner

Level info:
- Removed DataCache
- Finished a todo in H2DB
2019-02-19 12:56:12 +02:00
Rsl1122
ee50ebde2c Removed ExecStatement#executeBatch, ExecBatchStatement should be used. 2019-02-19 12:52:27 +02:00
Rsl1122
4f63a3771b Refactored database clean task out of the database
Fixed SonarCloud smells:

Level blocker:
- Removed 'dbType' field from CreateIndexTransaction (is in Transaction)
- Removed unused 'dbSystem' from AnalysisContainer
2019-02-19 12:51:52 +02:00
Rsl1122
0d8c2f2824 Removed ProxySessionCache:
This class is no longer required since responsibility of storage of
sessions now lies with the caller and it's functionality can be
achieved by not saving the returned optional.
2019-02-19 12:36:13 +02:00
Rsl1122
a41a4683c6 Removed Column interface, not used:
- Removed TableSqlParser, not used
- Removed Select#from that used Column
- Removed Update#values that used Column
- Removed Insert#values that used Column
2019-02-19 12:32:11 +02:00
Rsl1122
000290bb24 Bump pluginbridge version to 4.7.0 2019-02-19 12:22:30 +02:00
Rsl1122
530c4a2ea6 Fixed pluginbridge
- AAC SQL stuff
- ViaVersion & ProtocolSupport SQL stuff
- Litebans SQL stuff
- PlaceholderAPIHook (unfinished) SQL stuff
- Towny & Vault DataCache stuff
- Removed since javadoc tags
- Bridge Version bump to 4.7.0
2019-02-19 12:21:07 +02:00
Rsl1122
acae1c4b3d Removed DBInitException throws clauses from methods 2019-02-18 18:21:14 +02:00
Rsl1122
0b7b0a5a16 Removed DBException:
- Made DBInitException subclass of DBOpException
2019-02-18 18:15:50 +02:00
Rsl1122
6fbd8ced60 Fixed concurrency issues with backup related commands 2019-02-18 18:03:09 +02:00
Rsl1122
e1bef920e7 Fixed connection system auth query 2019-02-18 17:59:02 +02:00
Rsl1122
8f3f2e9127 Fixed a network page query 2019-02-18 17:57:38 +02:00
Rsl1122
bbb158ddc5 Fixed peak TPS query 2019-02-18 17:20:04 +02:00
Rsl1122
c60003cda0 Made db field in Transaction private 2019-02-17 23:06:43 +02:00
Rsl1122
e2310e4376 Fixed Patch code failing if a table doesn't exist 2019-02-17 22:57:37 +02:00
Rsl1122
1378d3100e Transaction rollback fail no longer hides original exception 2019-02-17 22:52:30 +02:00
Rsl1122
8870e034e1 All database transactions are now performed by a single thread.
- Added a Database Access Lock object
  - Access log lets OperationCriticalTransactions through
  - Transactions skip query access log check
  - executeTransaction returns a Future to allow easier synchronization
  - ServerInfo waits for the server to be registered. This could lead
    to issues if a new server is registering to old database. It should
    not be too big of an issue since no patches need to be applied
    on first enable of the database.
- Added database states: CLOSED <-> INITIALIZING -> OPEN -> CLOSED

These two changes allow restricting queries to the database until the
database has properly initialized (Schema is in correct format)

- Removed SQLDB as a Patch class variable

Tests use Guava direct thread executor on the database to reduce
concurrency issues during tests. Another option would be to wait for
each transaction.
2019-02-16 20:26:08 +02:00
Rsl1122
2b9e407816 Removed sql Table class 2019-02-16 15:14:20 +02:00
Rsl1122
360e631fc9 Removed PatchTask 2019-02-16 14:58:54 +02:00
Rsl1122
33eec6d990 Moved to using JUnit 5.4 TempDir instead of junitpioneer 2019-02-16 14:55:00 +02:00
Rsl1122
039696910c Removed ProxyAPI and ServerAPI since implementations are the same 2019-02-16 14:48:36 +02:00
Rsl1122
23969192c1 Moved two peak player count queries to TPSQueries class 2019-02-16 14:29:28 +02:00
Rsl1122
f83be34f09 Deprecation javadoc messages to FetchOperations 2019-02-16 14:29:27 +02:00
Rsl1122
738a58edc2 Removed SQLErrorUtil 2019-02-16 14:29:26 +02:00
Rsl1122
328e42a19b Removed Database#fetch usage 2019-02-16 14:29:26 +02:00
Rsl1122
f77750c138 Removed SQLOps class 2019-02-16 14:29:25 +02:00