[ 
https://issues.apache.org/jira/browse/IMPALA-12660?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17811418#comment-17811418
 ] 

ASF subversion and git services commented on IMPALA-12660:
----------------------------------------------------------

Commit f3ac2ddbfef0d7cd359b7c9ae47d424791327c6d in impala's branch 
refs/heads/master from Michael Smith
[ https://gitbox.apache.org/repos/asf?p=impala.git;h=f3ac2ddbf ]

IMPALA-12747: Atomic update of execution state

QueryDriver owns instances of ClientRequestState and TExecRequest. The
ClientRequestState is used to track execution state of the client-facing
side of a query. TExecRequest encapsulates context about the query
produced by the planner.

When a QueryDriver is created, it creates an instance of
ClientRequestState, but has not yet executed planning. It would create
an empty TExecRequest and pass a pointer to it to ClientRequestState,
then update the content of TExecRequest when RunFrontendPlanner is
called from ImpalaServer::ExecuteInternal.

Updating TExecRequest was not atomic, so it was possible other
operations - like producing a QueryStateRecord for /queries in the web
UI - would try to read the content of TExecRequest while updating. This
caused TSAN errors and occasional crashes in internal-server-test, which
runs concurrent requests and examines them through calls to /queries.

Changes ClientRequestState to
- Provide a static placeholder for TExecRequest during creation that
  represents an empty context for an UNKNOWN statement type (default
  initialized in Thrift).
- Make all references to TExecRequest const so its content cannot be
  updated in a non-thread-safe manner.
- ClientRequestState uses an AtomicPtr which is updated atomically when
  the filled TExecRequest is available.

QueryDriver does not publicly expose access to TExecRequest, so we can
ensure its use is thread-safe without atomics.

ClientRequestState::exec_request() will return either a reference to the
static placeholder or the value provided after - which is never changed
- so this reference will always be valid for the lifetime of the
ClientRequestState.

Updates user_has_profile_access to be AtomicBool for the same reason.

Reverts tsan-suppressions for IMPALA-12660 so we get TSAN coverage. Adds
suppression for a lock-order-inversion bug (IMPALA-12757) that was
uncovered after fixing this data race.

Testing:
- InternalServerTest.SimultaneousMultipleQueriesOneSession would fail
  after ~10 test runs. Ran 90 times without failure.
- Passed TSAN run of backend tests.

Change-Id: I9a967c5c84b6a401f8f5764373f6cd7ee807545f
Reviewed-on: http://gerrit.cloudera.org:8080/20956
Reviewed-by: Jason Fehr <jf...@cloudera.com>
Reviewed-by: Riza Suminto <riza.sumi...@cloudera.com>
Tested-by: Impala Public Jenkins <impala-public-jenk...@cloudera.com>


> TSAN error in ImpalaServer::QueryStateRecord::Init
> --------------------------------------------------
>
>                 Key: IMPALA-12660
>                 URL: https://issues.apache.org/jira/browse/IMPALA-12660
>             Project: IMPALA
>          Issue Type: Sub-task
>          Components: Backend
>    Affects Versions: Impala 4.4.0
>            Reporter: Csaba Ringhofer
>            Assignee: Jason Fehr
>            Priority: Critical
>              Labels: unit-test
>             Fix For: Impala 4.4.0
>
>         Attachments: tsan.txt
>
>
> See error in tsan.txt



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-all-unsubscr...@impala.apache.org
For additional commands, e-mail: issues-all-h...@impala.apache.org

Reply via email to