Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
a982111
Support table level read and write lock
Jun 2, 2020
944f9dc
Use table lock to replace db lock in some functions
Jun 2, 2020
08a7114
use table write lock to replace db write lock
Jun 3, 2020
5118571
remove some unused temp code
Jun 3, 2020
1354d05
use table lock to replace db lock
Jun 3, 2020
cffcbbd
Continue to use table lock to replace db lock
caiconghui Jun 3, 2020
3763e58
finish to replace db lock by table lock
Jun 4, 2020
e13b952
fix unit test
Jun 4, 2020
c2ff443
add null check for olap_table
caiconghui Jun 4, 2020
0646783
fix merge
caiconghui Jun 13, 2020
f648195
modify .gitignore content
Jun 16, 2020
dd9952d
fix Alter Class
Jun 16, 2020
d98756e
Fix AlterJobV2 and MaterializedViewHandler
Jun 16, 2020
6ec9c84
Fix RollupJob
Jun 16, 2020
721a840
fix RollupJobV2
Jun 16, 2020
f76aa9b
fix cancel
Jun 16, 2020
6167684
fix SchemaChangeJobV2
Jun 16, 2020
a25bb58
fix
Jun 16, 2020
92dfd35
fix DeleteHandler
Jun 16, 2020
e40783a
fix test
Jun 16, 2020
746e85a
fix conflict after rebasing mater
Sep 22, 2020
c824f7c
fix ReportHandler
Sep 22, 2020
3a57f8d
fix unit test failed for AlterTest
Sep 24, 2020
9357dc0
fix
Oct 20, 2020
461335b
Add MetaLockUtils and fix some table lock level
Oct 20, 2020
40f5cf1
Fix unittest for AlterTest failed
Oct 21, 2020
d3c287c
Change db level lock to table level lock for query
Oct 21, 2020
1860b70
fix unittest failed
Oct 22, 2020
46b8d04
fix conflict for table lock and db lock
Nov 4, 2020
dc87753
fix unittest failed
Nov 4, 2020
07d7314
fix unit test failed
Nov 4, 2020
6a98354
Fix SparkLoadJobTest Failed
Nov 5, 2020
b3b30a7
Fix save image lock
Nov 5, 2020
619b71c
Add unit test for MetaLockUtils
Nov 5, 2020
8fb1e32
use MetadataLockUtils to lock table when finish transaction
Nov 6, 2020
11e4e07
remove useless code of dropTableWithLock for Database
Nov 9, 2020
1b089e4
remove useless db read lock
Nov 9, 2020
841d3f8
remove useless db read lock and change some db read lock to table locks
Nov 9, 2020
520cd27
fix
Nov 9, 2020
a2faf9d
fix
caiconghui Nov 9, 2020
26f39d1
fix
caiconghui Nov 9, 2020
e518f1e
Fix dead lock bug
Nov 10, 2020
7563bfb
fix unit test failed for SelectStmt
Nov 19, 2020
7dfc2f8
Fix by review
Nov 27, 2020
6319533
Add table lock when update BackendReportVersion in SystemInfoService
caiconghui Nov 29, 2020
8bb19a2
change db level lock to table lock level in http2
caiconghui Nov 29, 2020
b4b6807
Fix broker load failed bug and add unit test for db
Dec 2, 2020
b2f55d7
fix
Dec 2, 2020
faa6eb2
Add some comment for the usage of MetaLockUtils
Dec 3, 2020
56b8d31
apply fix patch
Jan 11, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ docs/.temp
docs/.vuepress/dist
docs/node_modules
docs/build
docs/contents
gensrc/build
fe/fe-core/target
thirdparty/src
Expand Down
288 changes: 128 additions & 160 deletions fe/fe-core/src/main/java/org/apache/doris/alter/Alter.java

Large diffs are not rendered by default.

42 changes: 11 additions & 31 deletions fe/fe-core/src/main/java/org/apache/doris/alter/AlterHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -271,35 +271,18 @@ public void handleFinishedReplica(AgentTask task, TTabletInfo finishTabletInfo,
alterJob.handleFinishedReplica(task, finishTabletInfo, reportVersion);
}

