diff --git a/src/share/parameter/ob_parameter_seed.ipp b/src/share/parameter/ob_parameter_seed.ipp index 32b705a797332c71e70300c7727792802d5b0a95..49f33f3512add9cafb3b413778c5123cda520b4c 100644 --- a/src/share/parameter/ob_parameter_seed.ipp +++ b/src/share/parameter/ob_parameter_seed.ipp @@ -1434,3 +1434,7 @@ DEF_TIME(ilog_index_expire_time, OB_CLUSTER_PARAMETER, "7d", "[0s, 60d]", DEF_BOOL(_auto_drop_tenant_if_restore_failed, OB_CLUSTER_PARAMETER, "True", "auto drop restoring tenant if physical restore fails", ObParameterAttr(Section::OBSERVER, Source::DEFAULT, EditLevel::DYNAMIC_EFFECTIVE)); +DEF_BOOL(ob_proxy_readonly_transaction_routing_policy, OB_TENANT_PARAMETER, "true", + "Proxy route policy for readonly sql", + ObParameterAttr(Section::OBSERVER, Source::DEFAULT, EditLevel::DYNAMIC_EFFECTIVE)); + diff --git a/src/sql/session/ob_basic_session_info.cpp b/src/sql/session/ob_basic_session_info.cpp index d053cba66b7855837afdc87e3d6b2dfaeb8f9192..ac725adf90cbdc60655255f87f36c88726af58a7 100644 --- a/src/sql/session/ob_basic_session_info.cpp +++ b/src/sql/session/ob_basic_session_info.cpp @@ -29,6 +29,7 @@ #include "sql/engine/ob_physical_plan.h" #include "storage/transaction/ob_weak_read_util.h" //ObWeakReadUtil #include "observer/omt/ob_tenant_timezone_mgr.h" +#include "observer/omt/ob_tenant_config_mgr.h" using namespace oceanbase::common; using namespace oceanbase::share; @@ -129,8 +130,18 @@ ObBasicSessionInfo::~ObBasicSessionInfo() bool ObBasicSessionInfo::is_server_status_in_transaction() const { - bool result = get_in_transaction() || - (!get_local_autocommit() && trans_desc_.get_standalone_stmt_desc().is_snapshot_version_valid()); + /*! + * readonly sql not in transaction, for compatible, we also need send in trans flag to proxy. + * for now, + * we use ob_proxy_readonly_transaction_routing_policy parameter decide to send in trans or not. + */ + bool result = get_in_transaction(); + if (!result + && !get_local_autocommit() + && trans_desc_.get_standalone_stmt_desc().is_snapshot_version_valid()) { + omt::ObTenantConfigGuard tenant_config(TENANT_CONF(get_effective_tenant_id())); + result = is_isolation_serializable() || tenant_config->ob_proxy_readonly_transaction_routing_policy; + } return result; }