A Parameter Incremental Loading Method, Device, Computer Device, and Storage Medium

By detecting the database version number update, loading incremental parameters, and performing consistency checks and cleansing, the instantaneous pressure and security problems of parameter loading on the database are solved, and the stability and security of system performance are achieved.

CN111475518BActive Publication Date: 2025-07-25PING AN BANK CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202010222355.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-03-26
Publication Date
2025-07-25
Estimated Expiration
2040-03-26

AI Technical Summary

Technical Problem

In the prior art, the parameter loading method causes high instantaneous pressure on the database, easy to load misses and low security.

Method used

By detecting the total version number update in the database, obtaining the associated subversion number and loading it into memory, performing consistency check and cleaning of version numbers, ensuring the accuracy and validity of parameter versions in memory, only loading parameters with incremental changes, and using the latest total version number when controlling business transactions.

Benefits of technology

It effectively reduces the system instantaneous pressure on the cluster deployment system when loading parameters, avoids excessive memory usage and misloading problems, and ensures transaction security and system performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111475518B_ABST
    Figure CN111475518B_ABST
Patent Text Reader

Abstract

The present invention discloses a method, device, computer device and storage medium for incrementally loading parameters, which relates to the technical field of parameter caching. The method includes: after parameter loading is completed, comparing the latest total version number in the database and its associated sub-version numbers with the latest total version number in the memory and its associated sub-version numbers respectively. If they are inconsistent, roll back the parameter version corresponding to the latest total version number in the memory to the state before loading; if the number of total version numbers in the memory exceeds the upper limit, clean up the parameter version corresponding to the oldest total version number in the memory; when a business transaction occurs, obtain the latest total version number in the memory, and control the thread of the business transaction to reference the latest total version number in the memory. The present invention effectively reduces the instantaneous system pressure on the database during parameter loading; ensures transaction security; avoids the problem of excessive memory occupation; and avoids misloading parameters that do not belong to the current version.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of parameter caching, and particularly to a method, device, computer device and storage medium for incremental parameter loading. Background Art

[0002] Global parameter caching is a solution adopted by many systems, which can significantly improve system performance. However, there is usually no complete solution for parameter caching loading. The general processing method is only to perform full-volume loading through a polling thread. This processing method has the following problems under high concurrency and high-performance pressure:

[0003] 1. In the case of a certain scale and system cluster deployment, full-volume loading of parameters will cause instantaneous performance pressure on the database. For example, for a system with 140 parameter tables and 120 instances deployed, during one parameter loading process, tens of thousands of full-table read operations will occur instantaneously.

[0004] 2. When parameters are updated multiple times within a short period, the situation where some associated parameters take effect partially may occur, resulting in errors in the generated business logic during the time interval between two parameter loadings. Summary of the Invention

[0005] Embodiments of the present invention provide a method, device, computer device and storage medium for incremental parameter loading, aiming to solve the problems of large instantaneous system pressure on the database, easy misloading and low security caused by the existing parameter loading method.

[0006] In a first aspect, an embodiment of the present invention provides a method for incremental parameter loading, which includes:

[0007] When it is detected that the total version number in the database has been updated, obtain the sub-version numbers associated with the total version number and that have changed, and load the parameters corresponding to the changed sub-version numbers into the memory. At the same time, update the total version number and the associated sub-version numbers in the memory.

[0008] After the parameter loading is completed, query the latest total version number and its associated sub-version numbers in the database, and compare them with the latest total version number and its associated sub-version numbers in the memory respectively. If they are inconsistent, roll back the parameter version corresponding to the latest total version number in the memory to the state before loading.

[0009] Detect the number of total version numbers in the memory. If the number of total version numbers in the memory exceeds the upper limit, clean up the parameter version corresponding to the oldest total version number in the memory.

[0010] When a business transaction occurs, obtain the latest total version number in memory, and control the thread of the business transaction to reference the latest total version number in memory until the business transaction ends.

[0011] In a second aspect, an embodiment of the present invention provides a parameter incremental loading device, including:

[0012] An incremental loading unit, configured to obtain the sub-version numbers associated with and changed by the total version number when it is detected that the total version number in the database is updated, load the parameters corresponding to the changed sub-version numbers into memory, and update the total version number and the associated sub-version numbers in memory at the same time;

[0013] A consistency checking unit, configured to query the latest total version number and its sub-version numbers in the database after the parameter loading is completed, and compare them with the latest total version number and its sub-version numbers in memory respectively. If they are inconsistent, roll back the parameter version corresponding to the latest total version number in memory to the state before loading;

[0014] A version cleaning unit, configured to detect the number of total version numbers in memory. If the number of total version numbers in memory exceeds the upper limit, clean up the parameter version corresponding to the oldest total version number in memory;

[0015] A parameter reference unit, configured to obtain the latest total version number in memory when a business transaction occurs, and control the thread of the business transaction to reference the latest total version number in memory until the business transaction ends.

[0016] In a third aspect, an embodiment of the present invention provides a computer device, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the computer program, it implements the parameter incremental loading method as described in the first aspect.

[0017] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium storing a computer program, and when the computer program is executed by a processor, it implements the parameter incremental loading method as described in the first aspect.

