Skip to content

Commit bf01cde

Browse files
Implementation of durable incremental backups (#525)
That is a partial fix of issue YTDB-333, the implementation of a new algorithm for incremental backups. The detailed design document can be read there https://youtrack.jetbrains.com/articles/YTDB-A-10/Incremental-backup . Key points of this change: 1. Incremental backup is made durable by keeping a single backup file's hash code inside the metadata. 2. The last backup file is checked during the next iteration of the incremental backup. If the backup is broken, the file is removed, and a backup is performed since the changes of the previous backup. 3. It is possible to provide a virtual presentation of the file system by providing lambda functions that implement the required file system functionality. 4. New methods for public API were introduced: `YTDBGraphGraphTraversalSource#backup`, `YTDBGraphGraphTraversalSource#fullBackup` and `YouTrackDB#restore`.
2 parents 6b607e1 + a44459c commit bf01cde

File tree

273 files changed

+4289
-5345
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

273 files changed

+4289
-5345
lines changed

.github/pull_request_template.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ A clear and concise explanation of why this change is necessary and what problem
44
This section should provide context and justify the need for the change.
55
This section is **MANDATORY**.
66

7-
87
#### Changes:
98

109
A detailed description of the changes made in this pull request.
11-
This section should include any relevant code snippets, screenshots, or other supporting materials such as design documents and APRs.
10+
This section should include any relevant code snippets, screenshots, or other supporting materials
11+
such as design documents and APRs.
1212
This section is **MANDATORY**.

.github/workflows/maven-pipeline.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ jobs:
141141
MAVEN_MIROR_PASSWORD: ${{ secrets.MAVEN_MIROR_PASSWORD }}
142142
notify-failure:
143143
name: Notify build failure on Zulip
144-
needs: [ test, deploy, deploy-docker]
144+
needs: [ test, deploy, deploy-docker ]
145145
if: failure()
146146
runs-on: ubuntu-latest
147147
steps:

.idea/inspectionProfiles/youtrackdb.xml

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/data/tinkerpop-modern.json

Lines changed: 0 additions & 6 deletions
This file was deleted.

core/data/tinkerpop-modern.kryo

-781 Bytes
Binary file not shown.

core/data/tinkerpop-modern.xml

Lines changed: 0 additions & 1 deletion
This file was deleted.

core/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,10 @@
216216
<artifactId>youtrackdb-gremlin-annotations</artifactId>
217217
<version>${project.version}</version>
218218
</dependency>
219+
<dependency>
220+
<groupId>commons-io</groupId>
221+
<artifactId>commons-io</artifactId>
222+
</dependency>
219223
<dependency>
220224
<groupId>it.unimi.dsi</groupId>
221225
<artifactId>fastutil</artifactId>

core/src/main/java/com/jetbrains/youtrackdb/api/YouTrackDB.java

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,17 @@ YTDBGraphTraversalSource openTraversal(@Nonnull String databaseName, @Nonnull St
303303
@Nonnull
304304
YTDBGraphTraversalSource openTraversal(@Nonnull String databaseName);
305305

306-
/// Creates a database by restoring it from incremental backup. The backup should be created with
307-
/// [#incrementalBackup(Path)].
306+
/// Creates a database by restoring it from backup. The backup should be created with
307+
/// [YTDBGraphTraversalSource#backup(Path)].
308+
///
309+
/// At the moment only disk-based databases are supported, you cannot restore memory databases.
310+
///
311+
/// @param databaseName Name of a database to be created.
312+
/// @param path Path to the backup directory.
313+
void restore(@Nonnull String databaseName, @Nonnull String path);
314+
315+
/// Creates a database by restoring it from backup. The backup should be created with
316+
/// [YTDBGraphTraversalSource#backup(Path)].
308317
///
309318
/// At the moment only disk-based databases are supported, you cannot restore memory databases.
310319
///
@@ -372,4 +381,17 @@ default void createSystemUser(@Nonnull String username, @Nonnull String password
372381

373382
return userCredentialsArray;
374383
}
384+
385+
/// Creates a database by restoring it from backup. The backup should be created with
386+
/// [YTDBGraphTraversalSource#backup(Path)].
387+
///
388+
/// At the moment only disk-based databases are supported, you can not restore memory databases.
389+
///
390+
/// @param databaseName Name of a database to be created.
391+
/// @param path Path to the backup directory.
392+
/// @param expectedUUID UUID of the database to be restored. If null, the database will be
393+
/// restored only if the directory contains backup only from one database.
394+
/// @param config database configuration
395+
void restore(@Nonnull String databaseName, @Nonnull String path, @Nullable String expectedUUID,
396+
@Nonnull Configuration config);
375397
}

core/src/main/java/com/jetbrains/youtrackdb/api/YourTracks.java

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ public static YouTrackDB instance(@Nonnull String directoryPath,
5454
/// Create a new YouTrackDB manager instance for an embedded deployment with custom
5555
/// configuration.
5656
///
57-
/// A created instance is cached and reused if the method is called for the second time unless
58-
/// it is closed by the user.
57+
/// A created instance is cached and reused if the method is called for the second time unless it
58+
/// is closed by the user.
5959
///
60-
/// @param directoryPath the directory where the databases are stored. For in memory database
61-
/// use "."
60+
/// @param directoryPath the directory where the databases are stored. For in memory database use
61+
/// "."
6262
/// @param configuration custom configuration for current environment
6363
public static YouTrackDB instance(@Nonnull Path directoryPath,
6464
@Nonnull Configuration configuration) {
@@ -71,7 +71,6 @@ public static YouTrackDB instance(@Nonnull Path directoryPath,
7171
///
7272
/// @param serverAddress server address
7373
/// @param serverPort server port
74-
///
7574
/// @see YouTrackDB#createSystemUser(String, String, String...)
7675
/// @see YouTrackDB#createSystemUser(String, String, PredefinedSystemRole...)
7776
public static YouTrackDB instance(@Nonnull String serverAddress, int serverPort) {
@@ -89,7 +88,7 @@ public static YouTrackDB instance(@Nonnull String serverAddress, int serverPort)
8988
} catch (IllegalAccessException e) {
9089
throw new RuntimeException(e);
9190
}
92-
}
91+
}
9392

9493

9594
/// Creates a new YouTrackDB manager instance for a case when YTDB database is managed by Gremlin
@@ -104,7 +103,6 @@ public static YouTrackDB instance(@Nonnull String serverAddress, int serverPort)
104103
/// @param serverPort server port
105104
/// @param username user name
106105
/// @param password user password
107-
///
108106
/// @see YouTrackDB#createSystemUser(String, String, String...)
109107
/// @see YouTrackDB#createSystemUser(String, String, PredefinedSystemRole...)
110108
public static YouTrackDB instance(@Nonnull String serverAddress, int serverPort,
@@ -127,21 +125,20 @@ public static YouTrackDB instance(@Nonnull String serverAddress, int serverPort,
127125
}
128126

129127
/// Creates a new YouTrackDB manager instance for a case when YTDB database is managed by Gremlin
130-
/// Server. The name of passed in user should belong to the user either registered in the
131-
/// server configuration or system database.
128+
/// Server. The name of passed in user should belong to the user either registered in the server
129+
/// configuration or system database.
132130
///
133131
/// Server connection will use port `8182` by default.
134132
///
135133
/// Integration with SSO and user directories is going to be added soon.
136134
///
137-
/// As username and password are already passed during establishing the connection,
138-
/// the method [YouTrackDB#openTraversal(String)]
139-
/// is recommended to be used to send Gremlin queries to the server.
135+
/// As username and password are already passed during establishing the connection, the method
136+
/// [YouTrackDB#openTraversal(String)] is recommended to be used to send Gremlin queries to the
137+
/// server.
140138
///
141139
/// @param serverAddress server address
142140
/// @param username user name
143141
/// @param password user password
144-
///
145142
/// @see YouTrackDB#createSystemUser(String, String, String...)
146143
/// @see YouTrackDB#createSystemUser(String, String, PredefinedSystemRole...)
147144
public static YouTrackDB instance(@Nonnull String serverAddress, @Nonnull String username,

core/src/main/java/com/jetbrains/youtrackdb/api/config/GlobalConfiguration.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,13 @@ public enum GlobalConfiguration {
377377
Integer.class,
378378
0),
379379

380+
STORAGE_BACKUP_MINIMUM_TIMEOUT_INTERVAL("youtrackdb.storage.minimumTimeOutInterval",
381+
"Minimum interval between backups (in seconds). If users performs backup too often, "
382+
+ "storage will wait for this interval,"
383+
+ " as file system metadata update can be performed with delay in some filesystems. "
384+
+ "Default is 5 seconds.",
385+
Integer.class, 5),
386+
380387
// DATABASE
381388
DB_POOL_MIN("youtrackdb.db.pool.min", "Default database pool minimum size", Integer.class, 1),
382389

0 commit comments

Comments
 (0)