You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ag...@apache.org on 2018/11/09 08:59:18 UTC
ignite git commit: IGNITE-10128 Race in read\write cache
configurations. - Fixes #5241.
Repository: ignite
Updated Branches:
refs/heads/master 6a43fe137 -> 567d7994d
IGNITE-10128 Race in read\write cache configurations. - Fixes #5241.
Signed-off-by: Alexey Goncharuk <al...@gmail.com>
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/567d7994
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/567d7994
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/567d7994
Branch: refs/heads/master
Commit: 567d7994dcd660ecb6831e5c73d02797e80e25f6
Parents: 6a43fe1
Author: zstan <st...@gmail.com>
Authored: Fri Nov 9 11:26:14 2018 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Fri Nov 9 11:26:14 2018 +0300
----------------------------------------------------------------------
.../persistence/file/FilePageStoreManager.java | 41 ++++++++++----------
1 file changed, 21 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/567d7994/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/FilePageStoreManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/FilePageStoreManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/FilePageStoreManager.java
index 0f01fd4..4a14c6b 100755
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/FilePageStoreManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/FilePageStoreManager.java
@@ -22,7 +22,6 @@ import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
-import java.io.FilenameFilter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -186,6 +185,22 @@ public class FilePageStoreManager extends GridCacheSharedManagerAdapter implemen
"DataStorageConfiguration#storagePath properties). " +
"Current persistence store directory is: [" + tmpDir + "]");
}
+
+ File[] files = storeWorkDir.listFiles();
+
+ for (File file : files) {
+ if (file.isDirectory()) {
+ File[] tmpFiles = file.listFiles((k, v) -> v.endsWith(CACHE_DATA_TMP_FILENAME));
+
+ if (tmpFiles != null) {
+ for (File tmpFile : tmpFiles) {
+ if (!tmpFile.delete())
+ log.warning("Failed to delete temporary cache config file" +
+ "(make sure Ignite process has enough rights):" + file.getName());
+ }
+ }
+ }
+ }
}
/** {@inheritDoc} */
@@ -376,17 +391,17 @@ public class FilePageStoreManager extends GridCacheSharedManagerAdapter implemen
if (overwrite || !Files.exists(filePath) || Files.size(filePath) == 0) {
File tmp = new File(file.getParent(), file.getName() + TMP_SUFFIX);
- tmp.createNewFile();
+ if (tmp.exists() && !tmp.delete()) {
+ log.warning("Failed to delete temporary cache config file" +
+ "(make sure Ignite process has enough rights):" + file.getName());
+ }
// Pre-existing file will be truncated upon stream open.
try (OutputStream stream = new BufferedOutputStream(new FileOutputStream(tmp))) {
marshaller.marshal(cacheData, stream);
}
- if (file.exists())
- file.delete();
-
- Files.move(tmp.toPath(), file.toPath());
+ Files.move(tmp.toPath(), file.toPath(), StandardCopyOption.REPLACE_EXISTING);
}
}
catch (IOException ex) {
@@ -787,20 +802,6 @@ public class FilePageStoreManager extends GridCacheSharedManagerAdapter implemen
for (File file : files) {
if (file.isDirectory()) {
- File[] tmpFiles = file.listFiles(new FilenameFilter() {
- @Override public boolean accept(File dir, String name) {
- return name.endsWith(CACHE_DATA_TMP_FILENAME);
- }
- });
-
- if (tmpFiles != null) {
- for (File tmpFile: tmpFiles) {
- if (!tmpFile.delete())
- log.warning("Failed to delete temporary cache config file" +
- "(make sure Ignite process has enough rights):" + file.getName());
- }
- }
-
if (file.getName().startsWith(CACHE_DIR_PREFIX)) {
File conf = new File(file, CACHE_DATA_FILENAME);