[0018] An embodiment of the present invention provides a method, apparatus, computer device, and storage medium for incrementally loading parameters. The method includes: when it is detected that the total version number in the database is updated, obtaining the sub-version numbers associated with the total version number that have changed, and loading the parameters corresponding to the changed sub-version numbers into the memory, while updating the total version number and the associated sub-version numbers in the memory; after the parameter loading is completed, querying the latest total version number and its associated sub-version numbers in the database, and comparing them with the latest total version number and its associated sub-version numbers in the memory respectively. If they are inconsistent, rolling back the parameter version corresponding to the latest total version number in the memory to the state before loading; detecting the number of total version numbers in the memory. If the number of total version numbers in the memory exceeds the upper limit, cleaning the parameter version corresponding to the oldest total version number in the memory; when a business transaction occurs, obtaining the latest total version number in the memory, and controlling the thread of the business transaction to reference the latest total version number in the memory until the business transaction ends. The method of the embodiment of the present invention only loads incrementally changed parameters, effectively reducing the instantaneous system pressure on the database when the cluster-deployed system loads parameters, and avoiding short-term system performance problems; when a business transaction occurs, the total version number referenced by the thread of the business transaction does not change, ensuring transaction security; adopting a parameter cache cleaning mechanism to avoid excessive memory occupation; adopting a consistency check mechanism to avoid misloading parameters that do not belong to the current version. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for the description of the embodiments will be briefly introduced below. Obviously, the drawings in the following description are some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0020] Figure 1 It is a schematic flowchart of the parameter incremental loading method provided by the embodiment of the present invention;

[0021] Figure 2 It is a schematic sub-flowchart of the parameter incremental loading method provided by the embodiment of the present invention;

[0022] Figure 3 It is another schematic sub-flowchart of the parameter incremental loading method provided by the embodiment of the present invention;

[0023] Figure 4 It is another schematic sub-flowchart of the parameter incremental loading method provided by the embodiment of the present invention;

[0024] Figure 5 It is another schematic sub-flowchart of the parameter incremental loading method provided by the embodiment of the present invention;

[0025] Figure 6 Another sub - process schematic diagram of the parameter incremental loading method provided by the embodiment of the present invention;

[0026] Figure 7 Schematic block diagram of the parameter incremental loading device provided by the embodiment of the present invention;

[0027] Figure 8 Schematic block diagram of the sub - unit of the parameter incremental loading device provided by the embodiment of the present invention;

[0028] Figure 9 Another schematic block diagram of the sub - unit of the parameter incremental loading device provided by the embodiment of the present invention;

[0029] Figure 10 Another schematic block diagram of the sub - unit of the parameter incremental loading device provided by the embodiment of the present invention;

[0030] Figure 11 Another schematic block diagram of the sub - unit of the parameter incremental loading device provided by the embodiment of the present invention;

[0031] Figure 12 Another schematic block diagram of the sub - unit of the parameter incremental loading device provided by the embodiment of the present invention;

[0032] Figure 13 Schematic block diagram of the computer device provided by the embodiment of the present invention. Detailed implementation manners

[0033] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.

[0034] It should be understood that when used in this specification and the appended claims, the terms "comprises" and "comprising" indicate the presence of the described features, wholes, steps, operations, elements, and / or components, but do not preclude the presence or addition of one or more other features, wholes, steps, operations, elements, components, and / or their combinations.

[0035] It should also be understood that the terms used in this specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in this specification of the present invention and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an", and "the" are intended to include the plural forms.

[0036] It should be further understood that the term "and / or" used in the specification and appended claims of the present invention refers to any combination and all possible combinations of one or more of the associated listed items, and includes these combinations.

[0037] Please refer to Figure 1 , Figure 1 which is a schematic flowchart of a parameter incremental loading method provided by an embodiment of the present invention. The method may include steps S101 to S104:

[0038] S101. When it is detected that the total version number in the database is updated, obtain the sub-version numbers associated with the total version number and that have changed, and load the parameters corresponding to the changed sub-version numbers into the memory. At the same time, update the total version number and the associated sub-version numbers in the memory;

[0039] In this embodiment, the version number of the parameter is composed of a total version number and multiple sub-version numbers associated therewith. Each sub-version number corresponds to a parameter table, and this parameter table can be used to manage the change records and data of the corresponding parameters. When a parameter change occurs, the corresponding sub-version number will be updated, and at the same time, the total version number will be updated. A set of parameter versions can be jointly constituted by a total version number, multiple sub-version numbers associated therewith, and the corresponding parameters. Multiple sets of parameter versions can exist both in the database and in the memory.

[0040] In this embodiment, the update methods of the sub-version number and the total version number can be: when a parameter change occurs, control the corresponding sub-version number to be incremented by 1, and at the same time control the total version number to be incremented by 1. In this way, when a certain parameter changes, it can be confirmed that there is a parameter change through the total version number, and it can be confirmed which parameter has changed through the corresponding sub-version number. The above update methods of the sub-version number and the total version number can be applicable to both the database and the memory at the same time.

[0041] In one embodiment, as Figure 2 shown, the step S101 includes steps S201 to S205:

[0042] S201. Compare the total version number in the database with the total version number in the memory;

[0043] In this step, a parameter polling thread can check the parameter version of the database every predetermined time, for example, check it every 10s. The checking method can be to first compare the total version number in the database with the total version number in the memory. Since the parameters in the memory are loaded from the database, when the parameters in the database change and are loaded into the memory, the sub-version number and the total version number in the memory will be updated synchronously according to the aforementioned method. Therefore, it can be determined whether the parameters have changed according to whether the total version number in the database is the same as the total version number in the memory.

[0044] S202. If the total version number in the database is inconsistent with the total version number in the memory and the total version number in the database is higher than the total version number in the memory, confirm that the total version number in the database has been updated.

[0045] In this step, if the total version number in the database is inconsistent with the total version number in the memory, and the total version number in the database is higher than the total version number in the memory, it means that the total version number in the database has been updated due to parameter changes, but the update has not been loaded into the memory in time. Therefore, it can be confirmed that the total version number in the database has been updated.

[0046] If the total version number in the database is inconsistent with the total version number in the memory and the total version number in the database is lower than the total version number in the memory, this may be due to an exception in the previous loading process. Therefore, this situation is not considered a condition for the total version number in the database to be updated, that is, the loading action is not triggered.

