You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@impala.apache.org by jo...@apache.org on 2022/02/09 19:01:28 UTC
[impala] 02/02: IMPALA-10989: fix race for result set metadata
This is an automated email from the ASF dual-hosted git repository.
joemcdonnell pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/impala.git
commit 8ddac48f3428c86f2cbd037ced89cfb903298b12
Author: Joe McDonnell <jo...@cloudera.com>
AuthorDate: Mon Feb 7 15:27:35 2022 -0800
IMPALA-10989: fix race for result set metadata
TSAN tests uncovered a race condition between the
thread reading the result set metadata in
ImpalaServer::GetResultSetMetadata() and the
thread setting the result set metadata in
ClientRequestState::SetResultSet() from
ClientRequestState::ExecDdlRequestImpl().
This is introduced by IMPALA-10811, which runs
ExecDdlRequestImpl in an async thread that
can now race with the client thread.
GetResultSetMetadata() holds ClientRequestState's
lock_ while reading the result set metadata, so
the fix is to hold this lock when writing the
result set metadata.
Testing:
- Ran TSAN core job
Change-Id: Ic0833ed20d62474c434fa94bbbf8cd8ea99a7cf4
Reviewed-on: http://gerrit.cloudera.org:8080/18212
Tested-by: Impala Public Jenkins <im...@cloudera.com>
Reviewed-by: Csaba Ringhofer <cs...@cloudera.com>
---
be/src/service/client-request-state.cc | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/be/src/service/client-request-state.cc b/be/src/service/client-request-state.cc
index ca0f6c0..af68245 100644
--- a/be/src/service/client-request-state.cc
+++ b/be/src/service/client-request-state.cc
@@ -721,8 +721,12 @@ void ClientRequestState::ExecDdlRequestImpl(bool exec_in_worker_thread) {
ExecQueryOrDmlRequest(exec_request_->query_exec_request, !exec_in_worker_thread));
}
- // Set the results to be reported to the client.
- SetResultSet(catalog_op_executor_->ddl_exec_response());
+ // Set the results to be reported to the client. Do this under lock to avoid races
+ // with ImpalaServer::GetResultSetMetadata().
+ {
+ lock_guard<mutex> l(lock_);
+ SetResultSet(catalog_op_executor_->ddl_exec_response());
+ }
}
bool ClientRequestState::ShouldRunExecDdlAsync() {