MCPcopy Create free account
hub / github.com/apache/impala / CloseSessionInternal

Method CloseSessionInternal

be/src/service/impala-server.cc:2044–2107  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2042}
2043
2044Status ImpalaServer::CloseSessionInternal(const TUniqueId& session_id,
2045 const SecretArg& secret, bool ignore_if_absent) {
2046 DCHECK(secret.is_session_secret());
2047 VLOG_QUERY << "Closing session: " << PrintId(session_id);
2048
2049 // Find the session_state and remove it from the map.
2050 shared_ptr<SessionState> session_state;
2051 {
2052 lock_guard<mutex> l(session_state_map_lock_);
2053 SessionStateMap::iterator entry = session_state_map_.find(session_id);
2054 if (entry == session_state_map_.end() || !secret.Validate(entry->second->secret)) {
2055 if (ignore_if_absent) {
2056 return Status::OK();
2057 } else {
2058 if (entry != session_state_map_.end()) {
2059 // Log invalid attempts to connect. Be careful not to log secret.
2060 VLOG(1) << "Client tried to connect to session " << PrintId(session_id)
2061 << " with invalid secret.";
2062 }
2063 string err_msg = Substitute("Invalid session id: $0", PrintId(session_id));
2064 VLOG(1) << "CloseSessionInternal(): " << err_msg;
2065 return Status::Expected(err_msg);
2066 }
2067 }
2068 session_state = entry->second;
2069 session_state_map_.erase(session_id);
2070 }
2071 DCHECK(session_state != nullptr);
2072 if (session_state->session_type == TSessionType::BEESWAX) {
2073 ImpaladMetrics::IMPALA_SERVER_NUM_OPEN_BEESWAX_SESSIONS->Increment(-1L);
2074 } else {
2075 ImpaladMetrics::IMPALA_SERVER_NUM_OPEN_HS2_SESSIONS->Increment(-1L);
2076 DecrementSessionCount(session_state->connected_user);
2077 }
2078 unordered_set<TUniqueId> inflight_queries;
2079 vector<TUniqueId> interrupted_queries;
2080 {
2081 lock_guard<mutex> l(session_state->lock);
2082 DCHECK(!session_state->closed);
2083 session_state->closed = true;
2084 // Since closed is true, no more queries will be added to the inflight list.
2085 inflight_queries.insert(session_state->inflight_queries.begin(),
2086 session_state->inflight_queries.end());
2087 interrupted_queries.swap(session_state->interrupted_queries);
2088 }
2089 // Unregister all open queries from this session.
2090 Status status = Status::Expected("Session closed");
2091 for (const TUniqueId& query_id: inflight_queries) {
2092 // TODO: deal with an error status
2093 UnregisterQueryDiscardResult(query_id, &status);
2094 }
2095 {
2096 lock_guard<mutex> l(interrupted_query_statuses_lock_);
2097 for (const TUniqueId& query_id: interrupted_queries) {
2098 interrupted_query_statuses_.erase(query_id);
2099 }
2100 }
2101 // Reconfigure the poll period of session_maintenance_thread_ if necessary.

Callers 1

CloseSessionHandlerMethod · 0.80

Calls 13

PrintIdFunction · 0.85
OKFunction · 0.85
SubstituteFunction · 0.85
TNetworkAddressToStringFunction · 0.85
is_session_secretMethod · 0.80
eraseMethod · 0.80
findMethod · 0.45
endMethod · 0.45
ValidateMethod · 0.45
IncrementMethod · 0.45
insertMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected