# US 12,111,817 B2 · Log execution method and apparatus, computer device and storage medium

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 12,111,817 B2
- Document ID: US12111817B2
- Status: Granted
- Kind: B2
- Application number: 18/079,238
- Filed: 2022-12-12
- Published: 2023-04-13
- Granted: 2024-10-08
- Earliest claimed: 2021-02-09
- Assignees: Tencent Technology (Shenzhen) Company Limited
- Applicants: Tencent Technology (Shenzhen) Company Limited
- Inventors: Haixiang Li; Haohua Li
- Web page: https://patentgrep.com/patent/US12111817B2

## CPC

- G06F 11/1471: involving logging of persistent data for recovery
- G06F 16/2365: {Ensuring data consistency and integrity}
- G06F 11/1469: {Backup restoration techniques}
- G06F 16/2219: {Large Object storage; Management thereof}
- G06F 16/2379: {Updates performed during online database operations; commit processing}
- G06F 16/27: Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
- G06F 2201/80: Database-specific techniques
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

This application provides a log execution method and apparatus, a computer device and a storage medium and relates to the technical field of databases. The method includes circularly scanning a log execution active window, the log execution active window comprising a plurality of logs which are not executed, and all the logs before the log execution active window having been executed; acquiring a conflict verification result of a log in the log execution active window based on storage range information of the log, the storage range information indicating a storage range of the log and a storage range of a target number of logs before the log, and the target number being equal to a size of the log execution active window; and executing the log if the conflict verification result is no conflict.

## Claims

### Claim 1

A log execution method, performed by a first node device in a distributed storage system, and comprising:
circularly scanning a log execution active window, the log execution active window comprising a plurality of logs which are not executed, and all the logs before the log execution active window having been executed;
acquiring a conflict verification result of a log in the log execution active window based on storage range information of the log, the storage range information indicating a storage range of the log and a storage range of a target number of logs before the log, and the target number being equal to a size of the log execution active window; and
executing the log if the conflict verification result is no conflict, comprising:
writing the business data corresponding to the logs stored in a log list-to-be-executed into a volatile storage medium or a non-volatile storage medium;
adding the logs corresponding to the business data written to the volatile storage medium to an executed log list, wherein different state parameters are set in the executed log list for logs, of which the business data is not written to the non-volatile storage medium, and for logs, of which the business data is written to the non-volatile storage medium, respectively; and
after a crash event occurs in the distributed storage system, acquiring, when the distributed storage system is restarted, a plurality of logs-to-be-restored from the executed log list based on the state parameters, and restoring business data corresponding to the plurality of logs-to-be-restored to the volatile storage medium in sequence based on a storage order of the plurality of logs-to-be-restored in the executed log list.

### Claim 2 (depends on 1)

The method according to claim 1, wherein the operation of obtaining the conflict verification result of the log based on the storage range information of the log comprises:
reading the storage range information of the log, and obtaining the storage range of the log and the storage range of the target number of logs before the log;
if an intersection set between the storage range of the log and the storage range of the target number of logs is an empty set, determining the conflict verification result as no conflict; and
if the intersection set between the storage range of the log and the storage range of the target number of logs is not the empty set, determining the conflict verification result as conflict occurrence.

### Claim 3 (depends on 1)

The method according to claim 1, wherein the operation of executing the log comprises:
adding the log to the log list-to-be-executed; and
calling a log execution thread to process logs stored in the log list-to-be-executed.

### Claim 4 (depends on 3)

The method according to claim 3, wherein processing the logs stored in the log list-to-be-executed comprising:
if a data stored in the volatile storage medium is greater than or equal to a storage threshold, writing the business data stored in the volatile storage medium to a non-volatile storage medium.

### Claim 5 (depends on 1)

The method according to claim 1, further comprising:
if the conflict verification result is conflict occurrence, acquiring a number of logs in conflict with the logs;
determining a scanning frequency for the logs based on the number of logs; and
scanning the logs based on the scanning frequency, refreshing the conflict verification result until the conflict verification result is no conflict, and executing the logs.

### Claim 6 (depends on 5)

The method according to claim 5, wherein the operation of determining the scanning frequency for the logs based on the number of logs comprises:
determining the scanning frequency as a first frequency if the number of logs is greater than a conflict threshold; or,
if that the number of logs is less than or equal to the conflict threshold, determining the scanning frequency as a second frequency, wherein the second frequency is greater than the first frequency.

### Claim 7 (depends on 5)

The method according to claim 5, wherein the operation of scanning the logs based on the scanning frequency comprises:
adding the logs to a log list corresponding to the scanning frequency, and scanning the logs stored in the log list based on the scanning frequency.

### Claim 8 (depends on 1)

The method according to claim 1, further comprising:
circularly scanning a log matching index table, the log matching index table being used for recording the number of copies of a plurality of logs-to-be-committed stored in the distributed storage system; and
committing the logs-to-be-committed if the number of copies of any logs-to-be-committed in the log matching index table meets a target condition.

### Claim 9 (depends on 1)

The method according to claim 1, wherein the first node device is elected by votes from a plurality of second node devices in the distributed storage system after the end of a last term, and a maximum index in consecutive committed logs in the first node device is greater than or equal to a maximum index in consecutive committed logs in the plurality of second node devices.