[0047] If the total version number in the database is consistent with the total version number in the memory, it can be confirmed that the parameter version in the database has not changed, and the loading action is not triggered at this time.

[0048] S203. Obtain the sub-version numbers associated with the total version number in the database and having updates.

[0049] When the total version number in the database has been updated, it means that the associated sub-version numbers have been updated, that is, one or some parameters have changed. Therefore, the sub-version numbers associated with the total version number in the database and having updates can be obtained to confirm which parameter or parameters have changed.

[0050] As for the method of confirming whether the sub-version number has been updated, it is similar to that of the total version number, that is, comparing the sub-version numbers of each parameter in the database with the sub-version numbers of each parameter in the memory. If the sub-version number of a parameter in the database is inconsistent with the sub-version number of the corresponding parameter in the memory, and the sub-version number of the parameter in the database is higher than the sub-version number of the corresponding parameter in the memory, confirm that the sub-version number has been updated.

[0051] When the total version number in the database has been updated but the sub-version number has not been updated at all, there is no need to perform this loading and wait for the next polling.

[0052] S204. Load the parameters corresponding to the updated sub-version numbers into the memory.

[0053] Here, the parameters corresponding to the updated sub-version numbers in the database are loaded into the memory to upgrade the parameters in the memory. Since in the embodiments of the present invention, only the incrementally changed parameters are loaded each time, the instantaneous system pressure on the database caused by loading parameters in the system deployed in a cluster is effectively reduced, and short-term system performance problems are avoided.

[0054] S205. Update the sub-version number corresponding to the parameter loaded in the memory and update the total version number in the memory.

[0055] During the parameter loading process, the parameter version in the memory also needs to be updated according to the parameter version update method of the database, that is, update the sub-version number corresponding to the loaded parameter and update the total version number in the memory. In this way, the parameter version in the memory will be consistent with the parameter version in the database, which is convenient for comparing the total version number and the associated sub-version numbers in the database and the memory during the next polling.

[0056] In the embodiment of the present invention, every time the total version number is updated, record all the sub-version numbers corresponding to the total version number and establish a mapping relationship, so that each total version number has its own associated sub-version numbers.

[0057] In the embodiment of the present invention, the sub-version number corresponding to the loaded parameter will be updated during parameter loading. In order to facilitate subsequent steps such as parameter use and cleaning, the embodiment of the present invention can also copy the unloaded parameters and their corresponding sub-version numbers in the memory, and associate the updated total version number with the copied sub-version numbers and the aforementioned updated sub-version numbers. In this way, the updated total version number can be associated with brand-new and independent sub-version numbers and jointly form a set of parameter versions with the corresponding parameters. The parameter versions in the memory are independent of each other, forming multiple sets of parameter versions, and the parameter versions do not affect each other, which is convenient for different business threads to reference and clean up.

[0058] S102. After the parameter loading is completed, query the latest total version number and its associated sub-version numbers in the database, and compare them with the latest total version number and its associated sub-version numbers in the memory respectively. If they are inconsistent, roll back the parameter version corresponding to the latest total version number in the memory to the state before loading;

[0059] During a parameter loading process, another parameter change operation occurs simultaneously, which will cause the result of this loading to be inconsistent with the latest parameter version in the database, resulting in a system logic error. Therefore, this embodiment adopts consistency checking to solve the above problems, that is, compare the total version number and sub-version numbers in the database and the memory after the parameter loading is completed to check whether they are consistent. If they are inconsistent, the parameter version in the memory needs to be rolled back to the state before loading.

[0060] In one embodiment, as Figure 3 shown, the step S102 includes steps S301 to S302:

[0061] S301. After the parameter loading is completed, query the latest total version number in the database and compare it with the latest total version number in the memory. If they are inconsistent, roll back the parameter version corresponding to the latest total version number in the memory to the state before loading. If they are consistent, query the sub-version number associated with the latest total version number in the database;

[0062] After loading the parameters from the database into the memory, the total version number of the database can be queried again and compared with the total version number in the memory.

[0063] If the comparison result is consistent, it is necessary to further compare the sub-version numbers associated with these two total version numbers, because it is possible that due to other abnormal reasons, the total version number is updated while the sub-version number is not updated, so further comparison is required.

[0064] If the comparison result is inconsistent, it means that the total version number in the database is updated during the loading process, so the total version number in the memory is inconsistent with the total version number in the database. Therefore, the total version number in the memory, its sub-version number, and the corresponding parameters need to be rolled back to the state before loading so that the latest parameters can be reloaded during the next poll.

[0065] S302. Compare the sub-version number associated with the latest total version number in the database queried with the sub-version number associated with the latest total version number in the memory respectively. If they are inconsistent, roll back the parameter version corresponding to the latest total version number in the memory to the state before loading. If they are consistent, confirm that the current loading is successful.

[0066] If the comparison result is consistent, it can be confirmed that the current parameter loading process is successful.

[0067] If the comparison result is inconsistent, it means that during the current parameter loading process, the sub-version number in the database is updated again, and the parameters loaded in the memory are the version at the previous update. Therefore, the sub-version number in the memory is inconsistent with the sub-version number in the database. So, the total version number in the memory, its sub-version number, and the corresponding parameters need to be rolled back to the state before loading so that the latest parameters can be reloaded during the next poll.

[0068] Through the above parameter consistency check, the independence of different version parameters is ensured, and system problems caused by incorrect parameter loading are avoided.

[0069] S103. Detect the number of total version numbers in the memory. If the number of total version numbers in the memory exceeds the upper limit, clean up the parameter version corresponding to the oldest total version number in the memory;

[0070] During long-term operation of the application, new version parameters may be continuously loaded, which will cause the system memory to be occupied more and more. To avoid excessive memory occupation, this embodiment adds a parameter cache cleaning mechanism.

