Skip to content

Commit f13a84c

Browse files
committed
Merge branch '1.21.3' into 1.21.4
2 parents 6eb2cf2 + 3268f7f commit f13a84c

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

common/src/main/java/xaeroplus/feature/drawing/db/DrawingDatabase.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public DrawingDatabase(String worldId, String databaseName) {
6363
connection = DriverManager.getConnection("jdbc:rfresh_sqlite:" + dbPath);
6464
((SQLiteConnection) connection).setBusyTimeout(5000);
6565
MIGRATOR.migrate(dbPath, databaseName, connection, init);
66+
setPragmas();
6667
} catch (Exception e) {
6768
if (!nativeLibraryErrorSent && e.getCause() instanceof NativeLibraryNotFoundException nativeException) {
6869
nativeLibraryErrorSent = true;
@@ -76,6 +77,15 @@ public DrawingDatabase(String worldId, String databaseName) {
7677
}
7778
}
7879

80+
private void setPragmas() {
81+
try (var statement = connection.createStatement()) {
82+
statement.executeUpdate("pragma journal_mode = WAL;");
83+
statement.executeUpdate("pragma synchronous = NORMAL;");
84+
} catch (SQLException e) {
85+
throw new RuntimeException("Failed to set sqlite pragmas", e);
86+
}
87+
}
88+
7989
private void createHighlightsTable(final String databaseName, final Connection connection, final ResourceKey<Level> dimension) {
8090
int tryCount = 0;
8191
while (tryCount++ < MAX_RETRIES) {

common/src/main/java/xaeroplus/feature/highlights/ChunkHighlightDatabase.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public ChunkHighlightDatabase(String worldId, String databaseName) {
5050
((SQLiteConnection) connection).setBusyTimeout(5000);
5151
MIGRATOR.migrate(dbPath, databaseName, connection, init);
5252
createMetadataTable();
53+
setPragmas();
5354
} catch (Exception e) {
5455
XaeroPlus.LOGGER.error("Error while creating chunk highlight database: {} for worldId: {}", databaseName, worldId, e);
5556
throw new RuntimeException(e);
@@ -64,6 +65,15 @@ private String getTableName(ResourceKey<Level> dimension) {
6465
return dimension.location().toString();
6566
}
6667

68+
private void setPragmas() {
69+
try (var statement = connection.createStatement()) {
70+
statement.executeUpdate("pragma journal_mode = WAL;");
71+
statement.executeUpdate("pragma synchronous = NORMAL;");
72+
} catch (SQLException e) {
73+
throw new RuntimeException("Failed to set sqlite pragmas", e);
74+
}
75+
}
76+
6777
private void createMetadataTable() {
6878
int tryCount = 0;
6979
while (tryCount++ < MAX_RETRIES) {

0 commit comments

Comments
 (0)