Skip to content

Commit

Permalink
Make SRRoute initialization not crashed even SR is not linked
Browse files Browse the repository at this point in the history
Summary: Mcrouter crashed in S430813 due to SR is not linked and config is not gated by service_router_capable. The diff make it throw error instead of crash

Reviewed By: stuclar, vrishal

Differential Revision: D51049080

fbshipit-source-id: 1e6388f84d5013fe023d270e53fc2c62b1e13e2f
  • Loading branch information
disylh authored and facebook-github-bot committed Jul 9, 2024
1 parent 1a2a4a7 commit 3befde1
Show file tree
Hide file tree
Showing 17 changed files with 45 additions and 5 deletions.
5 changes: 5 additions & 0 deletions mcrouter/lib/carbon/example/gen/HelloGoodbyeRouterInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,4 +206,9 @@ HelloGoodbyeRouterInfo::buildRouteMapWithProxy() {
HelloGoodbyeRouterInfo::buildRouteMapForWrapper() {
return RouteHandleFactoryMapForWrapper();
}

/* static */ bool HelloGoodbyeRouterInfo::isSRLinked() {
return false;
}

} // namespace hellogoodbye
1 change: 1 addition & 0 deletions mcrouter/lib/carbon/example/gen/HelloGoodbyeRouterInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ struct HelloGoodbyeRouterInfo {
static RouteHandleFactoryMap buildRouteMap();
static RouteHandleFactoryMapWithProxy buildRouteMapWithProxy();
static RouteHandleFactoryMapForWrapper buildRouteMapForWrapper();
static bool isSRLinked();

static std::unique_ptr<facebook::memcache::mcrouter::
ExtraRouteHandleProviderIf<HelloGoodbyeRouterInfo>>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,4 +303,4 @@ class ThriftTransport<hellogoodbye::HelloGoodbyeRouterInfo> : public ThriftTrans
};

} // namespace memcache
} // namespace facebook
} // namespace facebook
5 changes: 5 additions & 0 deletions mcrouter/lib/carbon/test/gen/ARouterInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,11 @@ ARouterInfo::buildRouteMapWithProxy() {
ARouterInfo::buildRouteMapForWrapper() {
return RouteHandleFactoryMapForWrapper();
}

/* static */ bool ARouterInfo::isSRLinked() {
return false;
}

} // namespace A
} // namespace test
} // namespace carbon
1 change: 1 addition & 0 deletions mcrouter/lib/carbon/test/gen/ARouterInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ struct ARouterInfo {
static RouteHandleFactoryMap buildRouteMap();
static RouteHandleFactoryMapWithProxy buildRouteMapWithProxy();
static RouteHandleFactoryMapForWrapper buildRouteMapForWrapper();
static bool isSRLinked();

static std::unique_ptr<facebook::memcache::mcrouter::
ExtraRouteHandleProviderIf<ARouterInfo>>
Expand Down
2 changes: 1 addition & 1 deletion mcrouter/lib/carbon/test/gen/AThriftTransport.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,4 +222,4 @@ class ThriftTransport<carbon::test::A::ARouterInfo> : public ThriftTransportMeth
};

} // namespace memcache
} // namespace facebook
} // namespace facebook
5 changes: 5 additions & 0 deletions mcrouter/lib/carbon/test/gen/BRouterInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,11 @@ BRouterInfo::buildRouteMapWithProxy() {
BRouterInfo::buildRouteMapForWrapper() {
return RouteHandleFactoryMapForWrapper();
}

/* static */ bool BRouterInfo::isSRLinked() {
return false;
}

} // namespace B
} // namespace test
} // namespace carbon
1 change: 1 addition & 0 deletions mcrouter/lib/carbon/test/gen/BRouterInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ struct BRouterInfo {
static RouteHandleFactoryMap buildRouteMap();
static RouteHandleFactoryMapWithProxy buildRouteMapWithProxy();
static RouteHandleFactoryMapForWrapper buildRouteMapForWrapper();
static bool isSRLinked();

static std::unique_ptr<facebook::memcache::mcrouter::
ExtraRouteHandleProviderIf<BRouterInfo>>
Expand Down
2 changes: 1 addition & 1 deletion mcrouter/lib/carbon/test/gen/BThriftTransport.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,4 +222,4 @@ class ThriftTransport<carbon::test::B::BRouterInfo> : public ThriftTransportMeth
};

} // namespace memcache
} // namespace facebook
} // namespace facebook
5 changes: 5 additions & 0 deletions mcrouter/lib/carbon/test/gen/CarbonTestRouterInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,5 +202,10 @@ CarbonTestRouterInfo::buildRouteMapWithProxy() {
CarbonTestRouterInfo::buildRouteMapForWrapper() {
return RouteHandleFactoryMapForWrapper();
}

/* static */ bool CarbonTestRouterInfo::isSRLinked() {
return false;
}

} // namespace test
} // namespace carbon
1 change: 1 addition & 0 deletions mcrouter/lib/carbon/test/gen/CarbonTestRouterInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ struct CarbonTestRouterInfo {
static RouteHandleFactoryMap buildRouteMap();
static RouteHandleFactoryMapWithProxy buildRouteMapWithProxy();
static RouteHandleFactoryMapForWrapper buildRouteMapForWrapper();
static bool isSRLinked();

static std::unique_ptr<facebook::memcache::mcrouter::
ExtraRouteHandleProviderIf<CarbonTestRouterInfo>>
Expand Down
2 changes: 1 addition & 1 deletion mcrouter/lib/carbon/test/gen/CarbonTestThriftTransport.h
Original file line number Diff line number Diff line change
Expand Up @@ -277,4 +277,4 @@ class ThriftTransport<carbon::test::CarbonTestRouterInfo> : public ThriftTranspo
};

} // namespace memcache
} // namespace facebook
} // namespace facebook
5 changes: 5 additions & 0 deletions mcrouter/lib/carbon/test/gen/CarbonThriftTestRouterInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,5 +202,10 @@ CarbonThriftTestRouterInfo::buildRouteMapWithProxy() {
CarbonThriftTestRouterInfo::buildRouteMapForWrapper() {
return RouteHandleFactoryMapForWrapper();
}

/* static */ bool CarbonThriftTestRouterInfo::isSRLinked() {
return false;
}

} // namespace test
} // namespace carbon
1 change: 1 addition & 0 deletions mcrouter/lib/carbon/test/gen/CarbonThriftTestRouterInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ struct CarbonThriftTestRouterInfo {
static RouteHandleFactoryMap buildRouteMap();
static RouteHandleFactoryMapWithProxy buildRouteMapWithProxy();
static RouteHandleFactoryMapForWrapper buildRouteMapForWrapper();
static bool isSRLinked();

static std::unique_ptr<facebook::memcache::mcrouter::
ExtraRouteHandleProviderIf<CarbonThriftTestRouterInfo>>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,4 +332,4 @@ class ThriftTransport<carbon::test::CarbonThriftTestRouterInfo> : public ThriftT
};

} // namespace memcache
} // namespace facebook
} // namespace facebook
9 changes: 9 additions & 0 deletions mcrouter/lib/network/gen/MemcacheRouterInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,5 +202,14 @@ MemcacheRouterInfo::buildRouteMapWithProxy() {
MemcacheRouterInfo::buildRouteMapForWrapper() {
return RouteHandleFactoryMapForWrapper();
}

/* static */ bool MemcacheRouterInfo::isSRLinked() {
MemcacheRouterInfo::RouteHandlePtr (*fn)(
RouteHandleFactory<MemcacheRouterInfo::RouteHandleIf>&,
const folly::dynamic& json,
ProxyBase& proxy) = makeSRRoute;
return fn != nullptr;
}

} // namespace memcache
} // namespace facebook
1 change: 1 addition & 0 deletions mcrouter/lib/network/gen/MemcacheRouterInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ struct MemcacheRouterInfo {
static RouteHandleFactoryMap buildRouteMap();
static RouteHandleFactoryMapWithProxy buildRouteMapWithProxy();
static RouteHandleFactoryMapForWrapper buildRouteMapForWrapper();
static bool isSRLinked();

static std::unique_ptr<facebook::memcache::mcrouter::
ExtraRouteHandleProviderIf<MemcacheRouterInfo>>
Expand Down

0 comments on commit 3befde1

Please sign in to comment.