/*
* cancel alter job when drop table
* olapTable:
* table which is being dropped
*/
public void cancelWithTable(OlapTable olapTable) {
// make sure to hold to db write lock before calling this
AlterJob alterJob = getAlterJob(olapTable.getId());
if (alterJob == null) {
return;
protected void cancelInternal(AlterJob alterJob, OlapTable olapTable, String msg) {
// cancel
if (olapTable != null) {
olapTable.writeLock();
}
alterJob.cancel(olapTable, "table is dropped");

// remove from alterJobs and add to finishedOrCancelledAlterJobs operation should be perform atomically
lock();
try {
alterJob = alterJobs.remove(olapTable.getId());
if (alterJob != null) {
alterJob.clear();
finishedOrCancelledAlterJobs.add(alterJob);
}
alterJob.cancel(olapTable, msg);
} finally {
unlock();
if (olapTable != null) {
olapTable.writeUnlock();
}
}
}

protected void cancelInternal(AlterJob alterJob, OlapTable olapTable, String msg) {
// cancel
alterJob.cancel(olapTable, msg);
jobDone(alterJob);
}

Expand Down Expand Up @@ -427,12 +410,9 @@ public void handleFinishAlterTask(AlterReplicaTask task) throws MetaNotFoundExce
throw new MetaNotFoundException("database " + task.getDbId() + " does not exist");
}

db.writeLock();
OlapTable tbl = (OlapTable) db.getTableOrThrowException(task.getTableId(), Table.TableType.OLAP);
tbl.writeLock();
try {
OlapTable tbl = (OlapTable) db.getTable(task.getTableId());
if (tbl == null) {
throw new MetaNotFoundException("tbl " + task.getTableId() + " does not exist");
}
Partition partition = tbl.getPartition(task.getPartitionId());
if (partition == null) {
throw new MetaNotFoundException("partition " + task.getPartitionId() + " does not exist");
Expand Down Expand Up @@ -478,7 +458,7 @@ public void handleFinishAlterTask(AlterReplicaTask task) throws MetaNotFoundExce

LOG.info("after handle alter task tablet: {}, replica: {}", task.getSignature(), replica);
} finally {
db.writeUnlock();
tbl.writeUnlock();
}
}

Expand Down
27 changes: 11 additions & 16 deletions fe/fe-core/src/main/java/org/apache/doris/alter/AlterJobV2.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@
import org.apache.doris.catalog.Database;
import org.apache.doris.catalog.OlapTable;
import org.apache.doris.catalog.OlapTable.OlapTableState;
import org.apache.doris.catalog.Table;
import org.apache.doris.common.Config;
import org.apache.doris.common.FeMetaVersion;
import org.apache.doris.common.MetaNotFoundException;
import org.apache.doris.common.io.Text;
import org.apache.doris.common.io.Writable;
import org.apache.doris.persist.gson.GsonUtils;
Expand Down Expand Up @@ -176,10 +178,8 @@ public synchronized void run() {
}
}

public final boolean cancel(String errMsg) {
synchronized (this) {
return cancelImpl(errMsg);
}
public synchronized final boolean cancel(String errMsg) {
return cancelImpl(errMsg);
}

/**
Expand All @@ -188,21 +188,16 @@ public final boolean cancel(String errMsg) {
*/
protected boolean checkTableStable(Database db) throws AlterCancelException {
OlapTable tbl = null;
boolean isStable = false;
db.readLock();
try {
tbl = (OlapTable) db.getTable(tableId);
if (tbl == null) {
throw new AlterCancelException("Table " + tableId + " does not exist");
}
tbl = (OlapTable) db.getTableOrThrowException(tableId, Table.TableType.OLAP);
} catch (MetaNotFoundException e) {
throw new AlterCancelException(e.getMessage());
}

isStable = tbl.isStable(Catalog.getCurrentSystemInfo(),
boolean isStable = tbl.isStable(Catalog.getCurrentSystemInfo(),
Catalog.getCurrentCatalog().getTabletScheduler(), db.getClusterName());
} finally {
db.readUnlock();
}

db.writeLock();
tbl.writeLock();
try {
if (!isStable) {
errMsg = "table is unstable";
Expand All @@ -216,7 +211,7 @@ protected boolean checkTableStable(Database db) throws AlterCancelException {
return true;
}
} finally {
db.writeUnlock();
tbl.writeUnlock();
}
}

Expand Down
Loading