[0071] In one embodiment, as Figure 4 shown, step S103 includes steps S401 to S404:

[0072] S401. Preset the upper limit of the number of total version numbers;

[0073] During a business transaction, a timeout can be set for a single business transaction. Therefore, versions loaded outside a timeout can be cleared. For example, if the timeout is 10s and the polling interval is 10s, then at most 2 parameter loads may be triggered during a business transaction. Therefore, the upper limit can be set to 3. When the number of total version numbers in memory exceeds the upper limit, the parameter version corresponding to the oldest total version number can be cleared. The upper limit of the number of the above total version numbers actually refers to the upper limit of the number of parameter versions in memory.

[0074] S402. After a parameter load is successful, check the number of total version numbers in memory. If the number of total version numbers is greater than the upper limit, check whether there is a valid reference to the oldest total version number;

[0075] After a parameter load is successful and before making the parameters of the latest successfully loaded version take effect, the number of total version numbers in memory can be checked first, and the number of total version numbers can be compared with the preset upper limit. If the upper limit of the number of total version numbers is less than or equal to the number of total version numbers, no cleaning operation is required. If the upper limit of the number of total version numbers is greater than the number of total version numbers, the oldest total version number needs to be cleared to free up memory. Before clearing the oldest total parameter version number from memory, it is also necessary to check whether there is a valid reference to the oldest total version number, that is, whether the oldest total version number is being effectively referenced by a business thread.

[0076] Specifically, if the reference list of the oldest total version number is empty, it is confirmed that there is no valid reference to this total version number;

[0077] If the reference list of this total version number is not empty, but it is judged whether the reference has expired according to the reference timestamp. If all references have expired, it is confirmed that there is no valid reference to this total version number.

[0078] In one embodiment, as Figure 5 shown, the checking whether there is a valid reference to the oldest total version number includes steps S501 to S504:

[0079] S501. Obtain the reference timestamps of all threads that reference the oldest total version number;

[0080] S502. Compare the reference timestamp with the current time;

[0081] S503. When the difference between the reference timestamp and the current time is greater than the threshold, confirm that the corresponding thread is a failed reference.

[0082] S504. When the difference between the reference timestamp and the current time is less than or equal to the threshold, confirm that the corresponding thread is a valid reference.

[0083] In this embodiment, the reference timestamp of the thread that references the oldest total version number can be obtained first, and the reference timestamp is compared with the current time. If the time difference between the two is greater than the set threshold, it can be confirmed that the reference is invalid. Otherwise, confirm that the reference to the total version number is valid. The time length for a business thread to reference a total version number is limited. Starting from the establishment of the reference relationship, its time length does not exceed the set threshold. If it exceeds, it indicates that the reference is invalid.

[0084] S403. If there is no valid reference to the oldest total version number, clean up the parameter version corresponding to the oldest total version number.

[0085] After confirming that there is no valid reference, the GC mechanism (Garbage Collector) of the JVM (Java Virtual Machine) can be used to automatically perform garbage collection on the total version number, associated sub-version numbers, and their parameters (i.e., the parameter version corresponding to the oldest total version number) to achieve cleaning. This GC mechanism can improve the security of cleaning.

[0086] S404. After the cleaning is completed, control the parameters loaded this time to take effect.

[0087] After performing the above cleaning actions, the parameters loaded this time can be controlled to take effect. That is to say, when a business thread needs to use the parameters in memory next time, it can reference the updated total version number to use the latest parameters.

[0088] S104. When a business transaction occurs, obtain the latest total version number in memory, and control the thread of the business transaction to reference the latest total version number in memory until the business transaction ends.

[0089] Since business transactions may occur at any time, transactions cannot be aborted or made to wait because parameters are being loaded. In the embodiment of the present invention, the latest total version number is obtained from memory, and this total version number will be used as the total version number that is always used during the current business transaction. Suppose that during the current business transaction, parameter loading occurs, which does not affect the parameters used in the current business transaction, that is, the current business transaction will use the parameter version corresponding to the referenced total version number; and after the current business transaction ends, newly occurring business transactions can reference the newly updated total version number in memory.

[0090] In one embodiment, as Figure 6 shown, the step S104 includes steps S601 to S604:

[0091] S601. When a business transaction occurs, first obtain the latest total version number from the memory;

[0092] S602. Control the thread of the business transaction to reference the latest total version number in the memory;

[0093] S603. Obtain the sub-version number associated with the total version number;

[0094] S604. Take out the parameters from the corresponding parameter container according to the sub-version number and return them.

[0095] That is, when a business transaction occurs, the latest total version number in the memory will be obtained first, and the thread of the business transaction will always reference the obtained total version number. Then, according to the sub-version number associated with the total version number, the parameters will be taken out from the corresponding parameter container and returned for use. The parameter container is a Map (a collection of key-value pairs) for storing parameter objects. The key value is [parameter code + sub-version number], and the Value is an object containing all the data of a parameter table. Each time a parameter is loaded, a loaded parameter object (i.e., parameter data) will be put into this Map.

[0096] In one embodiment, the parameter incremental loading method further includes:

[0097] After the business transaction ends, remove the reference relationship between the thread of the business transaction and the corresponding total version number in the memory.

[0098] In this embodiment, after the business transaction ends, the reference relationship between the thread of the business transaction and the total version number can be removed. In this way, as the parameter version changes continuously, the current total version number may become the oldest total version number and needs to be cleared. Therefore, the reference relationship needs to be removed first.

[0099] The method of the embodiment of the present invention only loads incrementally changed parameters, effectively reducing the instantaneous system pressure on the database when the cluster-deployed system loads parameters, and avoiding short-term system performance problems; when a business transaction occurs, the total version number referenced by the thread of the business transaction does not change, ensuring transaction security; adopting a parameter cache cleaning mechanism avoids the problem of excessive memory occupation; adopting a consistency check mechanism avoids misloading parameters that do not belong to the current version.

