• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

eXist-db / exist / 40385135706

26 Oct 2026 07:15PM UTC coverage: 58.168% (+0.03%) from 58.138%
40385135706

push

github

web-flow
Merge pull request #6927 from wylovan/bugfix/2097-path-step-mutates-variable

[bugfix] Leave a variable unchanged when a path step is applied to it

32488 of 61728 branches covered (52.63%)

Branch coverage included in aggregate %.

85545 of 141188 relevant lines covered (60.59%)

2.73 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

71.43
/exist-core/src/main/java/org/exist/storage/sync/SyncTask.java
1
/*
2
 * eXist-db Open Source Native XML Database
3
 * Copyright (C) 2001 The eXist-db Authors
4
 *
5
 * info@exist-db.org
6
 * http://www.exist-db.org
7
 *
8
 * This library is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU Lesser General Public
10
 * License as published by the Free Software Foundation; either
11
 * version 2.1 of the License, or (at your option) any later version.
12
 *
13
 * This library is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16
 * Lesser General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU Lesser General Public
19
 * License along with this library; if not, write to the Free Software
20
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
21
 */
22
package org.exist.storage.sync;
23

24
import java.nio.file.FileStore;
25
import java.nio.file.Path;
26
import java.util.Properties;
27

28
import com.evolvedbinary.j8fu.tuple.Tuple2;
29
import org.apache.logging.log4j.LogManager;
30
import org.apache.logging.log4j.Logger;
31
import org.exist.EXistException;
32
import org.exist.scheduler.JobDescription;
33
import org.exist.storage.BrokerPool;
34
import org.exist.storage.DBBroker;
35
import org.exist.storage.SystemTask;
36
import org.exist.storage.txn.Txn;
37
import org.exist.util.Configuration;
38
import org.exist.util.FileUtils;
39

40
import static com.evolvedbinary.j8fu.tuple.Tuple.Tuple;
41

42
public class SyncTask implements SystemTask {
3 ✔
43

44
    private final static Logger LOG = LogManager.getLogger(SyncTask.class);
3 ✔
45

46
    private final static String JOB_NAME = "Sync";
1 ✔
47

48
    public static String getJobName() {
49
        return JOB_NAME;
2 ✔
50
    }
51

52
    public static String getJobGroup() {
53
        return JobDescription.EXIST_INTERNAL_GROUP;
×
54
    }
55

56
    private Path dataDir;
57
    private long diskSpaceMin;
58

59
    @Override
60
    public boolean afterCheckpoint() {
61
        // a checkpoint is created by the MAJOR_SYNC event
62
        return false;
2 ✔
63
    }
64

65
    @Override
66
    public String getName() {
67
        return getJobName();
2 ✔
68
    }
69

70
    @Override
71
    public void configure(final Configuration config, final Properties properties) throws EXistException {
72
        this.diskSpaceMin = 1024L * 1024L * config.getProperty(BrokerPool.DISK_SPACE_MIN_PROPERTY, BrokerPool.DEFAULT_DISK_SPACE_MIN);
12 ✔
73

74
        // fixme! - Shouldn't it be data dir AND journal dir we check
75
        // rather than EXIST_HOME? /ljo
76
        dataDir = (Path) config.getProperty(BrokerPool.PROPERTY_DATA_DIR);
6 ✔
77
        LOG.info("Using DATA_DIR: {}. Minimal disk space required for database to continue operations: {}mb", dataDir.toAbsolutePath().toString(), diskSpaceMin / 1024 / 1024);
14 ✔
78
        final long space = FileUtils.measureFileStore(dataDir, FileStore::getUsableSpace);
5 ✔
79
        LOG.info("Usable space on partition containing DATA_DIR: {}: {}mb", dataDir.toAbsolutePath().toString(), space / 1024 / 1024);
13 ✔
80
    }
1 ✔
81

82
    @Override
83
    public void execute(final DBBroker broker, final Txn transaction) throws EXistException {
84
        final BrokerPool pool = broker.getBrokerPool();
3 ✔
85
        final Tuple2<Boolean, Long> availableSpace = checkDiskSpace();
3 ✔
86
        if (!availableSpace._1) {
5 !
87
            LOG.fatal("Partition containing DATA_DIR: {} is running out of disk space [minimum: {} free: {}]. Switching eXist-db into read-only mode to prevent data loss!", dataDir.toAbsolutePath().toString(), diskSpaceMin, availableSpace._2);
×
88
            pool.setReadOnly();
×
89
        }
90

91
        if(System.currentTimeMillis() - pool.getLastMajorSync() >
4 ✔
92
                pool.getMajorSyncPeriod()) {
4 !
93
            pool.sync(broker, Sync.MAJOR);
×
94
        } else {
×
95
            pool.sync(broker, Sync.MINOR);
4 ✔
96
        }
97
    }
1 ✔
98

99
    /**
100
     * @return A tuple, where the first value indicates if there is enough disk space, the
101
     * second value is the amount of usable space in bytes
102
     */
103
    private Tuple2<Boolean,Long> checkDiskSpace() {
104
        final long usableSpace = FileUtils.measureFileStore(dataDir, FileStore::getUsableSpace);
5 ✔
105
        //LOG.info("Usable space on partition containing DATA_DIR: " + dataDir.getAbsolutePath() + ": " + (space / 1024 / 1024) + "mb");
106
        final boolean enoughSpace = usableSpace > diskSpaceMin || usableSpace == -1;
7 !
107
        return Tuple(enoughSpace, usableSpace);
6 ✔
108
    }
109
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc