Skip to content

Commit

Permalink
fix lock path error
Browse files Browse the repository at this point in the history
  • Loading branch information
CalvinKirs committed Sep 19, 2023
1 parent 760c14f commit c80bf87
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions fe/fe-core/src/main/java/org/apache/doris/DorisFE.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public class DorisFE {
public static final String PID_DIR = System.getenv("PID_DIR");


private static final String LOCK_FILE_PATH = Config.meta_dir + "/process.lock";
private static String LOCK_FILE_PATH;
private static FileChannel processLockFileChannel;
private static FileLock processFileLock;

Expand All @@ -95,12 +95,6 @@ public static void start(String dorisHomeDir, String pidDir, String[] args, Star
System.err.println("env PID_DIR is not set.");
return;
}
try {
tryLockProcess();
} catch (Exception e) {
LOG.error("start doris failed.", e);
System.exit(-1);
}

CommandLineOptions cmdLineOpts = parseArgs(args);

Expand All @@ -116,7 +110,13 @@ public static void start(String dorisHomeDir, String pidDir, String[] args, Star
// Must init custom config after init config, separately.
// Because the path of custom config file is defined in fe.conf
config.initCustom(Config.custom_config_dir + "/fe_custom.conf");

LOCK_FILE_PATH = Config.meta_dir + "/process.lock";
try {
tryLockProcess();
} catch (Exception e) {
LOG.error("start doris failed.", e);
System.exit(-1);
}
LdapConfig ldapConfig = new LdapConfig();
if (new File(dorisHomeDir + "/conf/ldap.conf").exists()) {
ldapConfig.init(dorisHomeDir + "/conf/ldap.conf");
Expand Down Expand Up @@ -430,9 +430,6 @@ private static boolean createAndLockPidFile(String pidFilePath) throws IOExcepti
* that only one FE process can occupy a metadata directory, and other processes will fail to start.
*/
private static void tryLockProcess() {
if (null == System.getenv("DORIS_HOME")) {
return;
}
try {
processLockFileChannel = FileChannel.open(new File(LOCK_FILE_PATH).toPath(), StandardOpenOption.WRITE,
StandardOpenOption.CREATE);
Expand Down

0 comments on commit c80bf87

Please sign in to comment.