IP Library Granted Patent US 11,775,521
Granted Patent B2
US 11,775,521 · App. 18/118,943 · Granted Oct 3, 2023

Efficient workload balancing in replicated databases based on result lag computation

Inventors: Yinghua Ouyang (Xi'an, CN); Zhen Tian (Xi'an, CN)
Assignee: SAP SE
G06F16/24542G06F9/5083G06F16/2379G06F16/2471G06F16/27
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 11,775,521
App. No.
18/118,943
Granted
Oct 3, 2023
Kind
B2
Abstract

A method for workload balancing is implemented in a computer system including a primary database system and a secondary database system, the secondary database system being configured as a backup system for the primary database system. The method includes compiling a query received from a client application. The query indicates one or more source tables have corresponding replicate tables. The compiling comprises replace the one or more source tables with the corresponding replicate tables. The method can generate a query execution plan based on the compiled query, determine a per-table result lag based on minimum commit times of the corresponding replicate tables, and compare the per-table result lag with a predefined threshold. Responsive to a determination that the per-table result lag exceeds the predefined threshold, the method can recompile the query by falling back to the one or more source tables from the corresponding replicate tables.

Claims (42)

1. A computer system comprising:

one or more processors;

a primary database system implemented by the one or more processors; and

a secondary database system implemented by the one or more processors, the secondary database system configured as a hot-standby system for the primary database system that is capable of providing at least a minimum amount of essential functionality of the primary database system during a disruption to the primary database system;

wherein the primary database system is configured by programming instructions, executable on the computer system, to cause the one or more processors to:

compile a query received from a client application, wherein the query indicates one or more source tables have corresponding replicate tables, wherein the compiling comprises replacing the one or more source tables with the corresponding replicate tables;

generate a query execution plan based on the compiled query;

determine a per-table result lag based on minimum commit times of the corresponding replicate tables;

compare the per-table result lag with a predefined threshold; and

responsive to a determination that the per-table result lag exceeds the predefined threshold, recompile the query by falling back to the one or more source tables from the corresponding replicate tables.

2. The computer system according to claim 1 , wherein the primary database system is configured by programming instructions, executable on the computer system, to further cause the one or more processors to:

responsive to a determination that the per-table result lag does not exceed the predefined threshold, directly execute the query plan without recompiling the query.

3. The computer system according to claim 1 , wherein the per-table result lag is determined by calculating differences between current time and the minimum commit times of the corresponding replicate tables.

4. The computer system according to claim 3 , wherein if two or more source tables are implicated by the query and have corresponding replica tables, the per-table result lag is a maximum of the calculated differences.

5. The computer system according to claim 1 , wherein the primary database system is configured by programming instructions, executable on the computer system, to further cause the one or more processors to invoke one or more client libraries by the client application and establish open connections between the one or more client libraries to both the primary database system and the secondary database system.

6. The computer system according to claim 5 , wherein the open connections between the one or more client library and the primary database system are read/write connections.

7. The computer system according to claim 5 , wherein the open connections between the one or more client library and the secondary database system are read only connections.

8. The computer system according to claim 1 , wherein the primary database system is configured by programming instructions, executable on the computer system, to further cause the one or more processors to identify a routing hint from the query, wherein the routing hint indicates that workload from the query may be shifted to the secondary database system.

9. The computer system according to claim 1 , wherein the primary database system is configured by programming instructions, executable on the computer system, to further cause the one or more processors to periodically update a map comprising last commit times of source tables that have corresponding replica tables.

10. The computer system according to claim 9 , wherein the primary database system is configured by programming instructions, executable on the computer system, to further cause the one or more processors to maintain last replayed transaction commit timestamps of the corresponding replica tables.

11. A computer-implemented method in a computer system comprising a primary database system and a secondary database system, the secondary database system configured as a backup system for the primary database system that is capable of providing at least a minimum amount of essential functionality of the primary database system during a disruption to the primary database system, the method comprising:

compiling a query received from a client application, wherein the query indicates one or more source tables have corresponding replicate tables, wherein the compiling comprises replacing the one or more source tables with the corresponding replicate tables;

generating a query execution plan based on the compiled query;

determining a per-table result lag based on minimum commit times of the corresponding replicate tables;

comparing the per-table result lag with a predefined threshold; and

responsive to a determination that the per-table result lag exceeds the predefined threshold, recompiling the query by falling back to the one or more source tables from the corresponding replicate tables.

12. The method according to claim 11 , further comprising:

responsive to a determination that the per-table result lag does not exceed the predefined threshold, directly executing the query plan without recompiling the query.

13. The method according to claim 11 , wherein determining the per-table result lag comprises calculating differences between current time and the minimum commit times of the corresponding replicate tables.

14. The method according to claim 13 , wherein determining the per-table result lag comprises finding the maximum of the calculated differences if two or more source tables are implicated by the query and have corresponding replica tables.

15. The method according to claim 11 , further comprising invoking one or more client libraries by the client application and establishing open connections between the one or more client libraries to both the primary database system and the secondary database system.

16. The method according to claim 15 , wherein the open connections between the one or more client library and the primary database system are read/write connections, and the open connections between the one or more client library and the secondary database system are read only connections.

17. The method according to claim 11 , further comprising identifying a routing hint from the query, wherein the routing hint indicates that workload from the query may be shifted to the secondary database system.

18. The method according to claim 11 , further comprising periodically updating a map comprising last commit times of source tables that have corresponding replica tables.

19. The method according to claim 18 , further comprising maintaining last replayed transaction commit timestamps of the corresponding replica tables.

20. A non-transitory computer readable storage medium embodying programming instructions for performing a method, the method comprising:

compiling a query received from a client application, wherein the query indicates one or more source tables have corresponding replicate tables, wherein the compiling comprises replacing the one or more source tables with the corresponding replicate tables;

generating a query execution plan based on the compiled query;

determining a per-table result lag based on minimum commit times of the corresponding replicate tables;

comparing the per-table result lag with a predefined threshold;

responsive to a determination that the per-table result lag exceeds the predefined threshold, recompiling the query by falling back to the one or more source tables from the corresponding replicate tables; and

responsive to a determination that the per-table result lag does not exceed the predefined threshold, directly executing the query plan without recompiling the query.

Assignments (1)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Mar 17, 2023
From: OUYANG, YINGHUA; TIAN, ZHEN
To: SAP SE
Reel/Frame 063021/0743 →
Continuity (3)
Continuation 17722104 · Apr 15, 2022
Continuation 16836469 · Mar 31, 2020
Related Publication 20230222122A1 · Jul 13, 2023
Cited By (4)
US 12,386,835 US 12,405,953 US 12,541,512 US 12,682,103