Skip to content

Commit 68598cd

Browse files
Cameron Evansfacebook-github-bot
Cameron Evans
authored andcommitted
Back out "Revert D68910844"
Summary: This is an unland of an unland. Meta: I did my original unland due to it being plausible that the diff was triggering a latent bug in the THRIFT_SERVER_EVENT handler and crashing in tsp_global/di_capacity/quota_enforcement_manager. It was worth attempting the unland as a potential mitigation to unblock the release of that service's binaries. The service continues to crash without this diff being in prod, so mitigation of that problem continues. Meanwhile, I would like to re-land this diff since it there is no longer any reason to suspect it causes problems. Reviewed By: sazonovkirill Differential Revision: D71045479 fbshipit-source-id: 39eea82404423df24324b66732a5f35cb28d0c2a
1 parent 9a6a8c1 commit 68598cd

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

thrift/lib/cpp2/server/ThriftServer.cpp

+34
Original file line numberDiff line numberDiff line change
@@ -1973,6 +1973,40 @@ folly::Optional<OverloadResult> ThriftServer::checkOverload(
19731973
LoadShedder::CUSTOM};
19741974
}
19751975

1976+
// Log services that might break if ConcurrencyController's executionLimit is
1977+
// unsynced from maxRequests and is synced with only concurrencyLimit instead.
1978+
if (folly::test_once(cancelSetMaxRequestsCallbackHandleFlag_) ||
1979+
folly::test_once(serviceMightRelyOnSyncedMaxRequestsFlag_)) {
1980+
// This is okay. Either maxRequests syncing was cancelled, or we already
1981+
// logged that the service might rely on the syncing.
1982+
} else if (
1983+
thriftConfig_.getMaxRequests().get() ==
1984+
thriftConfig_.getConcurrencyLimit().get()) {
1985+
// This is okay. When ConcurrencyController's executionLimit is synced with
1986+
// concurrencyLimit instead of maxRequests, there will be no difference
1987+
// since the values are the same.
1988+
} else if (
1989+
!isActiveRequestsTrackingDisabled() &&
1990+
!THRIFT_FLAG(enforce_queue_concurrency_resource_pools) &&
1991+
!getMethodsBypassMaxRequestsLimit().contains(method)) {
1992+
// This is okay. No bypass method is enabled. ThriftServer is strictly
1993+
// rejecting requests once there are maxRequests requests on the server.
1994+
// ConcurrencyController's will never enforce its executionLimit (synced
1995+
// from maxRequests) since ThriftServer will never pass enough requests into
1996+
// the resource pool. After ConcurrencyController's executionLimit is synced
1997+
// from concurrencyLimit instead, the new default value (uint32_t max) will
1998+
// continue to be greater than the number of requests that can be passed
1999+
// into the resource pool.
2000+
} else {
2001+
// This is not okay. When ConcurrencyController's executionLimit is unsynced
2002+
// from maxRequests and synced to concurrencyLimit instead, the service will
2003+
// encounter a behavioral change.
2004+
folly::call_once(serviceMightRelyOnSyncedMaxRequestsFlag_, [this]() {
2005+
LOG(WARNING) << "Service might rely on synced max requests.";
2006+
THRIFT_SERVER_EVENT(serviceMightRelyOnSyncedMaxRequests).log(*this);
2007+
});
2008+
}
2009+
19762010
// If active request tracking is disabled or we are using resource pools,
19772011
// skip max requests enforcement here. Resource pools has its own separate
19782012
// concurrency limiting mechanism.

thrift/lib/cpp2/server/ThriftServer.h

+4
Original file line numberDiff line numberDiff line change
@@ -1854,6 +1854,10 @@ class ThriftServer : public apache::thrift::concurrency::Runnable,
18541854
// from resource pools, when setConcurrencyLimit is explicitly called.
18551855
folly::once_flag cancelSetMaxRequestsCallbackHandleFlag_;
18561856

1857+
// If the service might rely on the synced maxRequests, then we need to log.
1858+
// Logging only needs to happen once.
1859+
folly::once_flag serviceMightRelyOnSyncedMaxRequestsFlag_;
1860+
18571861
struct IdleServerAction : public folly::HHWheelTimer::Callback {
18581862
IdleServerAction(
18591863
ThriftServer& server,

0 commit comments

Comments
 (0)