You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by ad...@apache.org on 2019/10/14 19:13:47 UTC
[kudu] branch master updated: net_util: tag DNS resolution as a
blocking operation
This is an automated email from the ASF dual-hosted git repository.
adar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git
The following commit(s) were added to refs/heads/master by this push:
new 4c4abfe net_util: tag DNS resolution as a blocking operation
4c4abfe is described below
commit 4c4abfe875bf949613f3f0fef5941ed60039ee62
Author: Adar Dembo <ad...@cloudera.com>
AuthorDate: Sun Oct 13 21:41:39 2019 -0700
net_util: tag DNS resolution as a blocking operation
ThreadRestrictions tags are basically only used to prevent reactor threads
from doing IO or invoking blocking operations. For some reason we didn't
annotate DNS resolution as blocking. After doing so, I had to make a few
exceptions in existing code. They're not great, but at least they're not in
tserver reactors.
Change-Id: I90e280855bc8e6797f887da26dfa67cfaf945dcf
Reviewed-on: http://gerrit.cloudera.org:8080/14424
Reviewed-by: Alexey Serbin <as...@cloudera.com>
Tested-by: Kudu Jenkins
---
src/kudu/client/client-internal.cc | 4 +++-
src/kudu/master/catalog_manager.cc | 8 ++++++++
src/kudu/master/catalog_manager.h | 1 -
src/kudu/util/net/net_util.cc | 2 ++
4 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/src/kudu/client/client-internal.cc b/src/kudu/client/client-internal.cc
index 3e1d8e1..befa03c 100644
--- a/src/kudu/client/client-internal.cc
+++ b/src/kudu/client/client-internal.cc
@@ -648,7 +648,9 @@ void KuduClient::Data::ConnectToClusterAsync(KuduClient* client,
HostPort hp;
Status s = hp.ParseString(master_server_addr, master::Master::kDefaultPort);
if (s.ok()) {
- // TODO(todd): Do address resolution asynchronously as well.
+ // TODO(todd): Until address resolution is done asynchronously, we need
+ // to allow waiting as some callers may be reactor threads.
+ ThreadRestrictions::ScopedAllowWait allow_wait;
s = dns_resolver_->ResolveAddresses(hp, &addrs);
}
if (!s.ok()) {
diff --git a/src/kudu/master/catalog_manager.cc b/src/kudu/master/catalog_manager.cc
index f3d5bc1..6108981 100644
--- a/src/kudu/master/catalog_manager.cc
+++ b/src/kudu/master/catalog_manager.cc
@@ -88,6 +88,7 @@
#include "kudu/gutil/basictypes.h"
#include "kudu/gutil/bind.h"
#include "kudu/gutil/bind_helpers.h"
+#include "kudu/gutil/gscoped_ptr.h"
#include "kudu/gutil/macros.h"
#include "kudu/gutil/map-util.h"
#include "kudu/gutil/port.h"
@@ -142,6 +143,7 @@
#include "kudu/util/scoped_cleanup.h"
#include "kudu/util/stopwatch.h"
#include "kudu/util/thread.h"
+#include "kudu/util/thread_restrictions.h"
#include "kudu/util/threadpool.h"
#include "kudu/util/trace.h"
@@ -3335,6 +3337,12 @@ Status RetryingTSRpcTask::ResetTSProxy() {
// so the task need not take ownership of the returned pointer.
target_ts_desc_ = ts_desc.get();
+ // We may be called by a reactor thread, and creating proxies may trigger DNS
+ // resolution.
+ //
+ // TODO(adar): make the DNS resolution asynchronous.
+ ThreadRestrictions::ScopedAllowWait allow_wait;
+
shared_ptr<tserver::TabletServerAdminServiceProxy> ts_proxy;
RETURN_NOT_OK(target_ts_desc_->GetTSAdminProxy(master_->messenger(), &ts_proxy));
ts_proxy_.swap(ts_proxy);
diff --git a/src/kudu/master/catalog_manager.h b/src/kudu/master/catalog_manager.h
index f4ce890..2dd529f 100644
--- a/src/kudu/master/catalog_manager.h
+++ b/src/kudu/master/catalog_manager.h
@@ -37,7 +37,6 @@
#include <sparsehash/dense_hash_map>
#include "kudu/consensus/metadata.pb.h"
-#include "kudu/gutil/gscoped_ptr.h"
#include "kudu/gutil/macros.h"
#include "kudu/gutil/port.h"
#include "kudu/gutil/ref_counted.h"
diff --git a/src/kudu/util/net/net_util.cc b/src/kudu/util/net/net_util.cc
index c9f1129..74653dd 100644
--- a/src/kudu/util/net/net_util.cc
+++ b/src/kudu/util/net/net_util.cc
@@ -54,6 +54,7 @@
#include "kudu/util/scoped_cleanup.h"
#include "kudu/util/stopwatch.h"
#include "kudu/util/subprocess.h"
+#include "kudu/util/thread_restrictions.h"
#include "kudu/util/trace.h"
// Mac OS 10.9 does not appear to define HOST_NAME_MAX in unistd.h
@@ -91,6 +92,7 @@ Status GetAddrInfo(const string& hostname,
const addrinfo& hints,
const string& op_description,
AddrInfo* info) {
+ ThreadRestrictions::AssertWaitAllowed();
addrinfo* res = nullptr;
const int rc = getaddrinfo(hostname.c_str(), nullptr, &hints, &res);
const int err = errno; // preserving the errno from the getaddrinfo() call