Use method of database shared object and related product

By setting reference counts and state variables for shared objects, cache them locally and using optimistic locking strategies, the communication bottleneck problem caused by frequent locking of shared objects is solved, and the operation efficiency and concurrency of the database system are improved.

CN120407226APending Publication Date: 2025-08-01CETC JINCANG (BEIJING) TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510428833.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-07
Publication Date
2025-08-01

AI Technical Summary

Technical Problem

In a multi-process architecture database system, frequent reading of shared variables leads to frequent acquisition of shared locks, forming a system communication bottleneck and affecting the operation efficiency of the database system.

Method used

By setting two reference counts and one state variable for shared objects, cache shared objects to the process local and manage counting operations using an optimistic locking strategy to avoid frequent locking of shared objects.

Benefits of technology

It improves the process's access speed to shared objects, reduces the risk of communication bottlenecks in the database system, prevents concurrent errors, and improves the operation efficiency of the database system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120407226A_ABST
    Figure CN120407226A_ABST
Patent Text Reader

Abstract

The invention provides a use method of a database shared object and a related product. The use method comprises the following steps: creating two reference counts corresponding to a shared object; under the condition that any process of the database serves as a cache process to cache the shared object locally, the cache process selectively performs accumulation counting on one of the two reference counts according to the state variable of the shared object; storing the cache process in an accumulated count record of the reference count; and under the condition that any process is used as the release process to release the shared object, the release process alternatively performs decrement counting on one of the two reference counts according to the state variable and the accumulated counting record. Under the condition of not generating a concurrent error problem, the access speed of the process to the shared object is accelerated, the efficiency of using the shared object by the process is improved, the communication bottleneck risk of the database system is reduced, and the operation efficiency of the database system is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of databases, and in particular, to a method for using a database shared object, a computer-readable storage medium, a computer program product, and a computer device. Background Art

[0002] In a database system with a multi-process architecture, each process has an independent address space, and each process can usually only read and write variables in its own stack. The database system usually sets variables that can be shared by all processes (referred to as shared memory variables or shared variables). Shared variables usually use the shared memory of the database system so that they can be obtained or changed by each process. Since the shared variables are globally shared, when process A changes a shared variable, if process B reads the shared variable after process A has completed the change, then process B can read the changed value. If process B reads the shared variable before process A has completed the change, then process B may not read the result it expects to read, and it may cause concurrent error problems.

[0003] To solve the above problems, a lock mechanism is usually set for shared variables in the related art. Specifically, when any process needs to read the shared variable, it always first obtains a shared mode lock (also called a shared lock) that locks the shared variable. When any process needs to change the shared variable, it always first obtains an exclusive mode lock (also called an exclusive lock) that locks the shared variable.

[0004] However, when each process in the database system frequently reads a certain shared variable, it is necessary to frequently obtain a shared lock, which easily forms a system communication bottleneck and further affects the operation efficiency of the database system. Summary of the Invention

[0005] An object of the present invention is to provide a method for using a database shared object, a computer-readable storage medium, a computer program product, and a computer device, so as to improve the efficiency of each process in the database using the shared object, thereby improving the operation efficiency of the database system.

[0006] Specifically, according to one aspect of the present invention, the present invention provides a method for using a database shared object, including:

[0007] Creating two reference counts corresponding to the shared object;

[0008] When any process in the database caches the shared object locally as a cache process, the cache process selectively accumulates one of the two reference counts according to the state variable of the shared object, and the state variable is used to reflect whether the shared object is being updated;

[0009] Save the cache process in the cumulative count record of the reference count;

[0010] In the case where any of the processes releases the shared object as a release process, the release process selectively decrements one of the two reference counts according to the state variable and the cumulative count record.

[0011] Optionally, the cache process selectively increments one of the two reference counts according to the state variable of the shared object, including:

[0012] The cache process determines whether the state variable is in an updated state;

[0013] If it is in a non-updated state, increment the first reference count of the two reference counts;

[0014] If it is in the updated state, increment the second reference count of the two reference counts.

[0015] Optionally, the release process selectively decrements one of the two reference counts according to the state variable and the cumulative count record, including:

[0016] The release process determines whether the state variable is in the updated state;

[0017] If it is in the non-updated state, decrement the first reference count;

[0018] If it is in the updated state, determine whether the release process exists in the cumulative count record of the second reference count;

[0019] If it exists, decrement the second reference count;

[0020] If it does not exist, decrement the first reference count.

[0021] Optionally, the update process of the shared object includes:

[0022] In response to any of the processes triggering the condition for updating the shared object as an update process, the update process sets the state variable to the updated state;

[0023] The update process modifies the shared object;

[0024] The update process issues a broadcast requesting all other processes to modify their respective shared objects;

[0025] In response to the first reference count decreasing to the initial value, the update process sets the status variable to the non-updated state;

[0026] Swap the values of the first reference count and the second reference count.

[0027] Optionally, the step of any process that receives the broadcast modifying its shared object includes:

[0028] Invalidate the shared object cached locally;

[0029] Cache the shared object modified by the update process locally.

[0030] Optionally, before setting the status variable to the updated state, it further includes:

[0031] The update process obtains an exclusive lock on the shared object;

[0032] The update process obtains an exclusive lock on the status variable; and

[0033] After the update process modifies the shared object, it further includes:

[0034] The update process releases the exclusive lock on the shared object;

[0035] The update process releases the exclusive lock on the status variable.

[0036] Optionally, before the update process sets the status variable to the non-updated state, it further includes:

[0037] The update process obtains an exclusive lock on the status variable; and

[0038] After swapping the values of the first reference count and the second reference count, it further includes:

[0039] The update process releases the exclusive lock on the status variable.

[0040] Optionally, before the release process determines whether the status variable is in the updated state, it further includes:

[0041] The release process obtains a shared lock on the status variable; and

[0042] After the release process determines the value of the status variable, it further includes:

[0043] The release process releases the shared lock on the status variable.

[0044] Optionally, before the step where the caching process determines whether the status variable is in an updated state, the following steps are further included:

[0045] The caching process acquires a shared lock for the status variable; and

[0046] After the caching process determines the value of the status variable, the following steps are further included:

[0047] The caching process releases the shared lock for the status variable.

[0048] Optionally, the step where the caching process caches the shared object locally includes:

[0049] Acquire a shared lock for the shared object;

[0050] Acquire the shared object;

[0051] Cache the shared object locally;

[0052] Release the shared lock for the shared object.

[0053] Optionally, the step of incrementing a certain reference count includes:

[0054] Use an optimistic locking strategy to increment the reference count by 1; and

[0055] Optionally, the step of decrementing a certain reference count includes:

[0056] Use an optimistic locking strategy to decrement the reference count by 1.

[0057] Optionally, the step where the releasing process releases its shared object includes:

[0058] In response to the releasing process triggering an instruction for logging off the current process, or receiving a notification for modifying its shared object, determine whether the releasing process has a shared object cached locally;

[0059] If so, release the shared object cached locally.

[0060] According to another aspect of the present invention, there is also provided a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the usage method of the database shared object described above are implemented.

[0061] According to still another aspect of the present invention, there is also provided a computer program product, which includes a computer program, and when the computer program is executed by a processor, the steps of the usage method of the database shared object described above are implemented.

[0062] According to another aspect of the present invention, there is also provided a computer device, including a memory, a processor, and a computer program stored on the memory, and the processor executes the computer program to implement the steps of the usage method of the database sharing object in any of the above.

[0063] The usage method of the database sharing object of the present invention can accelerate the access speed of the process to the sharing object, improve the efficiency of the process using the sharing object, reduce the risk of communication bottlenecks in the database system, and improve the operation efficiency of the database system by caching the sharing object locally in the process. By setting two reference counts and status variables for the sharing object, it is convenient to determine whether all the sharing objects before modification in all processes in this round of cycle have been released according to the values of the two reference counts, thereby preventing concurrent error problems.

[0064] Those skilled in the art will understand more clearly the above and other objects, advantages, and features of the present invention according to the following detailed description of the specific embodiments of the present invention in conjunction with the accompanying drawings. Description of the Drawings

[0065] Some specific embodiments of the present invention will be described in detail hereinafter with reference to the accompanying drawings in an exemplary but not restrictive manner. The same reference numerals in the drawings denote the same or similar components or parts. Those skilled in the art should understand that these drawings are not necessarily drawn to scale. In the drawings:

[0066] Figure 1 is a schematic flowchart of the usage method according to an embodiment of the present invention;

[0067] Figure 2 is a schematic flowchart of the cumulative counting of the reference count in the usage method according to an embodiment of the present invention;

[0068] Figure 3 is a schematic flowchart of the decremental counting of the reference count in the usage method according to an embodiment of the present invention;

[0069] Figure 4 is a schematic flowchart of the update of the sharing object in the usage method according to an embodiment of the present invention;

[0070] Figure 5 is a schematic flowchart of the process caching the sharing object locally in the usage method according to an embodiment of the present invention;

[0071] Figure 6 is a schematic flowchart of the process releasing its sharing object in the usage method according to an embodiment of the present invention;

[0072] Figure 7 is a schematic flowchart of the process modifying its sharing object in the usage method according to an embodiment of the present invention;

[0073] Figure 8 is a schematic diagram of a computer program product according to an embodiment of the present invention;

[0074] Figure 9 is a schematic diagram of a computer-readable storage medium according to an embodiment of the present invention; and

[0075] Figure 10 is a schematic diagram of a computer device according to an embodiment of the present invention. Detailed implementation manners

[0076] The purpose of the usage method of the database shared object in this embodiment is to improve the efficiency of each process of the database in using the shared object, thereby improving the running efficiency of the database system.

[0077] Figure 1 is a schematic flowchart of a usage method according to an embodiment of the present invention, and the method generally may include:

[0078] S100, create two reference counts corresponding to the shared object;

[0079] S200, when any process in the database is used as a caching process to cache the shared object locally, the caching process alternatively increments one of the two reference counts according to the status variable of the shared object, and the status variable is used to reflect whether the shared object is being updated;

[0080] S300, save the increment count record of the reference count in the caching process;

[0081] S400, when any process is used as a releasing process to release the shared object, the releasing process alternatively decrements one of the two reference counts according to the status variable and the increment count record.

[0082] Related technologies usually set a lock mechanism for shared objects (such as shared variables). When any process needs to read the shared object, it always first obtains the shared lock that locks the shared object. When any process needs to change the shared object, it always first obtains the exclusive lock that locks the shared object. In practice, the update frequency of some shared objects is relatively low. For these shared objects, all processes may frequently perform read operations and rarely perform change operations. This results in all processes frequently communicating with the node that has the control right of the lock of the shared object to request to obtain the shared lock of the shared object, thus easily forming a system communication bottleneck, and further affecting the running efficiency of the database system.

[0083] In this embodiment, when any process first uses a certain shared object, it will cache it locally in the process (which can be called the caching process). Specifically, when the caching process first obtains the shared object, it needs to use a shared lock to obtain the shared object in the shared memory. After successfully obtaining it, the value of the shared object is written to a certain position in the address space of the caching process itself. In this way, when the caching process performs subsequent read operations, it can obtain the value of the shared object by directly accessing the local shared object. When the process does not need to use the shared object (such as logging off the process, receiving relevant instructions, etc.), it needs to release the shared object cached locally (which can be called the releasing process). This solution can avoid frequently requesting the lock of the shared object and improve the operating efficiency of the database system.

[0084] When using the above solution, the following problems will be faced: If a certain process makes a change operation on the shared object in the shared memory (which can be called the updating process), that is, the updating process modifies the value of the shared object, it will cause the values of the shared object in the shared memory and those shared objects that have been cached locally to be inconsistent. That is to say, the shared object in the shared memory is the new version, while the shared object that already existed locally in the process before is the old version. If the caching process still uses the old version of the shared object, it may cause concurrent error problems, which may lead to serious consequences.

[0085] To solve this problem, this embodiment further sets two reference counts and a status variable for the shared object.

[0086] Exemplarily, when initializing the shared object in the shared memory, the first reference count and the second reference count can be generated together. The initial values of the two reference counts can both be set to 0. Each time the count is incremented, it is increased by 1, and each time the count is decremented, it is decreased by 1. When the values of the two reference counts are both 0, it indicates that no process is currently referencing the shared object.

[0087] The status variable is used to reflect whether the shared object is being updated. Specifically, the status variable may include an updated state and a non-updated state. The initial state of the status variable may be the non-updated state. The status variable can be modified by any update process in the database. The update process of the shared object is a periodic process. For this round of cycle, first, the update process modifies the shared object in the memory, and then notifies all other processes to release their shared objects (the shared objects cached locally in the previous round). After all releases are completed, the update process of the shared object in this round can end, waiting for the update process in the next round of cycle. The status variable is used to reflect that the shared object in the shared memory has been modified in this round of cycle. Exemplarily, when the update process completes the modification of the shared object in the shared memory in this round of cycle, the status variable can be set to the updated state. When all processes release their shared objects in this round of cycle, the status variable can be set to the non-updated state.

[0088] In this embodiment, when the caching process caches the shared object locally, it will obtain the value of the status variable, determine one of the first reference count and the second reference count according to the value of the status variable, perform an accumulative count on it, and save the accumulative count record of the reference count. The accumulative count record should record the number of the caching process. For example, when the value of the status variable is the updated state, the second reference count can be accumulatively counted, and when the value of the status variable is the non-updated state, the first reference count can be accumulatively counted. Since the value of the status variable can reflect whether the shared object in the shared memory has been modified in this round of cycle, therefore, through the values of the first reference count and the second reference count, it is convenient to determine the total number of processes that have not modified the cached shared object and the total number of processes that have modified the cached shared object in the database system in this round of cycle. When the value of the first reference count is the initial value, it can be determined that there is no process in the current system that caches the shared object that has not been modified.

[0089] In this embodiment, when the releasing process releases its shared object, by obtaining the status variable and the accumulative count record in the shared memory, it can be determined whether the shared object of the releasing process was cached before or after the modification of the shared object in the shared memory in this round of cycle, and then it can be determined whether the releasing process accumulatively counted the first reference count or the second reference count at the beginning, and then perform a decrement count to remove the accumulative count. Exemplarily, when the value of the first reference count is the initial value, it indicates that all the shared objects before modification in all processes in this round of cycle have been released, and there is no concurrent error problem for this shared object in this round of cycle.

[0090] The usage method of the database shared object in this embodiment can accelerate the access speed of the process to the shared object by caching the shared object locally in the process, improve the efficiency of the process using the shared object, reduce the risk of communication bottlenecks in the database system, and improve the operating efficiency of the database system. By setting two reference counts and status variables for the shared object, it is convenient to determine whether all the shared objects before modification in all processes in this cycle have been released according to the values of the two reference counts, thereby preventing concurrent error problems from occurring.

[0091] In some embodiments of the usage method of the present invention, such as Figure 2 shown, the caching process selectively increments one of the two reference counts according to the status variable of the shared object, including:

[0092] S251, the caching process determines whether the status variable is in the updated state;

[0093] S253, if it is in the non-updated state, increment the first reference count among the two reference counts;

[0094] S255, if it is in the updated state, increment the second reference count among the two reference counts.

[0095] In this embodiment, in each cycle, the first reference count is used to reflect the total number of processes that cache the unmodified shared objects in this cycle locally by the caching process, and the second reference count is used to reflect the total number of processes that cache the modified shared objects in this cycle locally by the caching process. Thus, when the value of the first reference count is the initial value, it indicates that no process caches the unmodified shared object. When the value of the first reference count is not the initial value, it indicates that there is a process caching the unmodified shared object. When the values of both the first reference count and the second reference count are not the initial value, it indicates that the process caches different versions of the shared object, and concurrent error problems may occur.

[0096] In this embodiment, only the cumulative count record of the second reference count can be saved, thereby reducing the system memory occupancy.

[0097] In some embodiments of the usage method of the present invention, such as Figure 3 shown, the releasing process selectively decrements one of the two reference counts according to the status variable and the cumulative count record, including:

[0098] S451, the releasing process determines whether the status variable is in the updated state; if it is in the non-updated state, execute S457, if it is in the updated state, execute S453;

[0099] S453, Determine whether the release process exists in the cumulative count record of the second reference count; if it exists, execute S455, if not, execute S457;

[0100] S455, Decrement the second reference count;

[0101] S457, Decrement the first reference count.

[0102] In this embodiment, when the status variable is in the non-updated state, it indicates that the shared object in the shared memory has not been modified during this cycle. Then it can be determined that the release process incremented the first reference count when caching the shared object. Now it is necessary to decrement the first reference count to remove this increment. When the status variable is in the updated state, it indicates that the shared object in the shared memory has been modified during this cycle. Therefore, there may be two cases: The first case is that the release process cached the shared object locally when it had not been modified. Therefore, the record of this release process does not exist in the cumulative count record of the second reference count. Now it is necessary to decrement the first reference count to remove this increment. The second case is that the release process cached the shared object locally when it had been modified. Therefore, the record of this release process exists in the cumulative count record of the second reference count. Now it is necessary to decrement the second reference count to remove this increment.

[0103] Thus, when the value of the first reference count is the initial value, it indicates that all processes have released the unmodified shared object. When the value of the first reference count is not the initial value, it indicates that there is a process caching an unmodified shared object.

[0104] In some embodiments of the usage method of the present invention, as Figure 4 shown, the update process of the shared object includes:

[0105] S551, The update process sets the status variable to the updated state;

[0106] S552, The update process modifies the shared object;

[0107] S553, The update process sends a broadcast requesting all other processes to modify their respective shared objects;

[0108] S554, Determine whether the first reference count is the initial value;

[0109] S555, If so, the update process sets the status variable to the non-updated state;

[0110] S556, Exchange the values of the first reference count and the second reference count.

[0111] This embodiment is used to further optimize the update problem of database shared objects. Specifically, the update process first sets the status variable to the update status to indicate that the shared object in the shared memory is being modified during this cycle. Then, it modifies the value of the shared object to the required value, and then issues a broadcast requesting all other processes to modify their respective shared objects. The processes that have cached the shared object will respond to this broadcast and perform the operation of modifying their shared objects.

[0112] It should be understood that after the update process issues the broadcast, the processes that have not cached the shared object can obtain the modified shared object and cache it locally. Since the status variable is in the update status at this time, the caching process needs to increment the second reference count and record the process in the cumulative count record of the second reference count. When a process that has cached the shared object modifies its shared object, it can first release the old shared object, decrement the first reference count, then obtain the modified shared object, increment the second reference count, and record the process in the cumulative count record of the second reference count.

[0113] In particular, in this embodiment, when the update process updates the shared object, it does not need to block other processes from obtaining the modified shared object for a long time. That is to say, it does not need to wait for all the processes that have cached the shared object to release the old shared object, but directly releases the access permission of each process to the modified shared object. On the one hand, it enables the update process to update the shared object at any time, and on the other hand, it enables other processes to obtain the modified shared object at any time, realizing non-blocking and efficient update and use of the shared object, improving the concurrency when updating the shared object, and enhancing the overall performance of the system.

[0114] After the update process issues the broadcast, it can wait for a period of time until the value of the first reference count is reduced to the initial value, indicating that the old shared object cache has been released by the process, and then it can perform the operation of ending this cycle. Specifically, the update process can exchange the values in the first reference count and the second reference count. At this time, the value of the first reference count is the initial value and no longer has the meaning of maintenance. By exchanging the values of the first reference count and the second reference count, the second reference count of this cycle is used as the first reference count of the next cycle, and the first reference count with the initial value of this cycle is used as the second reference count of the next cycle, which can save the step of reconstructing the two reference counts in the next cycle.

[0115] In some embodiments of the usage method of the present invention, as Figure 7 shown, the steps for any process that receives the broadcast to modify its shared object include:

[0116] S561, invalidate the shared object cached locally;

[0117] S563, cache the updated shared object of the update process locally.

[0118] Specifically, after receiving the broadcast, the process can first invalidate the shared object cached locally, decrement the corresponding reference count, then cache the updated shared object in the shared memory locally, and increment the second reference count. In this way, the efficient update of the local shared object is achieved.

[0119] In some embodiments of the usage method of the present invention, such as Figure 4 as shown, before setting the status variable to the update state, it further includes:

[0120] S511, in response to a condition that any process triggers the update of the shared object as the update process, the update process acquires the exclusive lock of the shared object;

[0121] S513, the update process acquires the exclusive lock of the status variable; and

[0122] after the update process modifies the shared object, it further includes:

[0123] S515, the update process releases the exclusive lock of the shared object;

[0124] S517, the update process releases the exclusive lock of the status variable.

[0125] In this embodiment, by acquiring the exclusive lock of the shared object, it can prevent other processes from reading or modifying the shared object when the update process modifies the shared object, avoiding concurrent error problems. In particular, since some processes have cached the shared object locally, there are fewer processes holding the shared lock of the shared object, and the update process can quickly acquire the exclusive lock of the shared object and modify the shared object. In this way, situations such as lock starvation and lock starvation can be effectively reduced or avoided, achieving non-blocking and efficient modification of the shared object, improving the update efficiency of the shared object, enhancing the concurrency when updating the shared object, and improving the overall performance of the system.

[0126] In this embodiment, after the update process sends out the broadcast, it can release the exclusive lock of the shared object. In this way, all processes can request to obtain the updated shared object without waiting and cache it locally, achieving non-blocking and efficient use of the shared object and improving the usage efficiency of the database shared object.

[0127] In this embodiment, by acquiring the exclusive lock of the status variable, it can prevent other processes from reading or modifying the status variable when the update process modifies the status variable, avoiding concurrent error problems.

[0128] In some embodiments of the usage method of the present invention, such asFigure 4 As shown, before the update process sets the status variable to the non-update state, it further includes:

[0129] S521, in response to the first reference count decreasing to the initial value, the update process acquires an exclusive lock on the status variable; and

[0130] After swapping the values of the first reference count and the second reference count, it further includes:

[0131] S523, the update process releases the exclusive lock on the status variable.

[0132] By acquiring the exclusive lock on the status variable, it can prevent other processes from reading or modifying the status variable when the update process modifies the status variable, avoiding concurrent error problems.

[0133] In some embodiments of the usage method of the present invention, as Figure 3 shown, before the step where the release process determines whether the status variable is in the update state, it further includes:

[0134] S411, the release process acquires a shared lock on the status variable; and

[0135] After the release process determines the value of the status variable, it further includes:

[0136] S413, the release process releases the shared lock on the status variable.

[0137] By acquiring the shared lock on the status variable, it can prevent other processes from modifying the status variable when the release process reads the status variable, avoiding concurrent error problems.

[0138] In some embodiments of the usage method of the present invention, as Figure 2 shown, before the step where the caching process determines whether the status variable is in the update state, it further includes:

[0139] S211, the caching process acquires a shared lock on the status variable; and

[0140] After the caching process determines the value of the status variable, it further includes:

[0141] S213, the caching process releases the shared lock on the status variable.

[0142] By acquiring the shared lock on the status variable, it can prevent other processes from modifying the status variable when the caching process reads the status variable, avoiding concurrent error problems.

[0143] In some embodiments of the usage method of the present invention, as Figure 5 shown, the step where the caching process caches the shared object locally includes:

[0144] S261, obtain the shared lock of the shared object;

[0145] S263, obtain the shared object;

[0146] S265, cache the shared object locally;

[0147] S267, release the shared lock of the shared object.

[0148] By obtaining the shared lock of the shared object, it is possible to prevent other processes from modifying the shared object while the caching process is caching the shared object, avoiding concurrent error problems.

[0149] In some embodiments of the usage method of the present invention, the step of incrementing a certain reference count includes:

[0150] Using the optimistic lock strategy Compare And Swap (abbreviated as CAS) to increment the reference count by 1; and

[0151] The step of decrementing a certain reference count includes:

[0152] Using the optimistic lock strategy to decrement the reference count by 1.

[0153] The optimistic lock strategy is a concurrency control mechanism used to solve potential data consistency problems when multiple processes simultaneously access and modify the same reference count. The basic idea of the optimistic lock is to assume that the modification operations of multiple processes on the same reference count will not conflict, so there is no need to add locks for restriction, and each operation will perform a version check to ensure data consistency. By using the optimistic lock strategy to increment or decrement the reference count, the efficiency of incrementing and decrementing the count can be improved.

[0154] In some embodiments of the usage method of the present invention, as Figure 6 shown, the steps for the releasing process to release its shared object include:

[0155] S461, in response to the releasing process triggering an instruction to log off the current process, or receiving a notification to modify its shared object, determine whether the releasing process has a shared object cached locally;

[0156] S463, if so, release the shared object cached locally.

[0157] In this embodiment, when any process logs off, it is necessary to first release the shared object cached locally and decrement the corresponding reference count. When any process receives a notification to modify its shared object (such as a broadcast sent by an update process), it is necessary to determine whether the current process has a shared object cached locally. If so, it is necessary to respond to the notification, release the shared object cached locally, and decrement the corresponding reference count.

[0158] The flowcharts provided in this embodiment are not intended to indicate that the operations of the method will be performed in any specific order, or that all operations of the method are included in every case. In addition, the method may include additional operations. Within the scope of the technical concept provided by the method of this embodiment, additional changes may be made to the above method.

[0159] It should be understood that in some embodiments, each part may be implemented by hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods may be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system.

[0160] The embodiment of the present invention also provides a computer program product 10, a computer-readable storage medium 20, and a computer device 30. Figure 8 is a schematic diagram of a computer program product 10 according to an embodiment of the present invention, Figure 9 is a schematic diagram of a computer-readable storage medium 20 according to an embodiment of the present invention, Figure 10 is a schematic diagram of a computer device 30 according to an embodiment of the present invention. The computer program product 10 includes a computer program 11, and when the computer program 11 is executed by a processor 32, it implements the steps of any one of the above usage methods. The computer-readable storage medium 20 stores the above computer program 11, and when the computer program 11 is executed by a processor 32, it implements the steps of the usage method of any one of the above embodiments. The computer device 30 may include a memory 31, a processor 32, and a computer program 11 stored on the memory 31 and running on the processor 32.

[0161] The computer program 11 for performing the operations of the present invention may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-related instructions, microcode, firmware instructions, state setting data, configuration data of an integrated circuit, or source code or object code written in any combination of one or more programming languages and procedural programming languages. The computer program 11 may be executed entirely on the user's computer, partially on the user's computer, executed as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the latter case, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider). In some embodiments, in order to perform aspects of the present invention, an electronic circuit, including, for example, a programmable logic circuit, a field-programmable gate array (FPGA), or a programmable logic array (PLA), may execute computer-readable program instructions by utilizing the state information of the computer-readable program instructions to personalize the electronic circuit.

[0162] For the description of this embodiment, the computer program product 10 is a related product containing the computer program 11.

[0163] For the description of this embodiment, the computer-readable storage medium 20 is a tangible device capable of retaining and storing the computer program 11, which may be any device that can contain, store, communicate, propagate, or transmit the computer program 11 for use by or in connection with an instruction execution system, apparatus, or device. More specific examples (non-exhaustive list) of the computer-readable storage medium 20 include the following: portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), static random access memory (SRAM), portable compact disc read-only memory (CD-ROM), digital versatile disc (DVD), memory stick, floppy disk, mechanically encoded device, and any suitable combination of the above.

[0164] The computer device 30 can be, for example, a server, a desktop computer, a laptop computer, a tablet computer, or a smart phone. In some examples, the computer device 30 can be a cloud computing node. The computer device 30 can be described in the general context of computer system executable instructions, such as program modules, executed by a computer system. Generally, program modules can include routines, programs, object programs, components, logic, data structures, etc. that perform particular tasks or implement particular abstract data types. The computer device 30 can be implemented in a distributed cloud computing environment where tasks are performed by remote processing devices linked through a communication network. In a distributed cloud computing environment, program modules can be located on local or remote computing system storage media including storage devices.

[0165] The computer device 30 can include a processor 32 adapted to execute stored instructions and a memory 31 that provides temporary storage space for the operation of the instructions during operation. The processor 32 can be a single-core processor, a multi-core processor, a computing cluster, or any number of other configurations. The memory 31 can include random access memory (RAM), read-only memory, flash memory, or any other suitable storage system.

[0166] The computer device 30 can also include a network adapter / interface and an input / output (I / O) interface. The I / O interface allows data to be input and output with external devices that can be connected to the computer device. The network adapter / interface can provide communication between the computer device and a network, which is typically shown as a communication network.

[0167] Up to this point, those skilled in the art should recognize that although multiple exemplary embodiments of the present invention have been shown and described in detail herein, many other variations or modifications that conform to the principles of the present invention can still be directly determined or derived from the content disclosed in the present invention without departing from the spirit and scope of the present invention. Therefore, the scope of the present invention should be understood and recognized as covering all these other variations or modifications.

