Skip to content

Commit

Permalink
KYLIN-3092 fix cyclic lock
Browse files Browse the repository at this point in the history
  • Loading branch information
liyang-kylin authored and Hongbin Ma committed Dec 21, 2017
1 parent 9f603d3 commit f37fbce
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ private void loadHiveConfiguration() {
hiveConfFile = new File(path + File.separator + "conf", hiveConfFileName);
}

if (hiveConfFile == null || !hiveConfFile.exists()) {
throw new RuntimeException("Failed to read " + HIVE_CONF_FILENAME + ".xml");
if (!hiveConfFile.exists()) {
throw new RuntimeException("Missing config file: " + hiveConfFile.getAbsolutePath());
}

String fileUrl = OptionsHelper.convertToFileURL(hiveConfFile.getAbsolutePath());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
import org.apache.kylin.metadata.project.ProjectInstance;
import org.apache.kylin.metadata.project.ProjectManager;
import org.apache.kylin.metadata.realization.IRealization;
import org.apache.kylin.metadata.realization.RealizationStatusEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -166,14 +165,6 @@ public CubeDesc reloadCubeDescLocal(String name) throws IOException {
if (ndesc.isBroken())
throw new IllegalStateException("CubeDesc " + name + " is broken");

// if related cube is in DESCBROKEN state before, change it back to DISABLED
CubeManager cubeManager = CubeManager.getInstance(config);
for (CubeInstance cube : cubeManager.getCubesByDesc(name)) {
if (cube.getStatus() == RealizationStatusEnum.DESCBROKEN) {
cube.init(config);
}
}

return ndesc;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,16 @@ public void run() {
try (SetThreadName ignored = new SetThreadName("Scheduler %s Job %s",
System.identityHashCode(DefaultScheduler.this), executable.getId())) {
executable.execute(context);
// trigger the next step asap
fetcherPool.schedule(fetcher, 0, TimeUnit.SECONDS);
} catch (ExecuteException e) {
logger.error("ExecuteException job:" + executable.getId(), e);
} catch (Exception e) {
logger.error("unknown error execute job:" + executable.getId(), e);
} finally {
context.removeRunningJob(executable);
}

// trigger the next step asap
fetcherPool.schedule(fetcher, 0, TimeUnit.SECONDS);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ public List<TableDesc> listAllTables(String prj) {
}

public Map<String, TableDesc> getAllTablesMap(String prj) {
// avoid cyclic locks
ProjectInstance project = (prj == null) ? null : ProjectManager.getInstance(config).getProject(prj);

try (AutoLock lock = srcTableMapLock.lockForWrite()) {
//TODO prj == null case is now only used by test case and CubeMetaIngester
//should refactor these test case and tool ASAP and stop supporting null case
Expand All @@ -168,7 +171,6 @@ public Map<String, TableDesc> getAllTablesMap(String prj) {
return globalTables;
}

ProjectInstance project = ProjectManager.getInstance(config).getProject(prj);
Set<String> prjTableNames = project.getTables();

Map<String, TableDesc> ret = new LinkedHashMap<>();
Expand Down Expand Up @@ -248,8 +250,10 @@ public void removeSourceTable(String tableIdentity, String prj) throws IOExcepti
* again
*/
public void resetProjectSpecificTableDesc(String prj) throws IOException {
// avoid cyclic locks
ProjectInstance project = ProjectManager.getInstance(config).getProject(prj);

try (AutoLock lock = srcTableMapLock.lockForWrite()) {
ProjectInstance project = ProjectManager.getInstance(config).getProject(prj);
for (String tableName : project.getTables()) {
String tableIdentity = getTableIdentity(tableName);
String key = mapKey(tableIdentity, prj);
Expand Down Expand Up @@ -338,7 +342,7 @@ public TableExtDesc getTableExt(TableDesc t) {
result.setUuid(UUID.randomUUID().toString());
result.setLastModified(0);
result.init(t.getProject());
srcExtMap.put(mapKey(t.getIdentity(), t.getProject()), result);
srcExtMap.putLocal(mapKey(t.getIdentity(), t.getProject()), result);
}
return result;
}
Expand Down

0 comments on commit f37fbce

Please sign in to comment.