Search

US-12625857-B1 - Conflict-free write operations in multi-master database

US12625857B1US 12625857 B1US12625857 B1US 12625857B1US-12625857-B1

Abstract

A method for operating a multi-master database includes defining a database cluster having a plurality of databases. Each database is assigned to a corresponding geographic region. Read/write requests originating from a user are assigned to a database with the same corresponding geographic region as the user. The database cluster defines a schema including defined relationships between data records stored in the database cluster such that each data record stored in the database cluster is within a data cluster. Each data cluster includes a single parent data record replicated in each database of the database cluster. Each data cluster defines a single master database of the plurality of databases. The single master database is the database originating the single parent data record.

Inventors

  • Madhu Pavan Kothapally
  • Narinder Kaur
  • Shivi Kashyap
  • Meer Nasser Ali
  • Manoj Kaila

Assignees

  • INTERNATIONAL BUSINESS MACHINES CORPORATION

Dates

Publication Date
20260512
Application Date
20241223

Claims (18)

  1. 1 . A computer-implemented method for operating a multi-master database system comprising: defining a database system having a plurality of databases, with each database being assigned to a corresponding geographic region, wherein read/write requests originating from a user are assigned to a database in the plurality of databases with the same corresponding geographic region as the user; the database system defining having a defined schema, the defined schema including relationships between data records stored in the database system such that each data record stored in the database system is within a data cluster, each data cluster includes a single parent data record and a plurality of child data records, wherein each parent data record is replicated in each database of the database system, and each data cluster defines a single master database of the plurality of databases such that each data cluster in the database system defines a same database of the plurality of databases as the single master database and, wherein the single master database is the database of the plurality of databases originating the single parent data record; replicating a write operation from a database of the plurality of databases to each other database of the plurality of databases by: determining that the database of the plurality of databases in which the write operation is being replicated from is not a parent's master database of the data record being operated by the write operation; replicating the write operation to the parent's master database of the data record being operated by the write operation; and replicating the write operation to each other database in the plurality of databases from the parent's master database of the data record being operated by the write operation.
  2. 2 . The computer-implemented method of claim 1 , wherein the single master database corresponding to each data cluster is the database of the plurality of databases assigned to the geographic region from which a write request creating the data cluster originates.
  3. 3 . The computer-implemented method of claim 1 , wherein a database of the plurality of databases responds to receiving a write request by determining the write request is not creating a parent data record, identifying a parent data record corresponding to the write request, determining a master database of the parent data record, and requesting write approval from the master database of the parent data record.
  4. 4 . The computer-implemented method of claim 3 , further comprising responding to write approval from the master database of the parent data record by writing a child data record in the data cluster of the parent data record.
  5. 5 . The computer-implemented method of claim 4 , further comprising replicating the data cluster including the child data record to each other database of the plurality of databases.
  6. 6 . The computer-implemented method of claim 1 , further comprising responding to a request for write approval from a database of the plurality of databases by comparing a revision number of the data record in the database for which write approval is requested of the data record for which write approval is requested and approving the write request when the revision number of the data record in the database for which write approval is requested is one less than a revision number of the data record in a parent's master database of the data record for which write approval is requested.
  7. 7 . The computer-implemented method of claim 1 , wherein the databases in the plurality of databases includes a lock table and the lock table defines the data record undergoing a write operation and defines whether the data record may be written.
  8. 8 . The computer-implemented method of claim 7 , wherein the lock table is accessible for the databases in the plurality of databases without requiring access to a correspond parent's master database.
  9. 9 . A computer program product comprising: computer executable instructions for causing a computer system to define a database architecture, the database architecture comprising: a database system having a plurality of databases, with each database being assigned to a corresponding geographic region, wherein read/write requests originating from a user are assigned to a database in the plurality of databases with the same corresponding geographic region as the user; the database system defining a schema including defined relationships between data records stored in the database such that each data record stored in the database system is within a data cluster, each data cluster includes a single parent data record, and each data cluster defines a single master database of the plurality of databases, wherein the single master database is the database of the plurality of databases storing the single parent data record; and replicating a write operation from a database of the plurality of databases to each other database of the plurality of databases by: determining that the database of the plurality of databases in which the write operation is being replicated from is not a parent's master database of the data record being operated by the write operation; replicating the write operation to the parent's master database of the data record being operated by the write operation; and replicating the write operation to each other database in the plurality of databases from the parent's master database of the data record being operated by the write operation.
  10. 10 . The computer program product of claim 9 , wherein the single master database corresponding to each data cluster is the database of the plurality of databases assigned to the geographic region from which a write request creating the data cluster originates.
  11. 11 . The computer program product of claim 9 , wherein a database of the plurality of databases responds to receiving a write request by determining the write request is not creating a parent data record, identifying a parent data record corresponding to the write request, determining a master database of the parent data record, and requesting write approval from the master database of the parent data record.
  12. 12 . The computer program product of claim 11 , further comprising responding to write approval from the master database of the parent data record by writing a child data record in the data cluster of the parent data record.
  13. 13 . The computer program product of claim 12 , further comprising replicating the child data record to each other database of the plurality of databases.
  14. 14 . The computer program product of claim 9 , further comprising responding to a request for write approval from a database of the plurality of databases by comparing a revision number of the data record in the database for which write approval is requested of the data record for which write approval is requested and approving the write request when the revision number of the data record in the database for which write approval is requested is one less than a revision number of the data record in a parent's master database of the data record for which write approval is requested.
  15. 15 . The computer program product of claim 9 , wherein the databases in the plurality of databases includes a lock table and the lock table defines the data record undergoing a write operation and defines whether the data record may be written.
  16. 16 . The computer program product of claim 15 , wherein the lock table is accessible for the databases in the plurality of databases without requiring access to a correspond parent's master database.
  17. 17 . A computer system comprising: a database system having a plurality of databases, with each database being assigned to a corresponding geographic region, wherein read/write requests originating from a user are assigned to a database in the plurality of databases with the same corresponding geographic region as the user; the database system defining a schema including defined relationships between data records stored in the database such that each data record stored in the database system is within a data cluster, each data cluster includes a single parent data record, and each data cluster defines a single master database of the plurality of databases, wherein the single master database is the database of the plurality of databases storing the single parent data record; and replicating a write operation from a database of the plurality of databases to each other database of the plurality of databases by: determining that the database of the plurality of databases in which the write operation is being replicated from is not a parent's master database of the data record being operated by the write operation; replicating the write operation to the parent's master database of the data record being operated by the write operation; and replicating the write operation to each other database in the plurality of databases from the parent's master database of the data record being operated by the write operation.
  18. 18 . The computer system of claim 17 , wherein the single master database corresponding to each data cluster is the database of the plurality of databases assigned to the geographic region from which a write request creating the data cluster originates.

Description

BACKGROUND The present invention generally relates to database structures, and more specifically, to database structures and operation schema for allowing conflict-free write operations in multi-master databases. Database structures using multiple redundant databases, such as those utilized for cloud computing, include multiple redundant databases. When two operations simultaneously write different values to the same entries of redundant databases or when one or more of the redundant databases is not updated to reflect a correctly performed write operation, the entries in corresponding databases will be different. This is referred to as a conflict, and database conflicts can cause cascading errors within a database structure. SUMMARY Embodiments of the present invention are directed to a computer-implemented method for providing a database schema. A non-limiting example of the computer-implemented method includes a method for operating a multi-master database includes defining a database cluster having a plurality of databases. Each database is assigned to a corresponding geographic region. Read/write requests originating from a user are assigned to a database with the same corresponding geographic region as the user. The database cluster defines a schema including defined relationships between data records stored in the database cluster such that each data record stored in the database cluster is within a data cluster. Each data cluster includes a single parent data record replicated in each database of the database cluster. Each data cluster defines a single master database of the plurality of databases. The single master database is the database originating the single parent data record. Embodiments of the present invention are further directed to a computer system and a computer program product for implementing and distributing the computer-implemented method. Additional technical features and benefits are realized through the techniques of the present invention. Embodiments and aspects of the invention are described in detail herein and are considered a part of the claimed subject matter. For a better understanding, refer to the detailed description and to the drawings. BRIEF DESCRIPTION OF THE DRAWINGS The specifics of the exclusive rights described herein are particularly pointed out and distinctly claimed in the claims at the conclusion of the specification. The foregoing and other features and advantages of the embodiments of the invention are apparent from the following detailed description taken in conjunction with the accompanying drawings in which: FIG. 1 depicts a cloud computing environment according to an embodiment of the present invention; FIG. 2 illustrates a computing environment for executing computer code involved in performing conflict-free write operations, detailing components such as computers, networks, and storage. FIG. 3 illustrates a distributed database system with databases configured in separate geographic regions, each containing multiple access groups and clusters for conflict-free operations. FIG. 4 illustrates an example usage flow of the system, showing how user requests are routed to databases based on geographic regions and how master databases are determined. FIG. 5 illustrates a process for performing a write operation, detailing steps for determining the master database and handling parent and child records. FIG. 6 illustrates a process for handling write requests, including authorization checks and lock table management to ensure conflict-free operations. FIG. 7 illustrates a replication strategy for databases, showing how data is replicated across databases to maintain consistency and availability. FIG. 8 illustrates a failover process for selecting a proxy master database when a database becomes unreachable, ensuring continued operation and data integrity. The diagrams depicted herein are illustrative. There can be many variations to the diagram or the operations described therein without departing from the spirit of the invention. For instance, the actions can be performed in a differing order or actions can be added, deleted or modified. Also, the term “coupled” and variations thereof describes having a communications path between two elements and does not imply a direct connection between the elements with no intervening elements/connections between them. All of these variations are considered a part of the specification. In the accompanying figures and following detailed description of the disclosed embodiments, the various elements illustrated in the figures are provided with two or three digit reference numbers. With minor exceptions, the leftmost digit(s) of each reference number correspond to the figure in which its element is first illustrated. DETAILED DESCRIPTION Various embodiments of the invention are described herein with reference to the related drawings. Alternative embodiments of the invention can be devised without departing from the scope of t