OceanBase logo

OceanBase

A unified distributed database ready for your transactional, analytical, and AI workloads.

DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Resources

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS

OceanBase Cloud

OceanBase Database

Tools

Connectors and Middleware

QUICK START

OceanBase Cloud

OceanBase Database

BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Company

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

International - English
中国站 - 简体中文
日本 - 日本語
Sign In
Start on Cloud

A unified distributed database ready for your transactional, analytical, and AI workloads.

DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS
OceanBase CloudOceanBase Database
ToolsConnectors and Middleware
QUICK START
OceanBase CloudOceanBase Database
BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

Start on Cloud
编组
All Products
    • Databases
    • iconOceanBase Database
    • iconOceanBase Cloud
    • iconOceanBase Tugraph
    • iconInteractive Tutorials
    • iconOceanBase Best Practices
    • Tools
    • iconOceanBase Cloud Platform
    • iconOceanBase Migration Service
    • iconOceanBase Developer Center
    • iconOceanBase Migration Assessment
    • iconOceanBase Admin Tool
    • iconOceanBase Loader and Dumper
    • iconOceanBase Deployer
    • iconKubernetes operator for OceanBase
    • iconOceanBase Diagnostic Tool
    • iconOceanBase Binlog Service
    • Connectors and Middleware
    • iconOceanBase Database Proxy
    • iconEmbedded SQL in C for OceanBase
    • iconOceanBase Call Interface
    • iconOceanBase Connector/C
    • iconOceanBase Connector/J
    • iconOceanBase Connector/ODBC
    • iconOceanBase Connector/NET
icon

OceanBase Database Proxy

V4.3.1

  • What is ODP?
  • Installation and deployment
    • Overview
    • Deploy ODP by using obd
    • Deploy ODP by using OCP
    • Deploy ODP by using the CLI
    • Deployment modes
  • Basic operations
  • Configuration parameter
    • View and modify parameters
    • Parameter summary
    • Global parameters
      • automatic_match_work_thread
      • block_thread_num
      • cache_cleaner_clean_interval
      • check_tenant_locality_change
      • client_max_connections
      • client_max_memory_size
      • client_session_id_version
      • client_sock_option_flag_out
      • client_tcp_keepcnt
      • client_tcp_keepidle
      • client_tcp_keepintvl
      • client_tcp_user_timeout
      • cluster_count_high_water_mark
      • cluster_expire_time
      • config_server_refresh_interval
      • congestion_fail_window
      • congestion_failure_threshold
      • congestion_retry_interval
      • connection_diagnosis_option
      • connect_observer_max_retries
      • current_local_config_version
      • default_buffer_water_mark
      • default_inactivity_timeout
      • delay_exit_time
      • delay_update_entry_interval
      • detect_server_timeout
      • digest_sql_length
      • enable_abort_conn_info
      • enable_async_log
      • enable_async_pull_location_cache
      • enable_bad_route_reject
      • enable_binlog_service
      • enable_cached_server
      • enable_causal_order_read
      • enable_client_connection_lru_disconnect
      • enable_client_ip_checkout
      • enable_cluster_checkout
      • enable_compression_protocol
      • enable_congestion
      • enable_connection_diagnosis
      • enable_cpu_isolate
      • enable_cpu_topology
      • enable_extra_prometheus_metric
      • enable_flow_control
      • enable_full_link_trace
      • enable_full_username
      • enable_get_rslist_remote
      • enable_global_ps_cache
      • enable_index_route
      • enable_monitor_stat
      • enable_ob_protocol_v2
      • enable_ob_protocol_v2_with_client
      • enable_obproxy_rpc_service
      • enable_partition_table_route
      • enable_performance_mode
      • enable_pl_route
      • enable_primary_zone
      • enable_prometheus
      • enable_proxy_scramble
      • enable_qa_mode
      • enable_qos
      • enable_report_session_stats
      • enable_reroute
      • enable_sequence_prefetch
      • enable_sharding
      • enable_single_leader_node_routing
      • enable_standby
      • enable_stat
      • enable_strict_kernel_release
      • enable_strict_stat_time
      • enable_sync_all_stats
      • enable_syslog_file_compress
      • enable_syslog_wf
      • enable_trace
      • enable_trace_stats
      • enable_trans_detail_stats
      • enable_transaction_internal_routing
      • enable_xa_route
      • fetch_proxy_bin_random_time
      • fetch_proxy_bin_timeout
      • flow_consumer_reenable_threshold
      • flow_event_queue_threshold
      • flow_high_water_mark
      • flow_low_water_mark
      • grpc_client_num
      • grpc_thread_num
      • hot_upgrade_exit_timeout
      • hot_upgrade_failure_retries
      • hot_upgrade_rollback_timeout
      • idc_list_refresh_interval
      • ignore_local_config
      • internal_cmd_mem_limited
      • ip_listen_mode
      • ldg_info_refresh_interval
      • listen_port
      • local_bound_ip
      • local_bound_ipv6_ip
      • log_cleanup_interval
      • log_dir_size_threshold
      • log_file_percentage
      • long_async_task_timeout
      • max_log_file_size
      • max_syslog_file_count
      • max_syslog_file_time
      • mem_leak_check_class_name
      • mem_leak_check_mod_name
      • metadb_server_state_refresh_interval
      • min_congested_connect_timeout
      • min_keep_congestion_interval
      • monitor_cost_ms_unit
      • monitor_item_limit
      • monitor_item_max_idle_period
      • monitor_log_level
      • monitor_stat_dump_interval
      • monitor_stat_high_threshold
      • monitor_stat_low_threshold
      • monitor_stat_middle_threshold
      • need_convert_vip_to_tname
      • net_accept_threads
      • net_config_poll_timeout
      • normal_pl_update_threshold
      • obproxy_config_server_url
      • obproxy_sys_password
      • partition_location_expire_relative_time
      • prometheus_cost_ms_unit
      • prometheus_listen_port
      • prometheus_sync_interval
      • protocol_diagnosis_level
      • proxy_hot_upgrade_check_interval
      • proxy_id
      • proxy_info_check_interval
      • proxy_local_cmd
      • proxy_mem_limited
      • qa_mode_mock_public_cloud_slb_addr
      • qos_stat_clean_interval
      • qos_stat_item_limit
      • refresh_idc_list
      • refresh_json_config
      • refresh_rslist
      • request_buffer_length
      • rootservice_list
      • routing_cache_mem_limited
      • rpc_enable_direct_expire_route_entry
      • rpc_enable_congestion
      • rpc_enable_global_index
      • rpc_enable_force_srv_black_list
      • rpc_enable_reroute
      • rpc_enable_parallel_handler
      • rpc_enable_retry_request_info_log
      • rpc_force_srv_black_list
      • rpc_max_request_batch_size
      • rpc_listen_port
      • rpc_max_response_batch_size
      • rpc_net_timeout_base
      • rpc_max_server_table_entry_num
      • rpc_request_timeout
      • rpc_period_task_interval
      • rpc_server_entry_expire_time
      • rpc_request_timeout_delta
      • rpc_server_net_invalid_time_us
      • rpc_server_net_handler_expire_time
      • rpc_server_net_max_pending_request
      • rpc_srv_session_pool_inactive_timeout
      • rpc_support_key_partition_shard_request
      • sequence_entry_expire_time
      • sequence_fail_retry_count
      • sequence_prefetch_threshold
      • server_detect_fail_threshold
      • server_detect_mode
      • server_detect_refresh_interval
      • server_routing_mode
      • server_state_refresh_interval
      • server_tcp_init_cwnd
      • server_tcp_keepcnt
      • server_tcp_keepidle
      • server_tcp_keepintvl
      • server_tcp_user_timeout
      • shard_scan_thread_num
      • short_async_task_timeout
      • skip_proxy_sys_private_check
      • skip_proxyro_check
      • slow_proxy_process_time_threshold
      • slow_transaction_time_threshold
      • sock_option_flag_out
      • sock_packet_mark_out
      • sock_packet_tos_out
      • sock_recv_buffer_size_out
      • sock_send_buffer_size_out
      • sql_table_cache_expire_relative_time
      • sql_table_cache_mem_limited
      • sqlaudit_mem_limited
      • stack_size
      • stat_dump_interval
      • stat_table_sync_interval
      • syslog_io_bandwidth_limit
      • syslog_level
      • task_thread_num
      • tenant_location_valid_time
      • tunnel_request_size_threshold
      • username_separator
      • work_thread_num
      • xflush_log_level
    • Multi-level parameters
      • binlog_service_ip
      • compression_algorithm
      • enable_client_ssl
      • enable_cloud_full_username
      • enable_read_write_split
      • enable_server_ssl
      • enable_transaction_split
      • enable_weak_reroute
      • mysql_version
      • ob_max_read_stale_time
      • obproxy_force_parallel_query_dop
      • obproxy_read_consistency
      • obproxy_read_only
      • observer_query_timeout_delta
      • observer_sys_password
      • observer_sys_password1
      • proxy_idc_name
      • proxy_primary_zone_name
      • proxy_route_policy
      • proxy_tenant_name
      • query_digest_time_threshold
      • read_stale_retry_interval
      • rootservice_cluster_name
      • route_diagnosis_level
      • slow_query_time_threshold
      • ssl_attributes
      • target_db_server
  • Connection management
    • Principles
    • Session status synchronization
    • Configure a globally unique client session ID
    • Client session
    • Server session
    • Network connection
  • Data routing
    • Factors affecting data routing
    • ODP routing
    • Intra-tenant routing
      • Overview
      • IP address-based routing
      • Partitioned table-based routing for strong-consistency reads
      • Global index table-based routing for strong-consistency reads
      • Replicated table-based routing for strong-consistency reads
      • Primary zone-based routing for strong-consistency reads
      • Strategy-based routing
      • Distributed transaction routing
      • Rerouting
      • Forcible routing
    • Automatic routing to the primary/standby tenants
    • Read/Write separation
    • Follower latency threshold
    • Function partition key routing
      • Overview
      • String functions
      • Numeric calculation functions
      • Date calculation functions
      • FAQ
    • Character set-based routing
  • Logs
    • Overview
    • obproxy_diagnosis.log
    • obproxy_digest.log
    • obproxy_error.log
    • obproxy_slow.log
    • obproxy_stat.log
    • obproxy.log
  • Commands
    • Overview
    • Dedicated ODP commands
      • ALTER
      • KILL
      • ping
      • SHOW
    • Compatible MySQL commands
      • BINLOG
      • KILL
      • SHOW PROCESSLIST
      • SHOW RELAYLOG EVENTS
      • SHOW SLAVE HOSTS
  • High availability mechanism
    • Overview
    • High availability of ODP services
    • High availability of OceanBase Database
    • High availability testing
  • Security and protocols
  • RPC service port
  • Operation and maintenance
    • Troubleshooting logic
    • Performance analysis
    • Show Trace
    • Routing diagnostics
      • Overview
      • Obtain diagnostic information
      • Diagnostic point troubleshooting
        • Overview
        • SQL_PARSE
        • ROUTE_INFO
        • LOCATION_CACHE_LOOKUP
        • ROUTINE_ENTRY_LOOKUP_DONE
        • FETCH_TABLE_RELATED_DATA
        • TABLE_ENTRY_LOOKUP_DONE
        • EXPR_PARSE
        • CALC_ROWID
        • RESOLVE_TOKEN
        • RESOLVE_EXPR
        • CALC_PARTITION_ID
        • PARTITION_ID_CALC_DONE
        • PARTITION_ENTRY_LOOKUP_DONE
        • ROUTE_POLICY
        • CONGESTION_CONTROL
        • RETRY
        • HANDLE_RESPONSE
      • Examples
    • Memory leak diagnostics
    • Connection diagnostics
  • Release Notes
    • Versioning rules
    • Enterprise Edition
      • V4.3
        • ODP Enterprise Edition V4.3.1
        • ODP Enterprise Edition V4.3.0
      • V4.2
        • ODP Enterprise Edition V4.2.3
        • ODP Enterprise Edition V4.2.2
        • ODP Enterprise Edition V4.2.1
      • V4.1
        • ODP Enterprise Edition V4.1.0
      • V4.0
        • ODP Enterprise Edition V4.0.0
      • V3.2
        • ODP Enterprise Edition V3.2.11
        • ODP Enterprise Edition V3.2.3.5
    • Community Edition
      • V4.3
        • ODP Community Edition V4.3.1
      • V4.2
        • ODP Community Edition V4.2.3
        • ODP Community Edition V4.2.1
        • ODP Community Edition V4.2.0
      • V4.1
        • ODP Community Edition V4.1.0
      • V4.0
        • ODP Community Edition V4.0.0

Download PDF

What is ODP? Overview Deploy ODP by using obd Deploy ODP by using OCP Deploy ODP by using the CLI Deployment modes Basic operations View and modify parameters Parameter summary automatic_match_work_thread block_thread_num cache_cleaner_clean_interval check_tenant_locality_change client_max_connections client_max_memory_size client_session_id_version client_sock_option_flag_out client_tcp_keepcnt client_tcp_keepidle client_tcp_keepintvl client_tcp_user_timeout cluster_count_high_water_mark cluster_expire_time config_server_refresh_interval congestion_fail_window congestion_failure_threshold congestion_retry_interval connection_diagnosis_option connect_observer_max_retries current_local_config_version default_buffer_water_mark default_inactivity_timeout delay_exit_time delay_update_entry_interval detect_server_timeout digest_sql_length enable_abort_conn_info enable_async_log enable_async_pull_location_cache enable_bad_route_reject enable_binlog_service enable_cached_server enable_causal_order_read enable_client_connection_lru_disconnect enable_client_ip_checkout enable_cluster_checkout enable_compression_protocol enable_congestion enable_connection_diagnosis enable_cpu_isolate enable_cpu_topology enable_extra_prometheus_metric enable_flow_control enable_full_link_trace enable_full_username enable_get_rslist_remote enable_global_ps_cache enable_index_route enable_monitor_stat enable_ob_protocol_v2 enable_ob_protocol_v2_with_client enable_obproxy_rpc_service enable_partition_table_route enable_performance_mode enable_pl_route enable_primary_zone enable_prometheus enable_proxy_scramble enable_qa_mode enable_qos enable_report_session_stats enable_reroute enable_sequence_prefetch enable_sharding enable_single_leader_node_routing enable_standby enable_stat enable_strict_kernel_release enable_strict_stat_time enable_sync_all_stats enable_syslog_file_compress enable_syslog_wf enable_trace enable_trace_stats enable_trans_detail_stats enable_transaction_internal_routing enable_xa_route fetch_proxy_bin_random_time fetch_proxy_bin_timeout flow_consumer_reenable_threshold flow_event_queue_threshold flow_high_water_mark flow_low_water_mark grpc_client_num grpc_thread_num hot_upgrade_exit_timeout hot_upgrade_failure_retries hot_upgrade_rollback_timeout idc_list_refresh_interval ignore_local_config
OceanBase logo