[0100] The embodiment of the present invention also provides a parameter incremental loading device, which is used to execute any embodiment of the foregoing parameter incremental loading method. Specifically, please refer to Figure 7 , Figure 7It is a schematic block diagram of a parameter incremental loading device provided by an embodiment of the present invention. The parameter incremental loading device 700 can be configured in a server.

[0101] As Figure 7 shown, the parameter incremental loading device 700 includes an incremental loading unit 710, a consistency checking unit 720, a version cleaning unit 730, and a parameter reference unit 740.

[0102] The incremental loading unit 710 is configured to, when detecting an update to the total version number in the database, obtain the sub-version numbers associated with the total version number and having changes, and load the parameters corresponding to the changed sub-version numbers into the memory, and at the same time update the total version number and the associated sub-version numbers in the memory;

[0103] The consistency checking unit 720 is configured to, after the parameter loading is completed, query the latest total version number and its sub-version numbers in the database, and compare them with the latest total version number and its sub-version numbers in the memory respectively. If they are inconsistent, roll back the parameter version corresponding to the latest total version number in the memory to the state before loading;

[0104] The version cleaning unit 730 is configured to detect the number of total version numbers in the memory. If the number of total version numbers in the memory exceeds the upper limit, clean the parameter version corresponding to the oldest total version number in the memory;

[0105] The parameter reference unit 740 is configured to, when a business transaction occurs, obtain the latest total version number in the memory, and control the thread of the business transaction to reference the latest total version number in the memory until the business transaction ends.

[0106] In one embodiment, as Figure 8 shown, the incremental loading unit 710 includes:

[0107] A comparison unit 711 for comparing the total version number in the database with the total version number in the memory;

[0108] A database confirmation unit 712 for confirming that the total version number in the database has been updated if the total version number in the database is inconsistent with the total version number in the memory and the total version number in the database is higher than the total version number in the memory;

[0109] An extraction unit 713 for obtaining the sub-version numbers associated with the total version number in the database and having updates;

[0110] A loading unit 714 for loading the parameters corresponding to the updated sub-version numbers into the memory;

[0111] An update unit 715 for updating the sub-version numbers corresponding to the parameters loaded in the memory, and updating the total version number in the memory.

[0112] In one embodiment, as Figure 9 shown, the parameter reference unit 740 includes:

[0113] A total version number acquisition unit 741, configured to first acquire the latest total version number from the memory when a service transaction occurs;

[0114] A control reference unit 742, configured to control the thread of the service transaction to reference the latest total version number in the memory;

[0115] A sub-version number acquisition unit 743, configured to acquire the sub-version number associated with the total version number;

[0116] A parameter return unit 744, configured to take out and return the parameter from the corresponding parameter container according to the sub-version number.

[0117] In one embodiment, as Figure 10 shown, the consistency check unit 720 includes:

[0118] A total version number check unit 721, configured to, after the parameter loading is completed, query the latest total version number in the database and compare it with the latest total version number in the memory. If they are inconsistent, roll back the parameter version corresponding to the latest total version number in the memory to the state before loading. If they are consistent, query the sub-version number associated with the latest total version number in the database;

[0119] A sub-version number check unit 722, configured to respectively compare the sub-version number associated with the latest total version number in the database queried with the sub-version number associated with the latest total version number in the memory. If they are inconsistent, roll back the parameter version corresponding to the latest total version number in the memory to the state before loading. If they are consistent, confirm that the current loading is successful.

[0120] In one embodiment, as Figure 11 shown, the version cleanup unit 730 includes:

[0121] An upper limit preset unit 731, configured to preset the quantity upper limit of the total version number;

[0122] A reference check unit 732, configured to, after a parameter loading is successful, check the quantity of the total version numbers in the memory. If the quantity of the total version numbers is greater than the quantity upper limit, check whether there is a valid reference to the oldest total version number;

[0123] A cleanup unit 733, configured to, if there is no valid reference to the oldest total version number, clean up the parameter version corresponding to the oldest total version number;

[0124] An effective unit 734, configured to, after the cleanup is completed, control the parameters of the current loading to take effect.

[0125] In one embodiment, as Figure 12 shown, the reference checking unit 732 includes:

[0126] A timestamp obtaining unit 7321, configured to obtain the reference timestamps of all threads that reference the oldest total version number;

[0127] A time comparison unit 7322, configured to compare the reference timestamp with the current time;

[0128] An invalidation confirmation unit 7323, configured to confirm that the corresponding thread is an invalid reference when the difference between the reference timestamp and the current time is greater than a threshold;

[0129] A validity confirmation unit 7324, configured to confirm that the corresponding thread is a valid reference when the difference between the reference timestamp and the current time is less than or equal to the threshold.

[0130] In one embodiment, the parameter incremental loading device 700 further includes:

[0131] A reference removal unit, configured to remove the reference relationship between the thread of the service transaction and the corresponding total version number in the memory after the service transaction ends.

[0132] The device according to the embodiment of the present invention only loads incrementally changed parameters, effectively reducing the instantaneous system pressure on the database when the system in the cluster deployment loads parameters, and avoiding short-term system performance problems; when a service transaction occurs, the total version number referenced by the thread of the service transaction does not change, ensuring transaction security; adopting a parameter cache cleaning mechanism avoids the problem of excessive memory occupation; adopting a consistency check mechanism avoids misloading parameters that do not belong to the current version.

[0133] The above-mentioned parameter incremental loading device can be implemented in the form of a computer program, and this computer program can run on a computer device as Figure 13 shown.

[0134] Please refer to Figure 13 , Figure 13 which is a schematic block diagram of the computer device provided by the embodiment of the present invention. The computer device 800 may be a server, and the server may be an independent server or a server cluster composed of multiple servers.