### Claim 10 (depends on 9)

The method according to claim 9, further comprising:
if at least one log is missing in a log committing active window, acquiring an index of each missing log, the log committing active window comprising a plurality of logs which are not committed, and all the logs before the log committing active window having been committed; and
based on the index, requesting the missing log from the plurality of second node devices.

### Claim 11 (depends on 10)

The method according to claim 10, further comprising:
receiving target logs returned by the plurality of second node devices and committing condition information of the target logs;
completing a target log with the committing condition information of being committed in the log committing active window; and
requesting a target log with the committing condition information of being uncommitted from a terminal.

### Claim 12

A computer device, comprising one or more processors and one or more memories storing at least one computer program, the at least one computer program being loaded and executed by the one or more processors to implement:
circularly scanning a log execution active window, the log execution active window comprising a plurality of logs which are not executed, and all the logs before the log execution active window having been executed;
acquiring a conflict verification result of a log in the log execution active window based on storage range information of the log, the storage range information indicating a storage range of the log and a storage range of a target number of logs before the log, and the target number being equal to a size of the log execution active window; and
executing the log if the conflict verification result is no conflict, comprising:
writing, by the one or more processors, the business data corresponding to the logs stored in a log list-to-be-executed into a volatile storage medium or a non-volatile storage medium stored in the one or more memories;
adding, by the one or more processors, the logs corresponding to the business data written to the volatile storage medium to an executed log list in the one or more memories, wherein different state parameters are set in the executed log list for logs in the one or more memories, of which the business data is not written to the non-volatile storage medium, and for logs, of which the business data is written to the non-volatile storage medium, respectively; and
after a crash event occurs in the distributed storage system, acquiring, by the one or more processors, when the distributed storage system is restarted, a plurality of logs-to-be-restored from the executed log list based on the state parameters, and restoring business data corresponding to the plurality of logs-to-be-restored to the volatile storage medium in the one or more memories in sequence based on a storage order of the plurality of logs-to-be-restored in the executed log list.

### Claim 13 (depends on 12)

The computer device according to claim 12, wherein the operation of obtaining the conflict verification result of the log based on the storage range information of the log comprises:
reading the storage range information of the log, and obtaining the storage range of the log and the storage range of the target number of logs before the log;
if an intersection set between the storage range of the log and the storage range of the target number of logs is an empty set, determining the conflict verification result as no conflict; and
if the intersection set between the storage range of the log and the storage range of the target number of logs is not the empty set, determining the conflict verification result as conflict occurrence.

### Claim 14 (depends on 12)

The computer device according to claim 12, wherein the operation of executing the log comprises:
adding the log to the log list-to-be-executed; and
calling a log execution thread to process logs stored in the log list-to-be-executed.

### Claim 15 (depends on 14)

The computer device according to claim 14, wherein the processing the logs stored in the log list-to-be-executed comprising:
if a data stored in the volatile storage medium is greater than or equal to a storage threshold, writing the business data stored in the volatile storage medium to a non-volatile storage medium.

### Claim 16

A non-transitory computer readable storage medium, storing at least one computer program, the at least one computer program being loaded and executed by a processor to implement:
circularly scanning a log execution active window, the log execution active window comprising a plurality of logs which are not executed, and all the logs before the log execution active window having been executed;
acquiring a conflict verification result of a log in the log execution active window based on storage range information of the log, the storage range information indicating a storage range of the log and a storage range of a target number of logs before the log, and the target number being equal to a size of the log execution active window; and
executing the log if the conflict verification result is no conflict, comprising:
writing, by the processor, the business data corresponding to the logs stored in a log list-to-be-executed into a volatile storage medium or a non-volatile storage medium stored;
adding, by the processor, the logs corresponding to the business data written to the volatile storage medium to an executed log list, wherein different state parameters are set in the executed log list for logs, of which the business data is not written to the non-volatile storage medium, and for logs, of which the business data is written to the non-volatile storage medium, respectively; and
after a crash event occurs in the distributed storage system, acquiring, by the processor, when the distributed storage system is restarted, a plurality of logs-to-be-restored from the executed log list based on the state parameters, and restoring business data corresponding to the plurality of logs-to-be-restored to the volatile storage medium in sequence based on a storage order of the plurality of logs-to-be-restored in the executed log list.

### Claim 17 (depends on 16)

The computer readable storage medium according to claim 16, the method further comprising:
if the conflict verification result is conflict occurrence, acquiring a number of logs in conflict with the logs;
determining a scanning frequency for the logs based on the number of logs; and
scanning the logs based on the scanning frequency, refreshing the conflict verification result until the conflict verification result is no conflict, and executing the logs.

### Claim 18 (depends on 17)

The computer readable storage medium according to claim 17, wherein the operation of determining the scanning frequency for the logs based on the number of logs comprises:
determining the scanning frequency as a first frequency if the number of logs is greater than a conflict threshold; or,
if that the number of logs is less than or equal to the conflict threshold, determining the scanning frequency as a second frequency, wherein the second frequency is greater than the first frequency.
