Skip to content

Commit

Permalink
[BugFix] Txn timeout too fast if not specify timeout in http header (
Browse files Browse the repository at this point in the history
…#34544)

Signed-off-by: lixianhai <lixianhai.lxh@alibaba-inc.com>
  • Loading branch information
smartlxh authored Nov 16, 2023
1 parent dd32eb6 commit eb806a1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1313,7 +1313,7 @@ private long loadTxnBeginImpl(TLoadTxnBeginRequest request, String clientIp) thr
if (connectContext.getSessionVariable().isEnableLoadProfile()) {
TransactionResult resp = new TransactionResult();
StreamLoadMgr streamLoadManager = GlobalStateMgr.getCurrentState().getStreamLoadMgr();
streamLoadManager.beginLoadTask(dbName, table.getName(), request.getLabel(), timeoutSecond, resp, false);
streamLoadManager.beginLoadTask(dbName, table.getName(), request.getLabel(), timeoutSecond * 1000, resp, false);
if (!resp.stateOK()) {
LOG.warn(resp.msg);
throw new UserException(resp.msg);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import com.starrocks.qe.ConnectContext;
import com.starrocks.qe.DDLStmtExecutor;
import com.starrocks.qe.GlobalVariable;
import com.starrocks.qe.SessionVariable;
import com.starrocks.server.GlobalStateMgr;
import com.starrocks.sql.ast.AddPartitionClause;
import com.starrocks.sql.ast.DropTableStmt;
Expand All @@ -55,6 +56,8 @@
import com.starrocks.thrift.TImmutablePartitionResult;
import com.starrocks.thrift.TListMaterializedViewStatusResult;
import com.starrocks.thrift.TListTableStatusResult;
import com.starrocks.thrift.TLoadTxnBeginRequest;
import com.starrocks.thrift.TLoadTxnBeginResult;
import com.starrocks.thrift.TLoadTxnCommitRequest;
import com.starrocks.thrift.TLoadTxnCommitResult;
import com.starrocks.thrift.TResourceUsage;
Expand Down Expand Up @@ -383,6 +386,27 @@ public void testCreatePartitionApi() throws TException {
Assert.assertEquals(1, partition.partitions.size());
}

@Test
public void testLoadTxnBegin() throws Exception {
FrontendServiceImpl impl = new FrontendServiceImpl(exeEnv);
TLoadTxnBeginRequest request = new TLoadTxnBeginRequest();
request.setLabel("test_label");
request.setDb("test");
request.setTbl("site_access_auto");
request.setUser("root");
request.setPasswd("");

new MockUp<SessionVariable>() {
@Mock
public boolean isEnableLoadProfile() {
return true;
}
};

TLoadTxnBeginResult result = impl.loadTxnBegin(request);
Assert.assertEquals(result.getStatus().getStatus_code(), TStatusCode.OK);
}

@Test
public void testCreatePartitionApiSlice() throws TException {
Database db = GlobalStateMgr.getCurrentState().getDb("test");
Expand Down

0 comments on commit eb806a1

Please sign in to comment.