The Unified Distributed Database for the Al Era.

Follow Us
Products
OceanBase CloudOceanBase EnterpriseOceanBase Community EditionOceanBase seekdb
Resources
DocsBlogLive DemosTraining & Certification
Company
About OceanBaseTrust CenterLegalPartnerContact Us
Follow Us

© OceanBase 2026. All rights reserved

Cloud Service AgreementPrivacy PolicySecurity
Contact Us
Document Feedback
  1. Documentation Center
  2. OceanBase Database Proxy
  3. V4.3.1
iconOceanBase Database Proxy
V 4.3.1
  • V 4.3.4
  • V 4.3.3
  • V 4.3.2
  • V 4.3.1
  • V 4.3.0
  • V 4.2.3
  • V 4.2.2
  • V 4.2.0 and earlier

Automatic routing to the primary/standby tenants

Last Updated:2025-02-18 09:26:25  Updated
share
What is on this page
Background information
Technical mechanism
Feature description
Service name
ODP routing
O&M

folded

share

Background information

In OceanBase Database V2.x and V3.x, disaster recovery is implemented based on the cluster-level primary/standby mode. A primary/standby cluster pair is identified by cluster_name. By default, you log in to the primary cluster (cluster_id = 0). If the login connection string carries cluster_id, it indicates that you are logging in to the primary/standby clusters. The primary/standby relationship is maintained in OceanBase Cloud Platform (OCP).

In OceanBase Database V4.1.0 and later, disaster recovery is implemented based on the tenant-level primary/standby mode. PRIMARY and STANDBY roles are assigned to tenants rather than clusters. Clusters are used only for tenant management and a cluster is uniquely identified by the cluster name. Two different tenants can be in a primary/standby relationship. The primary/standby relationships of tenants are no longer maintained in databases, and the primary and standby tenants in databases do not record the identities of each other. The primary/standby relationships of tenants are maintained in OCP instead. To enable automatic routing to primary/standby tenants, OceanBase Database introduces the concept of service. A service can serve multiple tenants in the same cluster or across clusters. When you use OceanBase Database Proxy (ODP) to connect to a database, you can specify the service name to route the connection to the primary tenant.

Technical mechanism

The following figure shows the basic framework for the feature of automatic routing to the primary/standby tenants in OceanBase Database. If you use a specific connection string to log in to ODP, ODP determines that you are logging in to the primary/standby tenants, obtains the tenant information from OCP, automatically routes SQL requests to the primary tenant, and forwards the SQL requests to the corresponding OBServer node. The OBServer node checks the tenant information. If the check is passed, ODP establishes a connection with the OBServer node.

Feature description

Notice

This feature requires the cooperation of OCP, ODP, and OceanBase Database. To use this feature, make sure that OCP is of V4.3.1 or later, ODP is of V4.3.1 or later, and OceanBase Database is of V4.2.4 or a later V4.2.x version.

Service name

  1. Create a service name.

    When you create a primary/standby tenant pair on the GUI of the OCP console, you can create a service name to uniquely identify the entry to the primary/standby tenants. For more information about the service name, see Manage service names.

  2. View information about the tenants associated with the service name.

    Log in to the sys tenant and execute the following statement to view all tenants in the cluster that are associated with the service name:

    SELECT t.tenant_id, t.tenant_name 
        FROM oceanbase.CDB_OB_SERVICES AS s JOIN DBA_OB_TENANTS AS t 
        ON s.tenant_id = t.tenant_id WHERE s.service_name = "xxxx";
    

    If OCP manages multiple OceanBase clusters, you need to run this command for each cluster.

  3. Log in to the primary/standby tenants by specifying the service name.

    Verify that the same service name is specified for the primary/standby tenants and that the clusters to which the primary/standby tenants belong are managed by OCP and associated with the same ODP cluster. Then, when you connect to the database through ODP, you can specify the service name for automatic routing to the primary/standby tenants. A sample connection string is as follows:

    obclient -h<IP> -P<PORT> -u<USER_NAME>@SERVICE:<SERVICE_NAME> -p
    

    In the connection string, SERVICE: is a keyword and must be set to the service name of the tenant to log in to. <IP> and <PORT> must be replaced with the IP address and port number of ODP.

    Notice

    If you use the username SERVICE (case-insensitive) to log in to an OceanBase cluster from ODP, ODP determines that you are logging in to the primary/standby tenants, and uses the cluster name specified by cluster_name as the service name of the tenant to log in to.

    Note

    ODP V4.3.1 BP3 and later V4.3.1.x versions allow you to specify service names in the <USER_NAME>@SERVICE#<SERVICE_NAME> or <SERVICE_NAME>-SERVICE-<USER_NAME> format.

    Assume that the IP address and port number of ODP are 10.10.10.1 and 2883 respectively, and that the service name is test. The connection string is as follows:

    obclient -h10.10.10.1 -P2883 -uroot@SERVICE:test
    # or
    obclient -h10.10.10.1 -P2883 -uroot@SERVICE#test
    # or
    obclient -h10.10.10.1 -P2883 -utest-SERVICE-root
    

    After you log in by using the service name, ODP automatically routes the request to the primary tenant associated with the service name. You can associate one service name with multiple tenants. When the database is being upgraded or migrated, service name-based routing ensures seamless application connection. The service name remains unchanged even if the backend database changes.

ODP routing

After you configure a service name for login, ODP can implement automatic routing to the primary tenant. The working mechanism is described as follows:

  • Routing retries: When a switchover or failover is performed at the backend, ODP automatically retries to connect to available tenants based on the negotiated error codes. Retries across clusters are supported. If ODP retries to connect to the primary tenant, no error is returned, implementing routing switching imperceptible to the business system.

    For the following types of SQL requests, ODP does not support tenant switching or retries but returns an error code of OceanBase Database:

    • Intra-transaction routing: ODP does not perform tenant switching but still forwards the request to the tenant that starts the transaction.

    • Temporary table-based routing: ODP forwards the request to the node that processes the previous request.

    • Request relying on the execution result of the previous SQL request: A query with functions such as found_rows() and row_count() must be forwarded to the node that processes the previous request.

    • Data import by using LOAD FILE: Tenant switching is not supported.

    • Cursor/Piece-based routing: When the client uses cursors or pieces to obtain or upload data, all requests are forcibly routed to the same node.

  • Automatic primary tenant detection: When a routing retry occurs, it means that the cached primary tenant information is incorrect. ODP obtains the tenant role of the corresponding OBServer node based on the tenant list, finds the primary tenant, and updates the cached information.

  • Periodic update: ODP updates the routing information of service names at an interval specified by config_server_refresh_interval, which is 60s by default. This ensures that the cached information does not lag too much behind the current situation.

  • High availability: After you log in with a service name, ODP writes the cached information to the disk and still provides automatic routing when OCP is unavailable.

O&M

You can configure the service name feature by using the following parameters:

  • enable_standby: specifies whether to enable automatic routing to the primary/standby tenants. The default value is True. If you set the parameter to False, ODP does not use the service name for routing.

  • config_server_refresh_interval: specifies the time interval for ODP to obtain config server information from OCP. The default value is 60s. Service name information is also obtained based on this time interval.

Note

When you use a service name for login, the login is not affected by the enable_cloud_full_username or enable_full_username parameter.

When an issue related to the primary/standby tenants occurs, you can check the cached information of the tenants associated with the service name or the error code for troubleshooting.

  • For login with a service name, a cache file named obproxy_service_name_info.json is generated in the etc directory under the installation directory of ODP. You can check this file to verify whether the information obtained by ODP based on the service name is correct.

    Note

    In ODP, service names are stored in lowercase.

  • The error code OB_NOT_PRIMARY_TENANT(-4782) indicates that the SQL request has been forwarded to the standby tenant and a switchover may have been performed.

  • The error code OB_SERVICE_NAME_NOT_FOUND(-4780) indicates that the service name does not exist in OceanBase Database and the information cached by ODP may have been outdated.

Previous topic

Forcible routing
Last

Next topic

Read/Write separation
Next
What is on this page
Background information
Technical mechanism
Feature description
Service name
ODP routing
O&M