[
https://issues.apache.org/jira/browse/JCR-3563?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Shashank Gupta updated JCR-3563:
--------------------------------
Description:
To preserve disk space in your environment is to share the CRX datastore
directory over a network share between multiple (non -clustered) installations
of CRX.[1]. [1] also mentions the procedure to run GC for these farm
installations.
FileDataStore#deleteOlderRecursive(File file, long min) [2] has potential data
loss risk if 2nd installation(other than on which [2] is running) add touch
file between (A) and (B) mentioned below. For e.g.
File X is eligible for gc'ed and node 1 is running deleteOlderRecursive to
process File X. If between point A & point B,
user upload same File X from node 2. Despite being added by node2, the file
will be deleted by node1.
[1]http://helpx.adobe.com/crx/kb/HowToCombineTheDatastoreToPreserveDiskSpace.html
[2]
{code}
private int deleteOlderRecursive(File file, long min) {
int count = 0;
if (file.isFile() && file.exists() && file.canWrite()) {
synchronized (this) {
long lastModified;
try {
(A) lastModified = getLastModified(file);
} catch (DataStoreException e) {
log.warn("Failed to read modification date; file not
deleted", e);
// don't delete the file, since the lastModified date is
uncertain
lastModified = min;
}
(B) if (lastModified < min) {
DataIdentifier id = new DataIdentifier(file.getName());
if (!inUse.containsKey(id)) {
if (log.isInfoEnabled()) {
log.info("Deleting old file " +
file.getAbsolutePath() +
" modified: " + new
Timestamp(lastModified).toString() +
" length: " + file.length());
}
if (!file.delete()) {
log.warn("Failed to delete old file " +
file.getAbsolutePath());
}
count++;
}
}
}
} else if (file.isDirectory()) {
File[] list = file.listFiles();
if (list != null) {
for (File f: list) {
count += deleteOlderRecursive(f, min);
}
}
// JCR-1396: FileDataStore Garbage Collector and empty directories
// Automatic removal of empty directories (but not the root!)
synchronized (this) {
if (file != directory) {
list = file.listFiles();
if (list != null && list.length == 0) {
file.delete();
}
}
}
}
return count;
}
{code}
was:
To preserve disk space in your environment is to share the CRX datastore
directory over a network share between multiple (non -clustered) installations
of CRX.[1]. [1] also mentions the procedure to run GC for these farm
installations.
FileDataStore#deleteOlderRecursive(File file, long min) [2] has potential data
loss risk if 2nd installation(other than on which [2] is running) add files
between (A) and (B) mentioned below
[1]http://helpx.adobe.com/crx/kb/HowToCombineTheDatastoreToPreserveDiskSpace.html
[2]
{code}
private int deleteOlderRecursive(File file, long min) {
int count = 0;
if (file.isFile() && file.exists() && file.canWrite()) {
synchronized (this) {
long lastModified;
try {
(A) lastModified = getLastModified(file);
} catch (DataStoreException e) {
log.warn("Failed to read modification date; file not
deleted", e);
// don't delete the file, since the lastModified date is
uncertain
lastModified = min;
}
(B) if (lastModified < min) {
DataIdentifier id = new DataIdentifier(file.getName());
if (!inUse.containsKey(id)) {
if (log.isInfoEnabled()) {
log.info("Deleting old file " +
file.getAbsolutePath() +
" modified: " + new
Timestamp(lastModified).toString() +
" length: " + file.length());
}
if (!file.delete()) {
log.warn("Failed to delete old file " +
file.getAbsolutePath());
}
count++;
}
}
}
} else if (file.isDirectory()) {
File[] list = file.listFiles();
if (list != null) {
for (File f: list) {
count += deleteOlderRecursive(f, min);
}
}
// JCR-1396: FileDataStore Garbage Collector and empty directories
// Automatic removal of empty directories (but not the root!)
synchronized (this) {
if (file != directory) {
list = file.listFiles();
if (list != null && list.length == 0) {
file.delete();
}
}
}
}
return count;
}
{code}
> Shared File DataStore: Potential data loss risk in FileDataStore's GC
> ------------------------------------------------------------------------
>
> Key: JCR-3563
> URL: https://issues.apache.org/jira/browse/JCR-3563
> Project: Jackrabbit Content Repository
> Issue Type: Bug
> Components: jackrabbit-core
> Affects Versions: 2.6
> Reporter: Shashank Gupta
>
> To preserve disk space in your environment is to share the CRX datastore
> directory over a network share between multiple (non -clustered)
> installations of CRX.[1]. [1] also mentions the procedure to run GC for these
> farm installations.
> FileDataStore#deleteOlderRecursive(File file, long min) [2] has potential
> data loss risk if 2nd installation(other than on which [2] is running) add
> touch file between (A) and (B) mentioned below. For e.g.
> File X is eligible for gc'ed and node 1 is running deleteOlderRecursive to
> process File X. If between point A & point B,
> user upload same File X from node 2. Despite being added by node2, the file
> will be deleted by node1.
> [1]http://helpx.adobe.com/crx/kb/HowToCombineTheDatastoreToPreserveDiskSpace.html
> [2]
> {code}
> private int deleteOlderRecursive(File file, long min) {
> int count = 0;
> if (file.isFile() && file.exists() && file.canWrite()) {
> synchronized (this) {
> long lastModified;
> try {
> (A) lastModified = getLastModified(file);
> } catch (DataStoreException e) {
> log.warn("Failed to read modification date; file not
> deleted", e);
> // don't delete the file, since the lastModified date is
> uncertain
> lastModified = min;
> }
> (B) if (lastModified < min) {
> DataIdentifier id = new DataIdentifier(file.getName());
> if (!inUse.containsKey(id)) {
> if (log.isInfoEnabled()) {
> log.info("Deleting old file " +
> file.getAbsolutePath() +
> " modified: " + new
> Timestamp(lastModified).toString() +
> " length: " + file.length());
> }
> if (!file.delete()) {
> log.warn("Failed to delete old file " +
> file.getAbsolutePath());
> }
> count++;
> }
> }
> }
> } else if (file.isDirectory()) {
> File[] list = file.listFiles();
> if (list != null) {
> for (File f: list) {
> count += deleteOlderRecursive(f, min);
> }
> }
> // JCR-1396: FileDataStore Garbage Collector and empty directories
> // Automatic removal of empty directories (but not the root!)
> synchronized (this) {
> if (file != directory) {
> list = file.listFiles();
> if (list != null && list.length == 0) {
> file.delete();
> }
> }
> }
> }
> return count;
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.2#6252)