Claims

1. A method for using a database shared object, characterized in that Comprising: Creating two reference counts corresponding to the shared object; When any process in the database serves as a caching process and caches the shared object locally, the caching process selectively increments one of the two reference counts according to the status variable of the shared object, and the status variable is used to reflect whether the shared object is being updated; Saving the caching process in the record of the cumulative count of the reference count; When any of the processes serves as a releasing process to release the shared object, the releasing process selectively decrements one of the two reference counts according to the status variable and the cumulative count record.

2. The usage method according to claim 1, characterized in that, The step that the caching process selectively increments one of the two reference counts according to the status variable of the shared object includes: The caching process determines whether the status variable is in an updated state; If it is in a non-updated state, increment the first reference count among the two reference counts; If it is in the updated state, increment the second reference count among the two reference counts.

3. The usage method according to claim 2, characterized in that, The step that the releasing process selectively decrements one of the two reference counts according to the status variable and the cumulative count record includes: The releasing process determines whether the status variable is in the updated state; If it is in the non-updated state, decrement the first reference count; If it is in the updated state, determine whether the releasing process exists in the cumulative count record of the second reference count; If it exists, decrement the second reference count; If it does not exist, decrement the first reference count.

4. The usage method according to claim 3, characterized in that, The update process of the shared object includes: In response to any of the processes serving as an update process triggering the condition for updating the shared object, the update process sets the status variable to the updated state; The update process modifies the shared object; The update process issues a broadcast requesting all other processes to modify their respective shared objects; In response to the first reference count decrementing to the initial value, the update process sets the status variable to the non-updated state; Exchanging the values of the first reference count and the second reference count; Wherein, the step for any process that receives the broadcast to modify its shared object includes: Invalidating the shared object cached locally; Caching the shared object modified by the update process locally.

5. The usage method according to claim 4, wherein Before setting the status variable to the updated state, it further includes: The update process acquires an exclusive lock for the shared object; The update process acquires an exclusive lock for the status variable; and After the update process modifies the shared object, it further includes: The update process releases the exclusive lock for the shared object; The update process releases the exclusive lock for the status variable; Before the update process sets the status variable to the non-updated state, it further includes: The update process acquires an exclusive lock for the status variable; and After swapping the values of the first reference count and the second reference count, the following steps are further included: The update process releases the exclusive lock of the status variable.

6. The usage method according to claim 3, characterized in that Before the release process determines whether the status variable is in the update state, the following steps are further included: The release process acquires the shared lock of the status variable; and After the release process determines the value of the status variable, the following step is further included: The release process releases the shared lock of the status variable; Before the cache process determines whether the status variable is in the update state, the following steps are further included: The cache process acquires the shared lock of the status variable; and After the cache process determines the value of the status variable, the following step is further included: The cache process releases the shared lock of the status variable.

7. The usage method according to claim 1, characterized in that, The step in which the cache process caches the shared object locally includes: Acquiring the shared lock of the shared object; Acquiring the shared object; Caching the shared object locally; Releasing the shared lock of the shared object.

8. The usage method according to claim 1, characterized in that The step of incrementing a certain reference count includes: Using an optimistic locking strategy to increment the reference count by 1; and The step of decrementing a certain reference count includes: Using an optimistic locking strategy to decrement the reference count by 1.

9. The usage method according to claim 1, characterized in that, The step in which the release process releases its shared object includes: In response to the release process triggering an instruction for logging off the process itself, or receiving a notification to modify its shared object, it is determined whether there is a shared object cached locally by the release process; If so, the shared object cached locally is released.

10. A computer-readable storage medium, characterized in that, A computer program is stored thereon, and when the computer program is executed by a processor, the steps of the usage method of the database shared object according to any one of claims 1 to 9 are implemented.

11. A computer program product comprising a computer program, characterized in that, When the computer program is executed by a processor, the steps of the usage method of the database shared object according to any one of claims 1 to 9 are implemented.

12. A computer device, characterized in that, It includes a memory, a processor, and a computer program stored on the memory, and the processor executes the computer program to implement the steps of the usage method of the database shared object according to any one of claims 1 to 9.