Caching technology for database change streams

By introducing a cache module and a location indicator mechanism into the database system, the problem of performance degradation of traditional database systems when processing change streams is solved, and efficient, multi-tenant support and fast recovery of change stream processing are achieved.

CN113906407BActive Publication Date: 2025-09-26SALESFORCE INC
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202080039987.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Priority Date
2019-05-31
Filing Date
2020-05-07
Publication Date
2025-09-26
Estimated Expiration
2040-05-07

AI Technical Summary

Technical Problem

When traditional database systems process change streams, their performance degrades as the number of accesses increases, making it difficult to meet the requirements of high efficiency and high concurrency.

Method used

By introducing a cache module, caching change stream records, and using position indicators for cache operations, direct access to the database is reduced, and multi-tenant support and checkpoint recovery are achieved.

Benefits of technology

It improves the performance of change stream processing, reduces the number of database accesses, supports efficient concurrent processing in multi-tenant scenarios, and ensures rapid recovery of the system in the event of a crash.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113906407B_ABST
    Figure CN113906407B_ABST
Patent Text Reader

Abstract

A technique related to caching for processing a database change stream is disclosed. A cache module of a computer system may receive change records from a change stream comprising a plurality of records indicating changes to a database table. The change stream may comprise change records for a plurality of shards, and the change stream may be accessed by providing one or more position indicators for one or more of the plurality of shards to request the one or more change records and an updated position indicator. One or more cache entries may be stored for changes to a group of one or more shards for which the cache module is configured, each cache entry comprising a group of change records up to a threshold group size. A change processor module of the computer system may request a portion of the change stream by providing the received position indicator. The change processor module may receive from the cache module one or more cached change records from cache entries that match the provided position indicator.
Need to check novelty before this filing date? Find Prior Art

Description

Background Art Technical Field

[0002] The disclosure relates generally to database systems and, more particularly, to processing change streams of database tables.

[0003] Related technical description

[0004] Some database systems generate a stream of change records indicating changes to database tables. This change stream can be processed by multiple different applications, and there may be timing constraints on processing the change records. As the number of accesses to the change stream increases, performance can degrade in traditional implementations. BRIEF DESCRIPTION OF THE DRAWINGS

[0005] Figure 1 is a block diagram illustrating an example database change streamprocess system including caching according to some embodiments.

[0006] Figure 2 is a block diagram illustrating example processing layers of a stream process that handles a change stream according to some embodiments.

[0007] Figure 3 is a block diagram illustrating example interactions between a network process and a stream process according to some embodiments.

[0008] Figure 4 is a block diagram illustrating an example cache implementation according to some embodiments.

[0009] Figure 5 is a block diagram illustrating example additions to a cache entry when retrieving a change record according to some embodiments.

[0010] Figure 6 is a flow diagram illustrating an example method for using caching for a change stream, according to some embodiments.

[0011] Figure 7 is a block diagram illustrating techniques for generating a combined change stream checkpoint based on checkpoints from multiple tenants, according to some embodiments.

[0012] Figure 8 is a flow chart illustrating a method for processing a stream of changes to a database table using a cache, according to some embodiments.

[0013] Figure 9 is a block diagram illustrating an example computing device according to some embodiments.

[0014] The disclosure includes references to "one embodiment" or "an embodiment." The appearance of the phrase "in one embodiment" or "in an embodiment" is not necessarily referring to the same embodiment. The particular features, structures, or characteristics may be combined in any suitable manner consistent with the disclosure.

[0015] In the disclosure, different entities (which may be variously referred to as "units," "circuits," other components, etc.) may be described or claimed as being "configured" to perform one or more tasks or operations. This expression—an "entity" configured to "perform one or more tasks"—is used herein to refer to a structure (i.e., a physical thing, such as an electronic circuit). More specifically, the formulaic expression is used to indicate that the structure is arranged to perform one or more tasks during operation. A structure can be said to be "configured to" perform certain tasks even if the structure is not currently being operated. "A cache module configured to cache change stream records" is intended to cover, for example, a computer system having, for example, a processor, a network interface, a memory with program instructions, etc., to perform that function during operation, even if the computer system is not currently being used (e.g., it is not connected to a power source). Thus, an entity described or recited as "configured to" perform certain tasks refers to a physical thing, such as a device, circuit, memory, etc., that stores program instructions executable to implement the task. The phrase is not used herein to refer to something intangible.

[0016] The term "configured to" does not mean "can be configured to." For example, an unprogrammed FPGA is not considered "configured to" perform some specific function, although it may be "configurable to" perform that function and may be "configured to" perform that function after being programmed.

[0017] Reciting a structure as “configured to” perform one or more tasks in the appended claims expressly does not intend to invoke 35 U.S.C. §112(f) for that claim element. Therefore, no claim in this application, as filed, should be construed as having means-plus-function elements. If applicant wishes to invoke §112(f) during invocation, it will do so using a “means-plus” [performing a function] structure to recite the claim element.

[0018] As used herein, the terms "first," "second," etc., are used as labels for the nouns that precede them and do not imply any type of order (e.g., spatial, temporal, logical, etc.) unless otherwise specified. For example, in a computing system with multiple user accounts, the terms "first" user account and "second" user account can be used to refer to any user. In other words, for example, the "first" user account and the "second" user account are not limited to the two user accounts that were initially created. When used herein, the term "or" is used as an inclusive or rather than an exclusive "or." For example, the phrase "at least one of x, y, or z" refers to any one of x, y, and z and any combination thereof (e.g., x and y, but not z or x, y, and z).

[0019] As used herein, the term "based on" is used to describe one or more factors that influence a determination. This term does not exclude the possibility that other factors may influence the decision. That is, a determination may be based solely on the specified factors, or on the specified factors as well as other unspecified factors. Consider the phrase "A is determined based on B." This phrase specifies that B is a factor used to determine A or that influences the determination of A. This phrase does not exclude that the determination of A may also be based on some other factor, such as C. This phrase is also intended to cover embodiments in which A is determined based solely on B. As used herein, the phrase "based on" is therefore synonymous with the phrase "based at least in part on." DETAILED DESCRIPTION

