From 77192f102c5fab595119c67d764fb4a009f98e35 Mon Sep 17 00:00:00 2001 From: Jay Edgar Date: Thu, 19 Sep 2024 14:12:42 -0700 Subject: [PATCH] Temporary fix for TAO Summary: I'm investigating a TAO crash and while I'm not yet sure of the root cause, I know where it is crashing. Add some checks in the code to prevent the crash from occurring to see if TAO can make progress while waiting for the root cause fix. Differential Revision: D63038824 fbshipit-source-id: d01e733f152ccbf19f14055295d9a920e3a112ee --- .../mysql_protocol/MysqlResult.cpp | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/third-party/squangle/src/squangle/mysql_client/mysql_protocol/MysqlResult.cpp b/third-party/squangle/src/squangle/mysql_client/mysql_protocol/MysqlResult.cpp index 45cb8331dfc3b..0039f4753fee9 100644 --- a/third-party/squangle/src/squangle/mysql_client/mysql_protocol/MysqlResult.cpp +++ b/third-party/squangle/src/squangle/mysql_client/mysql_protocol/MysqlResult.cpp @@ -16,6 +16,10 @@ namespace facebook::common::mysql_client::mysql_protocol { class MysqlRowMetadata; size_t MysqlResult::numFields() const { + // T202181457 + if (!res_) { + return 0; + } auto ret = mysql_num_fields(res_.get()); VLOG(4) << fmt::format( "mysql_num_fields({}) returned {}", (void*)res_.get(), ret); @@ -23,6 +27,10 @@ size_t MysqlResult::numFields() const { } MYSQL_FIELD* MysqlResult::fields() const { + // T202181457 + if (!res_) { + return nullptr; + } auto ret = mysql_fetch_fields(res_.get()); VLOG(4) << fmt::format( "mysql_fetch_fields({}) returned {}", (void*)res_.get(), (void*)ret); @@ -30,6 +38,10 @@ MYSQL_FIELD* MysqlResult::fields() const { } size_t MysqlResult::numRows() const { + // T202181457 + if (!res_) { + return 0; + } auto ret = mysql_num_rows(res_.get()); VLOG(4) << fmt::format( "mysql_num_rows({}) returned {}", (void*)res_.get(), ret); @@ -64,6 +76,8 @@ InternalResult::FetchRowRet MysqlRowFactory( } // namespace InternalResult::FetchRowRet SyncMysqlResult::fetchRow() { + // T202181457 + CHECK(res_); auto mysqlRow = mysql_fetch_row(res_.get()); VLOG(4) << fmt::format( "mysql_fetch_row({}) returned {}", (void*)res_.get(), (void*)mysqlRow); @@ -74,6 +88,12 @@ InternalResult::FetchRowRet SyncMysqlResult::fetchRow() { InternalResult::FetchRowRet AsyncMysqlResult::fetchRow() { std::unique_ptr row; + // T202181457 + if (!res_) { + return std::make_pair( + MysqlConnection::toHandlerStatus(NET_ASYNC_ERROR), std::move(row)); + } + MYSQL_ROW mysqlRow; auto ret = mysql_fetch_row_nonblocking(res_.get(), &mysqlRow); VLOG(4) << fmt::format(