[0135] Referring to Figure 13 , this computer device 800 includes a processor 802, a memory, and a network interface 805 connected through a system bus 801. Among them, the memory may include a non-volatile storage medium 803 and an internal memory 804.

[0136] The non-volatile storage medium 803 can store an operating system 8031 and a computer program 8032. When the computer program 8032 is executed, it can cause the processor 802 to execute a parameter incremental loading method.

[0137] The processor 802 is used to provide computing and control capabilities to support the operation of the entire computer device 800.

[0138] The internal memory 804 provides an environment for the operation of the computer program 8032 in the non-volatile storage medium 803. When the computer program 8032 is executed by the processor 802, it can cause the processor 802 to execute a parameter incremental loading method.

[0139] The network interface 805 is used for network communication, such as providing the transmission of data information, etc. Those skilled in the art can understand that Figure 13 The structure shown in is only a block diagram of some structures related to the solution of the present invention, and does not constitute a limitation on the computer device 800 to which the solution of the present invention is applied. The specific computer device 800 may include more or fewer components than those shown in the figure, or combine some components, or have different component arrangements.

[0140] Among them, the processor 802 is used to run the computer program 8032 stored in the memory to implement the following functions: when it is detected that the total version number in the database is updated, obtain the sub-version numbers associated with the total version number and that have changed, and load the parameters corresponding to the changed sub-version numbers into the memory, and at the same time update the total version number and the associated sub-version numbers in the memory; after the parameter loading is completed, query the latest total version number and its associated sub-version numbers in the database, and compare them with the latest total version number and its associated sub-version numbers in the memory respectively. If they are inconsistent, roll back the parameter version corresponding to the latest total version number in the memory to the state before loading; detect the number of total version numbers in the memory. If the number of total version numbers in the memory exceeds the upper limit, clean up the parameter version corresponding to the oldest total version number in the memory; when a business transaction occurs, obtain the latest total version number in the memory, and control the thread of the business transaction to reference the latest total version number in the memory until the business transaction ends.

[0141] In one embodiment, when the processor 802 executes the step of, when detecting an update to the total version number in the database, obtaining the sub-version numbers associated with the total version number that have changed, loading the parameters corresponding to the changed sub-version numbers into the memory, and simultaneously updating the total version number and the associated sub-version numbers in the memory, the following operations are performed: comparing the total version number in the database with the total version number in the memory; if the total version number in the database is inconsistent with the total version number in the memory and the total version number in the database is higher than the total version number in the memory, it is confirmed that the total version number in the database has been updated; obtaining the sub-version numbers associated with the total version number in the database that have been updated; loading the parameters corresponding to the updated sub-version numbers into the memory; updating the sub-version numbers corresponding to the parameters loaded in the memory, and updating the total version number in the memory.

[0142] In one embodiment, when the processor 802 executes the step of, when a business transaction occurs, obtaining the latest total version number in the memory and controlling the thread of the business transaction to reference the latest total version number in the memory until the business transaction ends, the following operations are performed: when the business transaction occurs, first obtain the latest total version number from the memory; control the thread of the business transaction to reference the latest total version number in the memory; obtain the sub-version numbers associated with the total version number; and retrieve the parameters from the corresponding parameter container according to the sub-version numbers and return them.

[0143] In one embodiment, when the processor 802 executes the step of, after the parameter loading is completed, querying the latest total version number and its associated sub-version numbers in the database, and comparing them with the latest total version number and its associated sub-version numbers in the memory respectively, and if they are inconsistent, rolling back the parameter version corresponding to the latest total version number in the memory to the state before loading, the following operations are performed: after the parameter loading is completed, query the latest total version number in the database and compare it with the latest total version number in the memory. If they are inconsistent, roll back the parameter version corresponding to the latest total version number in the memory to the state before loading. If they are consistent, query the sub-version numbers associated with the latest total version number in the database; compare the queried sub-version numbers associated with the latest total version number in the database with the sub-version numbers associated with the latest total version number in the memory respectively. If they are inconsistent, roll back the parameter version corresponding to the latest total version number in the memory to the state before loading. If they are consistent, it is confirmed that the current loading is successful.

[0144] In one embodiment, when the processor 802 executes the step of detecting the total number of version numbers in the memory and cleaning the parameter version corresponding to the oldest total version number in the memory if the total number of version numbers in the memory exceeds the upper limit, the following operations are performed: preset the upper limit of the total number of version numbers; after a parameter loading is successful, check the total number of version numbers in the memory. If the total number of version numbers is greater than the upper limit, check whether there is a valid reference to the oldest total version number; if there is no valid reference to the oldest total version number, clean the parameter version corresponding to the oldest total version number; after the cleaning is completed, control the parameters loaded this time to take effect.

[0145] In one embodiment, when the processor 802 executes the step of checking whether there is a valid reference to the oldest total version number, the following operations are performed: obtain the reference timestamps of all threads that reference the oldest total version number; compare the reference timestamps with the current time; when the difference between the reference timestamp and the current time is greater than the threshold, confirm that the corresponding thread is an invalid reference; when the difference between the reference timestamp and the current time is less than or equal to the threshold, confirm that the corresponding thread is a valid reference.

[0146] In one embodiment, the processor 802 is used to run the computer program 8032 stored in the memory and also implements the following function: after a business transaction ends, remove the reference relationship between the thread of the business transaction and the corresponding total version number in the memory.

[0147] Those skilled in the art can understand that Figure 13 the embodiments of the computer device shown in Figure 13 do not constitute a limitation on the specific composition of the computer device. In other embodiments, the computer device may include more or fewer components than shown in the figure, or combine some components, or have different component arrangements. For example, in some embodiments, the computer device may only include a memory and a processor. In such an embodiment, the structures and functions of the memory and the processor are the same as those in

[0148] It should be understood that in the embodiments of the present invention, the processor 802 may be a central processing unit (CPU), and the processor 802 may also be other general-purpose processors, digital signal processors (DSPs), application specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.

[0149] In another embodiment of the present invention, a computer-readable storage medium is provided. The computer-readable storage medium may be a non-volatile computer-readable storage medium. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the following steps are implemented: when it is detected that the total version number in the database is updated, obtain the sub-version numbers associated with the total version number and having changes, and load the parameters corresponding to the changed sub-version numbers into the memory, and at the same time update the total version number and the associated sub-version numbers in the memory; after the parameter loading is completed, query the latest total version number and its associated sub-version numbers in the database, and compare them with the latest total version number and its associated sub-version numbers in the memory respectively. If they are inconsistent, roll back the parameter version corresponding to the latest total version number in the memory to the state before loading; detect the number of total version numbers in the memory. If the number of total version numbers in the memory exceeds the upper limit, clean up the parameter version corresponding to the oldest total version number in the memory; when a business transaction occurs, obtain the latest total version number in the memory, and control the thread of the business transaction to reference the latest total version number in the memory until the business transaction ends.

[0150] In one embodiment, the step of when it is detected that the total version number in the database is updated, obtain the sub-version numbers associated with the total version number and having changes, and load the parameters corresponding to the changed sub-version numbers into the memory, and at the same time update the total version number and the associated sub-version numbers in the memory includes: comparing the total version number in the database with the total version number in the memory; if the total version number in the database is inconsistent with the total version number in the memory and the total version number in the database is higher than the total version number in the memory, it is confirmed that the total version number in the database is updated; obtain the sub-version numbers associated with the total version number in the database and having updates; load the parameters corresponding to the updated sub-version numbers into the memory; update the sub-version numbers corresponding to the parameters loaded in the memory, and update the total version number in the memory.

[0151] In one embodiment, when a business transaction occurs, obtain the latest total version number in the memory, and control the thread of the business transaction to reference the latest total version number in the memory until the business transaction ends, including: when a business transaction occurs, first obtain the latest total version number from the memory; control the thread of the business transaction to reference the latest total version number in the memory; obtain the sub-version number associated with the total version number; and retrieve and return the parameters from the corresponding parameter container according to the sub-version number.

[0152] In one embodiment, after the parameter loading is completed, query the latest total version number and its associated sub-version number in the database, and compare them with the latest total version number and its associated sub-version number in the memory respectively. If they are inconsistent, roll back the parameter version corresponding to the latest total version number in the memory to the state before loading, including: after the parameter loading is completed, query the latest total version number in the database and compare it with the latest total version number in the memory. If they are inconsistent, roll back the parameter version corresponding to the latest total version number in the memory to the state before loading. If they are consistent, query the sub-version number associated with the latest total version number in the database; compare the sub-version number associated with the latest total version number in the database retrieved with the sub-version number associated with the latest total version number in the memory respectively. If they are inconsistent, roll back the parameter version corresponding to the latest total version number in the memory to the state before loading. If they are consistent, confirm that the current loading is successful.

[0153] In one embodiment, detect the number of total version numbers in the memory. If the number of total version numbers in the memory exceeds the upper limit, clean up the parameter version corresponding to the oldest total version number in the memory, including: preset the upper limit of the number of total version numbers; after a parameter loading is successful, check the number of total version numbers in the memory. If the number of total version numbers is greater than the upper limit, check whether there is a valid reference to the oldest total version number; if there is no valid reference to the oldest total version number, clean up the parameter version corresponding to the oldest total version number; after the cleanup is completed, control the parameters of the current loading to take effect.

[0154] In one embodiment, the method for checking whether there is a valid reference to the oldest total version number includes: obtaining the reference timestamps of all threads that reference the oldest total version number; comparing the reference timestamps with the current time; when the difference between the reference timestamp and the current time is greater than the threshold, confirm that the corresponding thread is an invalid reference; when the difference between the reference timestamp and the current time is less than or equal to the threshold, confirm that the corresponding thread is a valid reference.

[0155] In one embodiment, when the computer program is executed by a processor, the following steps are implemented: after the business transaction ends, remove the reference relationship between the thread of the business transaction and the corresponding total version number in the memory.

[0156] Those skilled in the art can clearly understand that, for the convenience and conciseness of description, the specific working processes of the devices, apparatuses, and units described above can refer to the corresponding processes in the foregoing method embodiments and will not be elaborated herein. Those of ordinary skill in the art can realize that the units and algorithm steps of the examples described in combination with the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of each example have been generally described according to functions in the above description. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Professional technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present invention.

[0157] In several embodiments provided by the present invention, it should be understood that the disclosed devices, apparatuses, and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods, or units with the same function can be aggregated into one unit. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the couplings, direct couplings, or communication connections shown or discussed among each other can be indirect couplings or communication connections through some interfaces, devices, or units, and can also be in the form of electrical, mechanical, or other connections.

[0158] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they can be located in one place or distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiments of the present invention.

[0159] In addition, the functional units in each embodiment of the present invention can be integrated into one processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above integrated units can be implemented in the form of hardware or in the form of software functional units.

[0160] When the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a storage medium. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard disks, read-only memories (ROMs), magnetic disks, or optical discs.

[0161] As described above, the above is only the specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art within the technical scope disclosed by the present invention can easily think of various equivalent modifications or substitutions, and these modifications or substitutions should all be covered within the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims

1. A method for incrementally loading parameters, characterized in that, Including: When it is detected that the total version number in the database is updated, obtain the sub-version numbers associated with the total version number that have changed, load the parameters corresponding to the changed sub-version numbers into the memory, and at the same time update the total version number and the associated sub-version numbers in the memory; After the parameter loading is completed, query the latest total version number and its associated sub-version numbers in the database, and compare them with the latest total version number and its associated sub-version numbers in the memory respectively. If they are inconsistent, roll back the parameter version corresponding to the latest total version number in the memory to the state before loading; Detect the number of total version numbers in the memory. If the number of total version numbers in the memory exceeds the upper limit, clean up the parameter version corresponding to the oldest total version number in the memory; When a business transaction occurs, obtain the latest total version number in the memory, and control the thread of the business transaction to reference the latest total version number in the memory until the business transaction ends; The detecting the number of total version numbers in the memory. If the number of total version numbers in the memory exceeds the upper limit, then clean up the parameter version corresponding to the oldest total version number in the memory, including: presetting the upper limit of the number of total version numbers; when a parameter loading is successful once, check the number of total version numbers in the memory. If the number of total version numbers is greater than the upper limit, check whether there is a valid reference to the oldest total version number; if there is no valid reference to the oldest total version number, then clean up the parameter version corresponding to the oldest total version number; after the cleaning is completed, control the parameters loaded this time to take effect; The checking whether there is a valid reference to the oldest total version number includes: obtaining the reference timestamps of all threads that reference the oldest total version number; comparing the reference timestamps with the current time; when the difference between the reference timestamp and the current time is greater than the threshold, confirm that the corresponding thread is an invalid reference; when the difference between the reference timestamp and the current time is less than or equal to the threshold, confirm that the corresponding thread is a valid reference.

2. The parameter incremental loading method according to claim 1, wherein The when it is detected that the total version number in the database is updated, obtain the sub-version numbers associated with the total version number that have changed, and load the parameters corresponding to the changed sub-version numbers into the memory, and at the same time update the total version number and the associated sub-version numbers in the memory, including: Compare the total version number in the database with the total version number in the memory; If the total version number in the database is inconsistent with the total version number in the memory and the total version number in the database is higher than the total version number in the memory, confirm that the total version number in the database is updated; Obtain the sub-version numbers associated with the total version number in the database that have been updated; Load the parameters corresponding to the updated sub-version numbers into the memory; Update the sub-version numbers corresponding to the parameters loaded in the memory, and update the total version number in the memory.

3. The parameter incremental loading method according to claim 1, wherein The when a business transaction occurs, obtain the latest total version number in the memory, and control the thread of the business transaction to reference the latest total version number in the memory until the business transaction ends, including: When a business transaction occurs, first obtain the latest total version number from the memory; Control the thread of the business transaction to reference the latest total version number in the memory; Obtain the sub-version number associated with the total version number; Retrieve the parameters from the corresponding parameter container according to the sub-version number and return them.

4. The parameter incremental loading method according to claim 1, characterized in that After the parameter loading is completed, query the latest total version number and its associated sub-version number in the database, and compare them with the latest total version number and its associated sub-version number in the memory respectively. If they are inconsistent, roll back the parameter version corresponding to the latest total version number in the memory to the state before loading, including: After the parameter loading is completed, query the latest total version number in the database and compare it with the latest total version number in the memory. If they are inconsistent, roll back the parameter version corresponding to the latest total version number in the memory to the state before loading. If they are consistent, query the sub-version number associated with the latest total version number in the database; Compare the sub-version number associated with the latest total version number in the database retrieved with the sub-version number associated with the latest total version number in the memory respectively. If they are inconsistent, roll back the parameter version corresponding to the latest total version number in the memory to the state before loading. If they are consistent, confirm that the current loading is successful.

5. The parameter incremental loading method according to claim 1, wherein It also includes: After the business transaction ends, remove the reference relationship between the thread of the business transaction and the corresponding total version number in the memory.

6. A parameter incremental loading device, characterized in that, It includes: An incremental loading unit, which is used to obtain the sub-version numbers associated with and changed by the total version number when it detects that the total version number in the database is updated, load the parameters corresponding to the changed sub-version numbers into the memory, and update the total version number and the associated sub-version number in the memory at the same time; A consistency check unit, which is used to query the latest total version number and its sub-version number in the database after the parameter loading is completed, and compare them with the latest total version number and its sub-version number in the memory respectively. If they are inconsistent, roll back the parameter version corresponding to the latest total version number in the memory to the state before loading; A version cleaning unit, which is used to detect the number of total version numbers in the memory. If the number of total version numbers in the memory exceeds the upper limit, clean the parameter version corresponding to the oldest total version number in the memory; A parameter reference unit, which is used to obtain the latest total version number in the memory when a business transaction occurs, and control the thread of the business transaction to reference the latest total version number in the memory until the business transaction ends; The version cleaning unit includes: An upper limit preset unit, which is used to preset the upper limit of the number of total version numbers; A reference check unit, which is used to check the number of total version numbers in the memory after a successful parameter loading. If the number of total version numbers is greater than the upper limit, check whether there is a valid reference to the oldest total version number; A cleaning unit, which is used to clean the parameter version corresponding to the oldest total version number if there is no valid reference to the oldest total version number; An effective unit, which is used to control the parameters of the current loading to take effect after the cleaning is completed; The reference check unit includes: A timestamp acquisition unit, which is used to obtain the reference timestamps of all threads that reference the oldest total version number; A time comparison unit, which is used to compare the reference timestamp with the current time; An invalidation confirmation unit, which is used to confirm that the corresponding thread is an invalid reference when the difference between the reference timestamp and the current time is greater than the threshold; An effective confirmation unit, configured to confirm that the corresponding thread is an effective reference when the difference between the reference timestamp and the current time is less than or equal to a threshold value.

7. A computer device, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the parameter incremental loading method according to any one of claims 1 to 5.

8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, it implements the parameter incremental loading method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Method, device, apparatus and system for updating local cache

    CN109388764A

  • Method and device for pushing and updating cache data

    CN109450977A