[0020] In various high-volume database applications, multiple processes may have access to the same database table. In some embodiments, a change stream reflects a sequence of changes to a database table and may be accessed by one or more change processor modules to perform various tasks based on updates to the database table. As an example, a system may implement a network cluster and a stream cluster (e.g., each may include one or more Java processes) that access a database system. The network process may handle external change requests from a user, while the stream process may handle internal updates. An example of an external change request is a user placing an item in their online shopping cart, while an example of an internal change is updating inventory details based on the item placed in the user's shopping cart.

[0021] In a large number of applications, performance and cost may be important design considerations. In some embodiments, a change stream cache is implemented to cache change records associated with a particular process from a change stream. For example, the change stream can be sharded, and processes can be assigned to process only some of the shards included in the change stream. This can advantageously improve the performance of accessing change records and reduce the number of accesses to the change stream. The cache can group change stream records into threshold cache entry sizes (which may be referred to as segment sizes) and perform cache operations at entry granularity. For example, for a group of change records, data can be cached, evicted, hit / missed, etc. on a per-input basis.

[0022] Different stream processes can implement different change stream caches, and one or more change processor modules within a given stream process can share the process's cache. A change processor module can provide location indicators to access the change stream, and these location indicators can be used to detect cache hits and misses. A network process can forward the location indicators to a stream process, which can use them to retrieve change stream records. In some embodiments, although the underlying database system may be unaware of the multi-tenant implementation, one or more processing layers implement multi-tenancy such that database tables store entries for multiple tenants.

[0023] Streaming processes can perform checkpointing for change streams, where checkpoints can provide a recovery point in the event of a system crash. A checkpoint is a position indicator that specifies where in the change stream to begin processing records after a system crash. Checkpointing can be performed by one or more processing layers that implement multi-tenancy on a per-tenant basis, and based on individual tenant checkpoints, the system can generate a global checkpoint for the change stream.

[0024] Overview of the Change Handling System

[0025] Figure 1 is a block diagram illustrating an example database change stream processing system including a cache according to some embodiments. In the illustrated embodiment, a computer system 110 includes a change processor module 112 and a cache module 120 configured to process a change stream 134 of a database table 132 .

[0026] In the illustrated embodiment, database table 132 provides change information to change stream 134. In some embodiments, the change information includes one or more change records indicating changes made to database table 132. In some embodiments, computer system 110 uses database table 132 to store data for multiple different tenants, although the database system may not be aware of multi-tenancy. In some embodiments, database table 132 may be included in a NoSQL database system (e.g., In some embodiments, the computer system 110 is configured to independently scale the shards of the NoSQL database. In some embodiments, the scaling is based on the number of tenants or the amount of data per tenant, for example.

[0027] In the illustrated embodiment, change stream 134 stores change stream records accessible to computer system 110. In some embodiments, multiple different change streams provide change records to computer system 110. For example, multiple database tables may generate change information for multiple different change streams, and the computer system may process multiple different change streams. In some embodiments, a change stream includes information specifying the sequence of changes made to a database table. In some embodiments, each change record has a corresponding sequence number, which may be unique within the change stream. In some embodiments, a change record indicates the state of the data before and after a given change. Change streams may be provided by various database services, which may also provide a polling mechanism to retrieve changes from the change stream as they are generated. In some embodiments, the change stream is sharded, with different processes processing different sets of change stream shards (the different sets may or may not overlap). In some embodiments, change stream shards are scaled based on changes made for one or more tenants or the type of changes to be processed for a given change stream record. For example, a network process may receive a high load of external requests from a given tenant and may increase the size of the tenant's change stream shards or split the change stream shards into multiple shards based on the requests.

[0028] In the illustrated embodiment, the cache module 120 sends a position indicator to the change stream 134 to request a change record corresponding to the position indicator. In some embodiments, a polling module included in the computer system 110 iteratively retrieves records from the change stream 134 using the position indicator and passes the records to the cache module 120. In the illustrated embodiment, the cache module 120 receives the change stream records and stores the change records in the change stream cache 122. Note that, for example, when polling the change stream, access to the change stream 134 may also generate an updated position indicator (which may indicate the current latest record in the change stream). In some embodiments, the change stream cache 122 stores changes to groups of one or more fragments in cache entries (each of which includes groups of change records up to a threshold group size). Referring below to Figure 4 and Figure 5 Discuss these groups in detail.

[0029] As used herein, the term "position indicator" refers to information that specifies a location within a change stream. In some embodiments, the position indicator is a sequence number that identifies a location within a shard of the change stream, wherein the sequence number is unique within each shard in the change stream. In some embodiments, the position indicator includes a shard identifier (ID) and a sequence number of a record within the shard. Note that the combination of the shard identifier and the sequence number can uniquely identify the location of a record in the change stream. In some embodiments, the position indicator is a delta link that includes one or more shard IDs with the sequence number of the change stream included in the delta token of the delta link. The following is an example of a delta link for starting a query of a change stream, where the example query is an HTTP GET request:

[0030] http: / / ...delta? startOffset=ShardB+ShardC+ShardD

[0031] This example query requests the sequence numbers for shards B, C, and D. The following is a non-limiting example of a second query that uses delta linking to get changes to the change stream after a specified sequence number (e.g., sequence number 2 for shard B):

[0032] http: / / ...&$deltaToken=ShardB:2+ShardC:15+ShardD:8

[0033] The example query includes sequence number "2" for shard B, sequence number "15" for shard C, and sequence number "8" for shard D, where the sequence number indicates the position in each shard to start retrieving change records. For example, records before the position in each shard specified by the sequence number may have already been processed. In some embodiments, the position indicator specifies processing records: after the sequence number, at the sequence number, at a given timestamp, most recently added to the change stream, etc., and therefore, can be encoded using a variety of different formats. The position indicator can advantageously reduce or remove the need to maintain or persist the state of the change stream.

[0034] In the illustrated embodiment, the change processor module 112 receives the position indicator and sends the indicator to the cache module 120 requesting the change record. The cache module 120 returns the change record to the change processor module 112 from the cache entry of the change stream cache 122 that matches the provided position indicator (or accesses the change stream 134 if there is a cache miss). Figure 4Implementation details for the change stream cache 122 are discussed in detail. In some embodiments, implementing a change stream cache can advantageously support fan-out across multiple tenants. For example, multiple tenants may request the same or similar change stream records in parallel. In this case, caching can reduce the number of requests or eliminate the need to access the change stream. In addition, caching can provide improved performance (e.g., reducing the time between requesting a change stream record and receiving the requested record).

[0035] In some embodiments, computer system 110 implements multiple internal layers for handling the flow of changes to a database table (e.g., database table 132) that stores data for multiple different tenants. For example, computer system 110 may include one or more multi-tenant adapters that convert tenant-specific database operations (e.g., change operations) into a tenant-agnostic form. For example, tenant-independent database operations may be compatible with a database that is used to store information for multiple tenants but does not support multi-tenancy.

[0036] As used herein, the term "multi-tenant database system" refers to those systems in which the various hardware and software elements of the database system are shared by one or more clients. For example, a computer system can process requests from a large number of clients simultaneously, and a database table can store rows for a potentially large number of clients. In various embodiments, data for different tenants can be securely stored so that other tenants cannot access the data without permission.

[0037] Stream Process Overview

[0038] Figure 2 2 is a block diagram illustrating example processing layers of a stream process that processes a change stream according to some embodiments. In some embodiments, the stream process 210 processes internal updates to database tables within the database module 230. In some embodiments, the stream process 210 receives a location indicator from the network process 250 indicating a specific change to be retrieved (e.g., as requested by a client via the network process 250). In some embodiments, using the stream process 210 to process these requests can advantageously enable the use of the change stream cache 122, as discussed in further detail below.

[0039] In the illustrated embodiment, the streaming process 210 includes: a multi-tenant adapter / router 212, a change handler module 214, a multi-tenant adapter 216, a database translation module 218, a cache module 120, and a polling module 240. The streaming process 210 is operable by Figure 1 One example of a process implemented by computer system 110 is shown.

[0040] In the illustrated embodiment, the polling module 240 and the cache module 120 can retrieve and cache change stream records from the database module 230 so that accesses to the change stream by the change processor module 214 hit the cached data, which can reduce accesses to the database module 230. The remaining layers can transform requests, for example, to support multi-tenancy and underlying database implementations.

[0041] In the illustrated embodiment, the polling module 240 sends the domain name server (DNS) address for the stream process 210 and the combined checkpoint for the change stream to the database translation module 218. When the change stream record is successfully processed, the stream process 210 can update the combined checkpoint and store it in the lease table (see below). Figure 3 (discussed in detail). In some embodiments, when the server system hosting the streaming process 210 recovers from a crash, the polling module 240 (via the database translation module 218) retrieves the combined checkpoint from the database module 230. For example, based on the sequence number indicated by the retrieved checkpoint, the polling module 240 can begin processing the change stream record after the position indicated by the sequence number. The DNS address can be accessed and used by other processes, for example, to forward the position indicator to the streaming process 210.

[0042] In some embodiments, the polling module 240 polls change stream records (e.g., from the change stream 134) using delta links, where the delta links are position indicators with sequence numbers for one or more change stream fragments. In some embodiments, the polling module 240 sends an initial query to the change stream requesting the sequence numbers for one or more fragments. For each successive query, an updated position indicator is returned, with a new sequence number for each change stream fragment with a new record. In some embodiments, as discussed in further detail below, all or a portion of the change stream records retrieved by the polling module 240 are stored in the change stream cache 122.

[0043] In some embodiments, the stream process 210 instantiates change processor modules 214 and assigns one or more change stream fragments to each change processor module. Note that the stream process 210 can assign change stream fragments to previously instantiated change processor modules 214. In some embodiments, at least one change processor module 214 is instantiated for each change stream fragment to be processed by the stream process 210.

[0044] As used herein, the term "process" is intended to be interpreted according to its understood meaning, which includes program code and the execution state of an instance of a computer program. In some embodiments, a process is such as Application containers for containers. In some embodiments, the size and number of containers used for stream processes can be adjusted based on processing requirements. As described above, different types of processes (e.g., network or stream) can be used to handle different types of changes in the database system. Non-limiting examples of processes include: container, and Java processes.

[0045] In the illustrated embodiment, the multi-tenant adapter / router 212 receives a tenant-agnostic form of a single tenant checkpoint received from the change processor module 214 and generates a combined checkpoint based on the single checkpoint, as described below with reference to Figure 7 As discussed in detail herein. As used herein, the term "checkpoint" is intended to be interpreted according to its well-understood meaning that includes a recovery point. Thus, a checkpoint may imply that previous activity has been successfully processed such that reprocessing is not required after a system failure or other error condition. Thus, a checkpoint can provide state information for a change stream, allowing the system to return to that state if a failure is encountered. In some embodiments, an overall or cumulative checkpoint is generated for a change stream based on a single tenant checkpoint. The change processor module 214 can generate one or more individual tenant checkpoints for one or more allocated shards.

[0046] In some embodiments, the cache module 120 receives a change stream request including a position indicator (e.g., a delta link) from the multi-tenant adapter 216 (where the change stream request may come from the change processor module 214 or the polling module 240). In response to receiving the change stream request, the cache module 120 determines whether the corresponding change stream record is cached in the change stream cache 122, and if so, provides the record from the cache 122. If the record is not cached, the cache module 120 may forward the change stream request to the database translation module 218 to retrieve the record from the change stream (and may cache the record after it is returned).

[0047] In the illustrated embodiment, database translation module 218 converts database requests (e.g., database operations or change stream requests) into a format recognized by database module 230. In some embodiments, database translation module 218 is implemented as an application programming interface (API) associated with database module 230. In some embodiments, database translation module 218 is associated with a software development kit (SDK) configured to communicate with database module 230.

[0048] In the illustrated embodiment, the change processor module 214 is configured to send requests associated with database tables and requests for change streams to the database module 230. For database table operations, the change processor module 214 sends requests for one or more per-tenant operations to the database module 230 via the multi-tenant adapter 216 and the database translation module 218. For change stream requests, the change processor module 214 sends requests to the multi-tenant adapter 216 and retrieves change records from the change stream cache 122 or the database module 230.

[0049] In the illustrated embodiment, the change processor module 214 receives one or more location indicators from the network process 250. In some embodiments, the network process 250 sends a location indicator based on the DNS address of the streaming process 210 (e.g., by retrieving the DNS address stored in the database module 230 via the polling module 240). In the illustrated embodiment, the change processor module 214 sends a request for one or more per-tenant operations to the database module 230 via the multi-tenant adapter 216 and the database translation module 218. The streaming process 210 may return the retrieved change records to the network process 250. In some embodiments, the change processor module 214 sends per-tenant operations to the database table based on the one or more retrieved change records. For example, the change processor module 214 may access the database to update the shopping cart information of a user of a particular tenant based on receiving a change record indicating that the user has requested to add an item to the shopping cart.

[0050] In the illustrated embodiment, the multi-tenant adapter 216 converts each tenant operation into a database operation (e.g., tenant-agnostic CRUD operations) supported by the database module 230. The multi-tenant adapter 216 also forwards requests from the polling module 240 to the cache module 120 (note that the adapter 216 may not actually perform any operations on these requests). In some embodiments, the multi-tenant adapter 216 is configured to convert tenant-based addressing information into a location in the database table 132.

[0051] In the illustrated embodiment, the database translation module 218 processes data from various other modules and adapters within the stream process 210 and delivers this information in a form supported by the database module 230. Specifically, in the illustrated embodiment, the database translation module 218 sends database operations and change stream requests to the database module 230 and receives change stream responses. In the illustrated embodiment, the database translation module 218 also sends DNS and combined checkpoints (e.g., storing this information in a lease table).

[0052] In some embodiments, database module 230 performs operations using database tables based on CRUD operations and stores DNS addresses and checkpoints in the lease table based on information received from database translation module 218. In the illustrated embodiment, database module 230 also sends change stream records retrieved from the change stream based on the provided delta link to module 218, for example.

[0053] Example Change Handling System

[0054] Figure 3 is a block diagram illustrating example interactions between network processes and stream processes according to some embodiments. In the illustrated embodiment, one or more network processes 250 process external requests to perform one or more database operations, and one or more stream processes 210 process one or more database operations. In the illustrated embodiment, database module 230 includes database table 132, change stream 134, and lease table 336.

[0055] In some embodiments, network process 250 receives one or more external requests from one or more computing devices (e.g., via a network such as the Internet). In some embodiments, the external requests result in changes to database table 132. For example, a user may add an item to their online shopping cart, and the server hosting the user's device may send a Hypertext Transfer Protocol (HTTP) POST request to network process 250. In the illustrated embodiment, servlet 352 receives the external request, translates the request, and sends the translated request to change processor module 354. For example, the servlet may be a Java servlet that converts HTTP requests into Java data. In the illustrated embodiment, change processor module 354 generates one or more per-tenant operations for database table 132 and sends these operations to multi-tenant adapter 356, which converts them into database operations supported by database module 230. In some embodiments, a given network process includes one or more change processors. For example, the number of change processors may be determined based on the number of external requests. Multi-tenant adapter 356 sends the database operations to database translation module 358, which generates one or more CRUD operations for database table 132. For example, the database translation module 358 may be associated with a software development kit (SDK) configured to communicate with the database module 230 .

[0056] In the illustrated embodiment, the database module 230 receives CRUD operations forwarded from a database translation module 358 included in a network process 250 and implements one or more changes to the database table 132. In the illustrated embodiment, the changes to the database table 132 are indicated by a change stream 134. In some embodiments, the change stream 134 is sharded, where each shard includes one or more change records. In some embodiments, the external request includes a delta link, which the network process 250 forwards to the stream process 210, which retrieves the corresponding change record from the cache 122 if available, and responds to the network process 250 with the requested change record (which in turn can provide the record to the requesting client).

[0057] In the illustrated embodiment, the lease table 336 stores one or more DNS addresses of one or more stream processes 210 and a mapping of the DNS addresses to groups of one or more change stream shards. The network process 250 retrieves the DNS address from the lease table 336 to determine the stream process to which to forward the location indicator (e.g., which stream process is responsible for processing which change stream shard). The network process 250 then uses the DNS address to forward the location indicator for a particular change to the appropriate stream process 210. In some embodiments, the lease table 336 stores state information for one or more shards of a change stream. For example, each row of the lease table can represent a shard being processed by a given stream process, where the row includes a shard identifier, a checkpoint, and a lease ID. The lease information can be used by polling modules of different stream processes, for example, to perform load balancing between processes. The checkpoint for each shard can be a sequence number that identifies the most recently processed record for that shard.

[0058] In the illustrated embodiment, the stream process 210 receives the forwarded position indicator from the network process 250 and provides the position indicator to one or more change processor modules 214 associated with the one or more fragments specified by the position indicator. For example, the position indicator can be a delta link including the sequence number of one or more change stream fragments, where the change processor module 214 was previously assigned to process these fragments. Note that the internal layers of the stream process 210 (e.g., 212, 214, 218, 120, and 240) can perform operations similar to those described above with reference to FIG. Figure 2 In some embodiments, the forwarded location indicator can facilitate the use of cache 122, for example, if polling module 240 has already retrieved the corresponding change record, causing the record to be cached. In some embodiments, stream process 210 returns the requested change record to network process 250, which then sends the record to the computing device that sent the external change request. In various embodiments, using stream process 210 to handle change stream requests to network process 250 can advantageously allow the use of cache 122.

[0059] In the illustrated embodiment, the database translation module 218 sends CRUD operations on the database table 132 to the database module 230. In some embodiments, the CRUD operations are sent based on one or more internal updates (e.g., inventory count updates) to the database table 132. The database translation module 218 sends the checkpoint and DNS address from the stream process 210 to the database module 230 (which stores this information in the lease table 336). In some embodiments, for example, the module 218 retrieves the most recent checkpoint after recovering from a system crash.

[0060] As an example, Figure 3 The system shown in FIGURE 2 can process a request from a user of a given tenant to add an item to their online shopping cart. In this example, network process 250 receives the request from the user and generates CRUD operations for database table 132 to add the shopping cart information to the user's database table. Furthermore, in this example, the shopping cart information added to database table 132 can be reflected in change stream 134. Database module 230 can send the DNS address from lease table 336 to the given stream process 210 and a location indicator from change stream 134 to network process 250, where the location indicator specifies a sequence number in shard A of the change stream that reflects the change record for the shopping cart information added to database table 132. In this example, network process 250 forwards the location indicator to the given stream process 210 based on the DNS address from lease table 336.

[0061] Continuing with this example, the change processor module 214 of the stream process 210 configured to process shard A sends a request for a change record of shard A to the cache module 120 using the forwarded location indicator, and receives a change record of shard A from a cache entry that matches the location indicator. Finally, in this example, based on the received change record, the change processor module 214 sends a command to the database module 230, wherein the command includes instructions for updating an inventory count and generating a new user interface configured to display a user's online shopping cart based on the user placing an item in the user's online shopping cart.

[0062] Cache implementation example

[0063] Figure 4 is a block diagram illustrating an example cache implementation according to some embodiments. In the illustrated embodiment, the cache includes tags 410 for different entry data 420.

[0064] In the illustrated embodiment, each cache entry includes a tag 410 that specifies a shard identifier and a corresponding sequence number for the change record stored in the entry. In the illustrated embodiment, the tag 410 for the first entry includes sequence numbers 5-7 for shard B. Similarly, the tag 410 for the second cache entry specifies that the second cache entry includes change records corresponding to sequence numbers 120-150 for shard D. In the illustrated embodiment, the final cache entry has a tag 410 that specifies that records corresponding to sequence numbers 1-6 for shard A are stored in the cache entry. In some embodiments, the cache can store records from multiple streams, and therefore, the tag 410 of each cache entry includes a stream identifier in addition to the shard identifier and sequence number.

[0065] In some embodiments, the change processing module 214 provides a location indicator, and the cache module 120 detects a cache hit or a cache miss and, if there is a cache hit, provides a change record that matches the location indicator. If there is a cache miss, the cache module 120 can retrieve the record from the change stream 134. In some embodiments, as described below with reference to Figure 5 As discussed in detail, cache module 120 adds the retrieved change records to the cache entry until the threshold entry size is met. Consider the example of a position indicator that specifies shard B and sequence number 6. In this example, the position indicator generates a cache hit for the first cache entry, and the cache returns one or more change records after sequence number 6 (in some embodiments, the cache returns all sequence numbers in the entry after the provided position indicator).

[0066] In some embodiments, the cache performs cache operations at the group level (e.g., segment level) and continues to add change records to the grouped change records in the entry until the entry is full. Thus, the cache module 120 can detect hits and misses and perform evictions for entries that are full or partially full of change records. The cache 122 can be implemented using any of a variety of caching technologies and can perform evictions using various control techniques (e.g., such as, for example, least recently used (LRU) or first in, first out (FIFO)). In some embodiments, the cache 122 is a software cache.

[0067] Figure 5 is a block diagram illustrating example additions to a cache entry when retrieving a change record according to some embodiments. In the illustrated embodiment, the contents of a cache entry 550 are shown at points A-C 542-546, where different change stream records 512-538 with different sequence numbers are added to the cache entry 550 at different points.

[0068] At point A 542, in the example shown, the process retrieves the change record 512 with sequence number 4 from the change stream (e.g., change stream 134) and adds it to the newly allocated cache entry 550. In some embodiments, the change record is retrieved from the change stream based on a request with a delta link from the polling module 240 or the change processor module 214. Note that after this retrieval, the database system can provide the requester with an updated delta link that specifies sequence number 4 and the shard identifier of the cache entry 550. In some embodiments, the change record 512 is added to the new cache entry because the cache entry for the previously aggregated record is full.

[0069] At point B 544, in the example shown, the process retrieves records 524 and 526 with sequence numbers 5 and 8 from the change stream and adds them to cache entry 550 (which already contains record 522). Note that after retrieving record 512, for example, when retrieving by polling the change stream, records 524 and 526 may have already been added to the change stream. In some embodiments, the database system returns an updated delta link with sequence number 8 and a fragment identifier. At point C 546, in the example shown, the cache retrieves change record 538 with sequence number 10 from the change stream and adds it to cache entry 550, which already contains records 532-536. In some embodiments, the database system then sends an updated delta link with sequence number 10 and a fragment identifier. This process can continue until a threshold entry size is reached. For example, the threshold entry size can be 50, 200, 1000, or 5000 records, or any other appropriate size. In some embodiments, once a threshold entry size is reached, cache module 120 allocates new entries for caching records retrieved from the change stream.

[0070] Figure 6 is a flow diagram illustrating an example method for using caching for a change stream, according to some embodiments. Figure 6 The method shown in can be used in conjunction with any one of the computer circuits, systems, devices, elements and assemblies disclosed herein and other devices. In various embodiments, some of the method elements shown can be performed simultaneously in a different order than shown, or can be omitted. Additional method elements can also be performed as needed.

[0071] At 610, in the illustrated embodiment, the cache receives a request for a change record from a change processor module, wherein the request includes a location indicator. In some embodiments, the cache receives multiple requests in parallel from different change processor modules. In some embodiments, two different change processor modules submit requests where the location indicators of the requests are similar (indicating similar locations in the cache). In some embodiments, to benefit from cache locality, the cache may align change processor modules with entry boundaries to allow different modules to retrieve records from the cache in lock step over time.

[0072] At 620, the cache determines whether the provided location indicator results in a cache hit. For example, the cache may attempt to locate an entry corresponding to the fragment ID and sequence number contained in the location indicator. In some embodiments, as described above with reference to Figure 4 As discussed in detail, an entry includes a tag having a fragment ID and one or more sequence numbers for the fragment ID. If there is a cache hit at element 620, the flow proceeds to element 640. If there is a cache miss, the flow continues to element 630.

[0073] At 630, the cache module returns the record from the change stream. The cache module can cache the returned record in an available cache entry for future requests. The cache module can also forward an updated location indicator based on the returned change record.

[0074] At 640, the cache module returns a cached change record, based on the sequence number of the location indicator, and an updated location indicator based on the returned change record to the change processor module based on the cache hit. The cache module can generate an updated location indicator in the event of a cache hit, rather than receiving an updated location indicator from the database system in the event of a cache miss. As an example, the updated location indicator can include one or more shard IDs that are the same as the original location indicator, but with a different sequence number for one or more shards. In this example, the sequence number can be the sequence number of the last record in each shard returned to the change processor module.

[0075] Figure 7 is a block diagram illustrating a technique for generating a combined change stream checkpoint based on checkpoints of multiple tenants according to some embodiments. In the illustrated example, the stream process 210 creates a combined checkpoint 736 for the change stream 710 based on the individual tenant checkpoints 726 and 728 .

[0076] In the illustrated embodiment, change stream 710 includes change records for multiple different tenants. In some embodiments, the numbers associated with the change records are sequence numbers (sequence numbers 1-6). In the illustrated embodiment, change stream 710 includes a combined checkpoint 736 generated based on single tenant checkpoints 726 and 728.

[0077] Figure 7 The right portion of shows information 720 representing the change stream 710 grouped according to tenants. In some embodiments, the change processor module 214 is tenant-aware and groups records from the change stream by tenant. The information 720 includes three different groups of records for tenants A, B, and C. In the illustrated embodiment, checkpoints 726 and 728 are shown for tenants A and B, respectively. Note that within each group of records for a given tenant, the change processor module 214 may maintain the original order of the records. In some embodiments, one or more change processor modules 214 generate checkpoints for each tenant. Note that the group of records for tenant C does not include a checkpoint. For example, the record with sequence number 5 for tenant C may not have been processed yet.

[0078] In the illustrated embodiment, combined checkpoint 736 is shown after the change record with sequence number 3 in change stream 710. In some embodiments, the combined checkpoint represents a point at which all records prior to that point have been successfully processed. Although some sequence numbers after combined checkpoint 736 may have been successfully processed (e.g., record with sequence number 6 for tenant A), combined checkpoint 736 does not advance because other tenants have not yet successfully processed earlier sequence numbers (e.g., tenant B has not yet processed record with sequence number 4, and tenant C has not yet processed record with sequence number 5).

[0079] In some embodiments, the stream process 210 tracks the range of sequence numbers observed for each tenant and a single checkpoint for each tenant (although note that in some cases a tenant's range or checkpoint may be empty). Figure 7 In the example shown in FIG, the stream process 210 may store the sequence number range [2, 6] for tenant A and indicate a checkpoint at sequence number 6. Similarly, the stream process 210 may store the range [1, 4] and a checkpoint at sequence number 1 for tenant B, and the range [5] and an empty checkpoint for tenant C.

[0080] In some embodiments, the stream process 210 determines a first threshold sequence number for a shared checkpoint based on a lower bound of a range where no checkpoints exist. Figure 7 In the example, the first threshold sequence number for the combined checkpoint is sequence number 4 because the lower limit for tenant C (which has no checkpoints) is 5.

[0081] In some embodiments, the stream process 210 also determines a second threshold sequence number based on an existing tenant checkpoint. Figure 7 In the example of , the second threshold sequence number of the combined checkpoint is sequence number 3 because it is the sequence number that is just before the lowest tenant checkpoint (Tenant B's checkpoint is before sequence number 4). In some embodiments, the streaming process 210 selects the smaller of the first threshold and the second threshold as the shared checkpoint, for example, Figure 7 In the example, the sequence number is 3.

[0082] In some embodiments, the stream process 210 may also support a tenant-independent checkpoint mode. Figure 7 The discussed techniques allow accurate checkpointing in multi-tenant scenarios, even when the underlying database is not aware of multi-tenancy.

[0083] Example Method

[0084] Figure 8 is a flow chart illustrating a method for processing a stream of changes to a database table using a cache, according to some embodiments. Figure 8 The method shown in can be used in conjunction with any one of the computer circuits, systems, devices, elements or assemblies disclosed herein and other devices. In various embodiments, some of the method elements shown can be performed simultaneously in a different order than shown, or can be omitted. Additional method elements can also be performed as needed.

[0085] At 810, in the illustrated embodiment, a cache module of a computer system receives change records from a change stream, wherein the change stream includes a plurality of records for a plurality of shards indicating changes to a database table, and the change stream is accessible by providing one or more location indicators for one or more of the plurality of shards to request the one or more change records and updated location indicators.

[0086] In some embodiments, the multi-tenant adapter receives tenant-based requests from the change processor module and converts the tenant-based requests into requests supported by a database system that maintains a database table, wherein the multi-tenant adapter module uses the database table to store fields for multiple different tenants. In some embodiments, the computer system determines multiple tenant checkpoints based on processing change records for the multiple tenants. In some embodiments, the computer system determines a combined checkpoint based on the multiple tenant checkpoints and stores the combined checkpoint.

[0087] At 820 , one or more cache entries are stored by the cache module for changes to the group of one or more shards for which the cache module is configured, each cache entry including a record of changes to the group of up to a threshold group size.

[0088] At 830 , the change processor module of the computer system requests a portion of the change stream, including providing the received location indicator.

[0089] In some embodiments, the cache module and the change handler module are included in a stream process, and the method further comprises accessing the change stream using a plurality of different stream processes executed by the computer system.

[0090] At 840, the change handler module receives, from the cache module, one or more change records from the cache for the cache entry that matches the provided location indicator. In some embodiments, the match between the cache entry and the provided location indicator is based on a shard identifier and a sequence number included in the location indicator, wherein the cache entry includes a tag value having one or more shard identifiers and one or more sequence numbers corresponding to the one or more shard identifiers.

[0091] In some embodiments, a computer system stores an address of a change handler module in association with one or more shards of a change stream processed by the change handler module in a lease table of a database system, wherein the database system maintains database tables and change streams. In some embodiments, the address for the change handler module may be a DNS address of a process that includes the change handler module. In some embodiments, the received location indicator is forwarded by another module based on the stored address.

[0092] In some embodiments, a polling module of a computer system polls a change stream using a position indicator, wherein the position indicator includes a fragment identifier for one or more fragments in the change stream and a sequence number for each fragment. In some embodiments, in response to the polling, the polling module receives one or more new change records and an updated position indicator. In some embodiments, the cache module stores the one or more new change records in one or more cache entries.

[0093] Example computing device

[0094] Now turn Figure 9 , according to some embodiments, depicts a block diagram of a computing device (also referred to as a computing system) 910. Computing device 910 can be used to implement various portions of the disclosure. Computing device 910 is an example of a device that can be used as a mobile device, a server computer system, a client computer system, or any other computing system that implements portions of the disclosure.

[0095] Computing device 910 can be any suitable type of device, including but not limited to a personal computer system, a desktop computer, a laptop or notebook computer, a mobile phone, a mainframe computer system, a network server, a workstation, or a network computer. As shown, computing device 910 includes a processing unit 950, a storage subsystem 912, and an input / output (I / O) interface 930 coupled via an interconnect 960 (e.g., a system bus). I / O interface 930 can be coupled to one or more I / O devices 940. Computing device 910 also includes a network interface 932, which can be coupled to a network 920 for communicating with, for example, other computing devices.

[0096] Processing unit 950 includes one or more processors and, in some embodiments, one or more coprocessor units. In some embodiments, multiple instances of processing unit 950 can be coupled to interconnect 960. Processing unit 950 (or each processor within processing unit 950) can include cache or other forms of on-board memory. In some embodiments, processing unit 950 can be implemented as a general-purpose processing unit, while in other embodiments, processing unit 950 can be implemented as a special-purpose processing unit (e.g., an ASIC). In general, computing device 910 is not limited to any particular type of processing unit or processor subsystem.

[0097] As used herein, the term "processing unit" or "processing element" refers to a circuit configured to perform an operation. Thus, a processing unit can be implemented as a hardware circuit implemented in a variety of ways. The hardware circuit can include, for example, custom very large scale integration (VLSI) circuits or gate arrays, off-the-shelf semiconductors such as logic chips, transistors, or other discrete components. A processing unit can also be implemented in a programmable hardware device such as a field programmable gate array, programmable array logic, a programmable logic device, or the like.

[0098] As used herein, the term "module" refers to a circuit or physical non-transitory computer-readable medium configured to perform a specified operation, which stores information (e.g., program instructions) that instructs other circuits (e.g., processors) to perform the specified operation. A module can be implemented in a variety of ways, including as a hard-wired circuit or as a memory in which program instructions that can be executed by one or more processors to perform the operation are stored. Hardware circuits can include, for example, customized very large scale integration (VLSI) circuits or gate arrays, off-the-shelf semiconductors such as logic chips, transistors, or other discrete components. A module can also be implemented in programmable hardware devices such as field programmable gate arrays, programmable array logic, programmable logic devices, etc. A module can also be a non-transitory computer-readable medium in any suitable form that stores program instructions that can be executed to perform the specified operation.

[0099] The storage subsystem 912 can be used by the processing unit 950 (e.g., to store instructions that can be executed by the processing unit 950 and data used by the processing unit 950). The storage subsystem 912 can be implemented by any suitable type of physical storage medium, including hard disk storage, floppy disk storage, removable disk storage, flash memory, random access memory (RAM-SRAM, EDO RAM, SDRAM, DDR SDRAM, RDRAM, etc.), ROM (PROM, EEPROM, etc.), etc. In some embodiments, the storage subsystem 912 can be composed only of volatile memory. The storage subsystem 912 can store program instructions that can be executed by the computing device 910 using the processing unit 950, including program instructions that can be executed to cause the computing device 910 to implement the various techniques disclosed herein.

[0100] According to various embodiments, the I / O interface 930 can represent one or more interfaces and can be any of the various types of interfaces configured to be coupled to other devices and communicate with other devices. In some embodiments, the I / O interface 930 is a bridge chip from the front end to one or more back-end buses. The I / O interface 930 can be coupled to one or more I / O devices 940 via one or more corresponding buses or other interfaces. Examples of I / O devices include storage devices (hard drives, optical drives, removable flash drives, storage arrays, SANs, or associated controllers), network interface devices, user interface devices, or other devices (e.g., graphics, sound, etc.).

[0101] Notice, Figure 9 The computing device shown is one embodiment for demonstrating the disclosed concepts. In other embodiments, various aspects of the computing device may be different. For example, in some embodiments, additional components or multiple instances of the components shown may be included.

[0102] Although specific embodiments have been described above, these embodiments are not intended to limit the scope of the disclosure, even if only a single embodiment has been described with respect to a particular feature. Unless otherwise stated, the examples of features provided in the disclosure are intended to be illustrative rather than restrictive. The above description is intended to encompass such alternatives, modifications, and equivalents as would be apparent to one skilled in the art having the benefit of the disclosure.

[0103] The scope of the disclosure includes any feature or combination of features disclosed herein (explicitly or implicitly), or any generalization thereof, whether or not it mitigates any or all of the problems addressed herein. Accordingly, new claims may be formulated during the prosecution of this application (or an application claiming priority thereto) to any such combination of features. In particular, with reference to the appended claims, features of dependent claims may be combined with features of the independent claims, and features of the independent claims may be combined in any appropriate manner, and not merely in the specific combinations recited in the appended claims.

Claims

1. A method comprising: receiving, by a cache module of a computer system, a change record from a change stream, wherein the change stream includes a plurality of records indicating changes to a database table; wherein the change stream comprises change records for a plurality of shards, and wherein the change stream is accessible by providing one or more position indicators for one or more of the plurality of shards to request the one or more change records and the updated position indicator; storing, by the cache module, one or more cache entries each including a record of the change for the group of one or more shards for which the cache module is configured; requesting, by a change processor module of the computer system, a portion of the change stream, wherein the request includes providing a received position indicator; and receiving, by the change processor module, from the cache module, one or more cached change records from cache entries that match a provided location indicator, wherein the match between the cache entry and the provided location indicator is based on a shard identifier and a sequence number included in the location indicator, and wherein the cache entry comprises a tag value having one or more of the shard identifiers and one or more sequence numbers corresponding to the one or more shard identifiers.

2. The method according to claim 1, further comprising: receiving, by a multi-tenant adapter module, a tenant-based request from the change processor module; and The multi-tenant adapter module converts the tenant-based request into a request supported by the database system that maintains the database table, wherein the multi-tenant adapter module uses the database table to store fields of multiple different tenants.

3. The method according to claim 2, further comprising: determining, by the computer system, a plurality of tenant checkpoints based on processing of change records of the plurality of tenants; determining, by the computer system, a combined checkpoint based on the plurality of tenant checkpoints; and The combined checkpoint is stored.

4. The method of claim 1, wherein the cache module and the change handler module are included in a stream process, wherein the method further comprises accessing the change stream using a plurality of different stream processes executed by the computer system.

5. The method according to claim 1, further comprising: storing, by the computer system, an address of the change processor module in association with one or more shards of the change stream processed by the change processor module in a lease table of a database system, wherein the database system maintains the database table and the change stream; and The received location indicator is forwarded by another module based on the stored address.

6. The method according to claim 1, further comprising: polling the change stream by a polling module of the computer system using a position indicator, wherein the position indicator includes a fragment identifier of one or more fragments in the change stream and a sequence number of each fragment; In response to the poll, receiving one or more new change records and an updated location indicator; and The cache module stores the one or more new change records in one or more cache entries.

7. A non-transitory computer-readable medium having stored thereon instructions executable by a computing device to perform operations comprising: receiving, by a cache module, a change record from a change stream, wherein the change stream includes a plurality of records indicating changes to a database table; wherein the change stream comprises change records for a plurality of shards, and wherein the change stream is accessible by providing one or more position indicators for one or more of the plurality of shards to request the one or more change records and the updated position indicator; For changes to the group of one or more shards for which the cache module is configured, storing, by the cache module, one or more cache entries, each comprising a record of changes to the group of up to a threshold group size requesting, by a change processor module, a portion of the change stream, wherein the request includes providing a received position indicator; and receiving, by the change processor module, from the cache module, one or more cached change records from cache entries that match a provided location indicator, wherein the match between the cache entry and the provided location indicator is based on a shard identifier and a sequence number included in the location indicator, and wherein the cache entry comprises a tag value having one or more of the shard identifiers and one or more sequence numbers corresponding to the one or more shard identifiers.

8. The non-transitory computer-readable medium of claim 7, wherein the operations further comprise: receiving, by a multi-tenant adapter module, a tenant-based request from the change processor module; and The multi-tenant adapter module converts the tenant-based request into a request supported by the database system that maintains the database table, wherein the multi-tenant adapter module uses the database table to store fields of multiple different tenants.

9. The non-transitory computer-readable medium of claim 8, wherein the operations further comprise: determining a plurality of tenant checkpoints based on processing of change records for the plurality of tenants; determining a combined checkpoint based on the plurality of tenant checkpoints; and The combined checkpoint is stored.

10. The non-transitory computer-readable medium of claim 7, wherein the operations further comprise: storing an address of the change processor module in association with one or more shards of the change stream processed by the change processor module in a lease table of a database system, wherein the database system maintains the database table and the change stream; and The received location indicator is forwarded by another module based on the stored address.

11. The non-transitory computer-readable medium of claim 7, wherein the operations further comprise: polling the change stream using the position indicator by a polling module, wherein the position indicator comprises a fragment identifier of one or more fragments in the change stream and a sequence number of each fragment; In response to the poll, receiving one or more new change records and an updated location indicator; and The cache module stores the one or more new change records in one or more cache entries.

12. A system comprising: The cache module is configured as follows: receiving a change record from a change stream, wherein the change stream includes a plurality of records indicating changes to a database table; wherein the change stream comprises change records for a plurality of shards, and wherein the change stream is accessible by providing one or more position indicators for one or more of the plurality of shards to request the one or more change records and the updated position indicator; storing, by the cache module, one or more cache entries each including a record of the change for the group of one or more shards for which the cache module is configured; and The change processor module is configured as follows: requesting a portion of the change stream, wherein the requesting includes providing a received position indicator; and receiving from the cache module one or more cached change records from cache entries that match the provided location indicator, wherein the match between the cache entry and the provided location indicator is based on a shard identifier and a sequence number included in the location indicator, and wherein the cache entry comprises a tag value having one or more of the shard identifiers and one or more sequence numbers corresponding to the one or more shard identifiers.

13. An apparatus comprising means for performing the method of any one of claims 1 to 6.