Information processing device, information processing program, and information processing method
The information processing device and method address synchronization delays in database replication by monitoring and switching server access to prevent clients from accessing outdated data.
Patent Information
- Authority / Receiving Office
- JP · JP
- Patent Type
- Applications
- Current Assignee / Owner
- Filing Date
- 2024-08-28
- Publication Date
- 2026-03-12
AI Technical Summary
In database replication, synchronization delays between the master and slave servers can lead to clients referencing outdated data, as there is no guarantee that data updates are synchronized across both servers, potentially causing inconsistencies.
An information processing device and method that monitors synchronization status between master and slave servers, dynamically changing the server accessed by clients based on synchronization conditions to avoid referencing outdated data.
Ensures that clients always access up-to-date data by detecting synchronization delays and switching to the master server before data inconsistencies occur.
Smart Images

Figure 2026043497000001_ABST
Abstract
Description
[Technical Field]
[0001] The present invention relates to an information processing device, an information processing program, and an information processing method, and can be applied to, for example, a database system employing a master-slave configuration. [Background technology]
[0002] Traditionally, one method of redundant configuration is the master-slave configuration, which is used in database (DB) servers (for example, PostgreSQL, MySQL (registered trademark), etc.) (Non-Patent Document 1). In this configuration, the master and slave maintain the same DB data by performing "replication" between them, which synchronizes changes made to the master's DB with the slave.
[0003] Slave server access control is a function that distributes load by dividing the referenced DB server into master for updates and slave for references.
[0004] 10 to 12 show the basic operations (status monitoring process, update process, and reference process) of conventional slave server access control.
[0005] As shown in Figure 10, the client-side application (client APL30) monitors the status (health check) of the master and slave DB servers (DB server 2-1, DB server 2-2) (A1, A2). Based on the health check status, client APL30 determines whether to perform updates / references and which DB to connect to.
[0006] 11, when an update is subsequently performed, DB client 3 (client APL30) selects master DB server 2-1 and performs DB update. When client APL30 sends a DB update request to RDBMS (Relational Database Management System) 20-1 (B1), DB server 2-1 (RDBMS20-1) updates the data in its own DB21-1 (B2), synchronizes (replicates) the updated data with DB21-2 of DB server 2-2 (B3), and returns a response to DB client 3 (B4).
[0007] On the other hand, when performing a reference, DB client 3 (client APL30) selects slave DB server 2-2 and performs a DB reference, as shown in Figure 12. When client APL30 sends a DB reference request to RDBMS20-2 (C1), DB server 2-2 (RDBMS20-2) references the data in its own DB21-2 (C2) and returns a response to DB client 3 (C3). Because synchronization (replication) is performed between the master and slave, the same reference result can be obtained whether you reference either the master or the slave.
[0008] 13 to 15 show the operation when a failure occurs in conventional slave server access control.
[0009] As shown in Figure 13, if a failure occurs in the master DB server 2-1 during status monitoring, the DB server 2-1 is deemed to have failed and is isolated (Figure 13(A)). In this case, since there is no guarantee that the data in the slave DB server 2-2 is synchronized with the master, the DB client 3 is unable to perform updates or references (Figures 13(B) and (C)).
[0010] On the other hand, as shown in Figure 14, if a failure occurs in DB server 2-2 on the slave side during status monitoring, DB server 2-2 is isolated as a failure (Figure 14(A)). In this case, DB server 2-1 on the master side continues to operate (update) normally, so DB client 3 performs updates / references to DB server 2-1 (Figures 14(B) and (C)).
[0011] Also, as shown in Figure 15, if a failure occurs in the replication between the master and slave, the slave DB server 2-2 is isolated as a failure (Figure 15(A)). In this case, the master DB server 2-1 continues to operate (update) normally, so the DB client 3 performs updates / references to the DB server 2-1 (Figures 15(B) and (C)). [Prior art documents] [Non-patent literature]
[0012] [Non-Patent Document 1] Rental server · Home server setting · Building tips Try using mysql semi-synchronous replication [Searched August 1, 2024], [Online], INTERNET,<https: / / server-setting.info / centos / mysql-semisynchronous.html> Summary of the Invention [Problem to be solved by the invention]
[0013] Incidentally, in database replication, if there is a synchronization delay from the master side to the slave side, there is a possibility that a client referencing the slave side will refer to old data.
[0014] In other words, as shown in Figure 16, when a synchronization delay occurs, it does not become a DB failure (DB failure is detected when a clear failure occurs in DB access, such as a session disconnection), so references / updates are performed as usual (Figure 16(A)).
[0015] Furthermore, if a synchronization delay occurs during replication when an update is made to the master DB server 2-1 (DB21-1), a delay occurs before the update is reflected in the slave DB server 2-2 (DB21-2) (Figure 16(B)).When the DB client 3 references data on the slave DB server 2-2 (DB21-2), replication synchronization has not been completed, so there is a possibility that the data before the update (old data) will be obtained (Figure 16(C)).
[0016] Therefore, there is a demand for an information processing device, an information processing program, and an information processing method that can avoid the problem of clients referencing data before it is updated, even if there is a synchronization delay from the master side to the slave side in replication. [Means for solving the problem]
[0017] The first invention is an information processing device connected to a plurality of server devices, each of which stores a database, one of which operates as a master and the other of which operates as a slave that backs up the master, characterized in that it has a synchronization status monitoring means for monitoring the synchronization status between the master server device and the slave server device, and a control means for changing the server device that references the database depending on whether the synchronization status between the master server device and the slave server device meets predetermined conditions.
[0018] The second information processing program of the present invention is characterized in that it causes a computer installed in an information processing device connected to a plurality of server devices, each of which stores a database, one of which operates as a master and the other of which operates as a slave that backs up the master, to function as a synchronization status monitoring means for monitoring the synchronization status between the master server device and the slave server device, and as a control means for changing the server device that references the database depending on whether the synchronization status between the master server device and the slave server device meets predetermined conditions.
[0019] The third aspect of the present invention is an information processing method used for an information processing device connected to a plurality of server devices, each of which stores a database, one of which operates as a master and the other of which operates as a slave that backs up the master, wherein the information processing device has a synchronization status monitoring means and a control means, wherein the synchronization status monitoring means monitors the synchronization status between the master server device and the slave server device, and the control means changes the server device that references the database depending on whether the synchronization status between the master server device and the slave server device meets predetermined conditions. [Effects of the Invention]
[0020] According to the present invention, even if a synchronization delay occurs from the master side to the slave side in replication, it is possible to avoid the adverse effect of a client referencing data before it is updated. [Brief explanation of the drawings]
[0021] [Figure 1] FIG. 2 is a block diagram showing the functional configuration of a DB client according to the embodiment. [Figure 2] 1 is a block diagram showing the overall configuration of a DB system according to an embodiment. [Figure 3] FIG. 4 is an explanatory diagram illustrating an example of a server status monitoring condition according to the embodiment. [Figure 4] 10A and 10B are explanatory diagrams showing examples of master / slave synchronization state determination conditions and uncompleted transaction presence / absence determination conditions according to the embodiment; [Figure 5] FIG. 1 is an explanatory diagram (part 1) showing the operation of the DB system according to the embodiment. [Figure 6] FIG. 2 is an explanatory diagram (part 2) showing the operation of the DB system according to the embodiment. [Figure 7] FIG. 10 is an explanatory diagram (part 3) showing the operation of the DB system according to the embodiment. [Figure 8] FIG. 10 is an explanatory diagram (part 4) showing the operation of the DB system according to the embodiment. [Figure 9]FIG. 5 is an explanatory diagram (part 5) showing the operation of the DB system according to the embodiment. [Figure 10] FIG. 1 is an explanatory diagram showing the basic operation (status monitoring process) of conventional slave server access control. [Figure 11] FIG. 1 is an explanatory diagram showing the basic operation (update processing) of conventional slave server access control. [Figure 12] FIG. 1 is an explanatory diagram showing the basic operation (reference process) of conventional slave server access control. [Figure 13] FIG. 1 is an explanatory diagram (part 1) showing the operation when a failure occurs in conventional slave server access control. [Figure 14] FIG. 10 is an explanatory diagram (part 2) showing the operation when a failure occurs in conventional slave server access control. [Figure 15] FIG. 10 is an explanatory diagram (part 3) showing the operation when a failure occurs in conventional slave server access control. [Figure 16] FIG. 10 is an explanatory diagram showing the operation when a synchronization delay occurs in conventional slave server access control. DETAILED DESCRIPTION OF THE INVENTION
[0022] (A) Main embodiment Hereinafter, an embodiment of an information processing device, an information processing program, and an information processing method according to the present invention will be described in detail with reference to the drawings.
[0023] (A-1) Configuration of the embodiment <Overall structure> FIG. 2 is a block diagram showing the overall configuration of the DB system according to the embodiment.
[0024] The DB system 5 is configured as a master-slave system including the DB server 2-1 as the master and the DB server 2-2 as the slave. The DB system 5 further includes the DB server 2-1, the DB server 2-2, and the DB client 1, and each device is configured to be capable of wired or wireless communication via a network.
[0025] Also, in this embodiment, the RDBMSs (Relational Database Management Systems) 20-1 and 20-2 provided in the DB servers 2-1 and 2-2 are assumed to be PostgreSQL, but it is not limited thereto, and various RDBMSs having the same functions as PostgreSQL may be applied.
[0026] The DB system 5 is an environment in which transactions such as data updates and references are given from the DB client 1 to the RDBMSs 20 (20-1 and 20-2) of the DB servers 2 (2-1 and 2-2) and processing is performed.
[0027] The DB client 1 gives transactions related to the database to the DB server 2. Note that, unlike the conventional DB client 3, the DB client 1 in this embodiment checks the replication synchronization state between the master and slave, and when detecting a replication synchronization delay, dynamically changes the reference server to avoid referring to old data.
[0028] <Configuration of DB Client> FIG. 1 is a block diagram showing the functional configuration of the DB client according to the embodiment.
[0029] The DB client 1 has a control unit 10 and a storage unit 15.
[0030] The DB client 1 may be entirely configured by hardware (e.g., a dedicated chip, etc.) or may be configured as software (a program) for part or all of it. For example, except for the storage unit 15, the DB client 1 may be configured by installing a program (including the information processing program of the embodiment) on a computer having a processor and a memory.
[0031] The control unit 10 controls each element in the DB client 1 to monitor the status of the DB servers 2-1 and 2-2. The control unit 10 includes a server status monitoring unit 11, a master-slave synchronization control unit 12, and a database request unit 13.
[0032] The server status monitoring unit 11 includes a master / slave synchronization status determining unit 110 and an uncompleted transaction existence determining unit 111, and monitors the status of the DB servers 2-1 and 2-2 according to a server status monitoring condition T1, which will be described later.
[0033] The master / slave synchronization state determination unit 110 checks the synchronization state between the master and the slave in accordance with a master / slave synchronization state determination condition T2, which will be described later.
[0034] The uncompleted transaction presence / absence determining unit 111 checks for an uncompleted transaction that occurs when a synchronization delay occurs between the master and the slave, in accordance with an uncompleted transaction presence / absence determining condition T3, which will be described later.
[0035] When a synchronization delay occurs between the master and slave, the master-slave synchronization control unit 12 stops replication synchronization that synchronizes DB changes in the master DB server 2-1 with the DB in the slave DB server 2-2.
[0036] The database request unit 13 transmits data search requests and update requests, that is, transactions, to the DB servers 2-1 and 2-2 (RDBMS 20-1 and 20-2) and receives the results.
[0037] The storage unit 15 stores a server state monitoring condition T1, a master / slave synchronization state determination condition T2, and an incomplete transaction presence / absence determination condition T3.
[0038] In this embodiment, the server monitoring conditions shown in Fig. 3 are defined as a means of monitoring the status of the master and slave DB servers 2 (2-1, 2-2). In this embodiment, Nos. 1 and 2 in Fig. 3 are used as the monitoring conditions (synchronization status between master and slave, presence or absence of uncompleted transactions), but other monitoring conditions may be applied as appropriate depending on the system.
[0039] Furthermore, as a means for determining the synchronization state between the master and slave, the master / slave synchronization state determination condition T2 shown in Fig. 4(A) is defined. The master / slave synchronization state determination condition in Fig. 4(A) defines the target object (table) and the confirmation condition for requesting confirmation from the RDBMS (PostgreSQL) 20-1 and 20-2 of the DB servers 2-1 and 2-2.
[0040] As a means for determining whether or not there is an incomplete transaction, the system defines the incomplete transaction presence / absence determination condition T3 in Fig. 4(B). The incomplete transaction presence / absence determination condition T3 in Fig. 4(B) defines the target object (transaction management table) for requesting confirmation of a two-phase commit (2PC) transaction to the RDBMS (PostgreSQL) 20-1 and 20-2 of the DB servers 2-1 and 2-2, and the contents to be examined (examination results).
[0041] (A-2) Operation of the embodiment Next, the operation of the DB system 5 according to the embodiment having the above configuration will be described.
[0042] <Server status monitoring> As shown in FIG. 5, the server status monitoring unit 11 of the DB client 1 monitors the status (health check) of the master and slave DB servers 2 (2-1, 2-2) in accordance with the server status monitoring condition T1 (S1, S2).
[0043] During the health check, the server status monitoring unit 11 checks the target synchronization status (determines the synchronization status between the master and the slave and determines whether there is an uncompleted transaction).
[0044] For example, in determining the master-slave synchronization state, the master-slave synchronization state determination unit 110 determines the synchronization state in accordance with the master-slave synchronization state determination condition T2. Specifically, the master-slave synchronization state determination unit 110 determines that a delay has occurred in replication (synchronization) when the number of synchronization delay bytes that exceeds the delay detection threshold exceeds a specified number of times during an interval. Note that the delay detection threshold, number of checks, interval value, etc. are configuration settings that can be changed depending on the target system / service.
[0045] <Master-slave synchronization stop and slave access stop> As mentioned above, if the synchronization delay byte count (delay detection threshold) is exceeded, the slave is put into a failure state, and synchronization from the master is stopped (asynchronous) (Figure 6).
[0046] That is, the master-slave synchronization control unit 12 requests the master DB server 2-1 (RDBMS 20-1) to change the synchronous mode to asynchronous mode (S3), and at the same time stops access (data reference, etc.) from the DB client 1 to the slave DB server 2-2 (FIG. 7) (S4).
[0047] <DBアクセス> 8, the DB client 1 changes the connection destination in advance before a synchronization abnormality occurs. In other words, when a synchronization delay is recognized as a stage before a synchronization abnormality occurs, the database request unit 13 switches the connection destination from DB server 2-2 to DB server 2-1 and requests data reference (S5 to S7).
[0048] <Uncompleted transaction occurs> Furthermore, as shown in FIG. 9, if a synchronization delay occurs between the master and the slave, an incomplete transaction occurs (S8 to S11).
[0049] Monitoring of uncompleted transactions is achieved by checking the 2PC (Two-Phase Commit) transaction management table (object), as shown in the uncompleted transaction presence / absence determination condition T3 in Figure 4(B). Since the management table stores the timestamp at the time of transaction registration, the uncompleted transaction presence / absence determination unit 111 detects a transaction as incomplete if the timestamp is equal to or greater than a threshold. The monitoring threshold and the behavior after detection are configuration settings that can be changed depending on the target system / service.
[0050] (A-3) Effects of the embodiment According to this embodiment, DB client 1 checks the synchronization status of the master and slave, and if a delay is detected, it dynamically changes the referenced server, thereby avoiding referencing old data. [Explanation of symbols]
[0051] 1...DB client, 2 (2-1, 2-2)...DB server, 3...DB client, 5...DB system, 10...control unit, 11...server status monitoring unit, 12...slave synchronization control unit, 13...database request unit, 15...storage unit, 110...inter-slave synchronization status determination unit, 111...uncompleted transaction presence / absence determination unit, 20 (20-1, 20-2)...RDBMS, 21 (21-1, 21-2)...DB, 30...client APL, T1...server status monitoring condition, T2...inter-slave synchronization status determination condition, T3...uncompleted transaction presence / absence determination condition.
Claims
1. An information processing device connected to a plurality of server devices, each of which stores a database, one of which operates as a master and the other of which operates as a slave that backs up the master, a synchronization status monitoring means for monitoring a synchronization status between the master server device and the slave server device; a control means for changing the server device that refers to the database depending on whether or not a synchronization state between the master server device and the slave server device satisfies a predetermined condition; An information processing device comprising:
2. 2. The information processing apparatus according to claim 1, wherein the control means further comprises master-slave synchronization control means for requesting, when a synchronization delay is detected between the master server device and the slave server device, that a synchronization mode in which updates to the master's database are reflected in the slave's database be changed to an asynchronous mode.
3. 3. The information processing apparatus according to claim 2, wherein said control means, when referring to said database, refers to said database of said master server apparatus instead of said slave server apparatus.
4. An information processing device according to any one of claims 1 to 3, further comprising an incomplete transaction detection means for comparing a timestamp registered in a table managing two-phase commit transactions of the master and slave server devices with the current time, and detecting an incomplete transaction based on whether a certain time has elapsed between the two times.
5. A computer installed in an information processing device connected to a plurality of server devices, each of which stores a database, one of which operates as a master and the other of which operates as a slave that backs up the master, a synchronization status monitoring means for monitoring a synchronization status between the master server device and the slave server device; a control means for changing the server device that refers to the database depending on whether or not a synchronization state between the master server device and the slave server device satisfies a predetermined condition; An information processing program characterized by causing the program to function as follows.
6. 1. An information processing method used in an information processing device connected to a plurality of server devices, each of which stores a database, one of which operates as a master and the other of which operates as a slave that backs up the master, comprising: The information processing device has a synchronization status monitoring means and a control means, the synchronization status monitoring means monitors the synchronization status between the master server device and the slave server device; The control means changes the server device that refers to the database depending on whether or not a synchronization state between the master server device and the slave server device satisfies a predetermined condition.
1. An information processing method comprising: