Management record control methods, devices, storage media and electronic equipment
By setting up a request-exclusive lock mechanism in the virtual item management system, the problem of concurrent conflicts in virtual item management records across multiple time dimensions is solved, ensuring accurate circulation and rigorous status changes of virtual items and avoiding frequent issues.
Patent Information
- Application Number
- CN202211130668.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-16
- Publication Date
- 2026-01-30
- Estimated Expiration
- 2042-09-16
AI Technical Summary
In the management of virtual items across multiple time dimensions, existing technologies struggle to effectively prevent the occurrence of multiple or fewer virtual items due to conflicts in management records, especially in scenarios with concurrent operations where management chaos is severe.
By setting up an exclusive lock mechanism, querying mapping records and obtaining task status, and controlling the status changes of virtual item management records, multiple occurrences are avoided in concurrent situations.
This effectively avoids management chaos caused by concurrent operations, ensures the accurate circulation of virtual items, and prevents the problem of multiple virtual items.
Smart Images

Figure CN115510028B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] Embodiments of the present application relate to the technical field of computer, and particularly relate to a management record control method and device, a storage medium and an electronic device. BACKGROUND
[0002] With the continuous development of the network world, the circulation management of virtual goods becomes more and more important. The virtual goods management platform can provide virtual goods management services for users in multiple time dimensions, but this also leads to a significant increase in virtual goods management difficulty, and also leads to problems such as virtual goods shortage and oversupply. In the process of virtual goods management, the support for concurrent operations of management records is also increasing, but multiple concurrency may also lead to management record conflicts, and such management record conflicts have become increasingly prominent in multi-time dimension management scenarios, further exacerbating the problems of virtual goods shortage and oversupply. SUMMARY
[0003] To solve at least one of the above technical problems, embodiments of the present application provide a management record control method and device, a storage medium and an electronic device.
[0004] In one aspect, the present application provides a management record control method, which comprises:
[0005] In the case of needing to change the state of a first record, a mapping record is queried, the mapping record being a record having the same primary key as the first record and having the same target time period, and the first record being a management record for recording the quantity information of virtual goods associated by a target object in a target time period;
[0006] In the case of querying the mapping record, a request exclusive lock corresponding to the mapping record is queried, the request exclusive lock being used to prevent other threads except the takeover thread of the request exclusive lock from processing the record having the same primary key as the mapping record;
[0007] In the case of the request exclusive lock existing and the lock duration of the request exclusive lock being greater than a first time threshold, a record state corresponding to the mapping record is obtained;
[0008] According to the record state, the state change of the first record is controlled.
[0009] In one embodiment, before the record state corresponding to the mapping record is obtained, the method further comprises:
[0010] In the case of the task corresponding to the mapping record being successfully created, a task identifier is generated;
[0011] An association relationship between the task identifier and the mapping record is established.
[0012] The obtaining the record state corresponding to the mapping record comprises:
[0013] The task identifier corresponding to the mapping record is determined according to the association relationship;
[0014] The task state of the task corresponding to the mapping record is obtained by calling an asynchronous state query interface based on the task identifier;
[0015] The task state is taken as the record state corresponding to the mapping record.
[0016] In one embodiment, the controlling the first record to change the state according to the record state comprises:
[0017] In the case where the record state represents that the task is executed, the first record is changed in state based on a locking interaction mechanism;
[0018] In the case where the record state represents that the task is not executed, it is judged whether the locking duration is greater than a second duration threshold, and the first record is changed in state according to the judgment result.
[0019] In one embodiment, the controlling the first record to change the state according to the judgment result comprises:
[0020] In the case where the locking duration is less than or equal to the second duration threshold, it is prompted that the state change of the first record fails;
[0021] In the case where the locking duration is greater than the second duration threshold, the first record is changed in state based on the locking interaction mechanism.
[0022] In one embodiment, the changing the first record in state based on the locking interaction mechanism comprises:
[0023] The request exclusive lock is taken over, and the locking time corresponding to the request exclusive lock is reset;
[0024] In the case where the request exclusive lock is reset, the first record is changed in state;
[0025] In the case where the state change succeeds, the request exclusive lock is deleted.
[0026] In one embodiment, the method further comprises:
[0027] In the case where the request exclusive lock exists and the locking duration of the request exclusive lock is less than or equal to the first duration threshold, it is prompted that the state change of the first record fails.
[0028] In one embodiment, the method further comprises:
[0029] In the case where the mapping record is not queried, adding a request exclusive lock to the first record, performing state change on the first record, and in the case where the state change succeeds, deleting the request exclusive lock.
[0030] In another aspect, an embodiment of the present application provides a management record control device, the device comprising:
[0031] A mapping record querying module, configured to, in the case where state change is needed on a first record, query a mapping record, the mapping record being a record having the same primary key as the first record and having the same target time period, the first record being a management record used to record quantity information of virtual items associated by a target object in a target time period;
[0032] A request exclusive lock querying module, configured to, in the case where the mapping record is queried, query a request exclusive lock corresponding to the mapping record, the request exclusive lock being used to prevent threads other than a takeover thread removing the request exclusive lock from processing a record having the same primary key as the mapping record;
[0033] A record control module, configured to, in the case where the request exclusive lock exists and a lock duration of the request exclusive lock is greater than a first duration threshold, acquire a record state corresponding to the mapping record; and control the first record to perform state change according to the record state.
[0034] In one embodiment, the record control module is configured to perform the following operations:
[0035] In the case where task creation corresponding to the mapping record succeeds, generating a task identifier;
[0036] Establishing an association between the task identifier and the mapping record;
[0037] Determining the task identifier corresponding to the mapping record according to the association;
[0038] Calling an asynchronous state querying interface based on the task identifier to obtain a task state of a task corresponding to the mapping record;
[0039] Taking the task state as the record state corresponding to the mapping record.
[0040] In one embodiment, the record control module is configured to perform the following operations:
[0041] In the case where the record state indicates that a task is executed, performing state change on the first record based on a lock interaction mechanism.
[0042] In a case where the record state characterization task is not executed completely, it is judged whether the locking duration is greater than a second duration threshold, and the first record is controlled to change state according to a judgment result.
[0043] In an embodiment, the record control module is configured to perform the following operation:
[0044] In a case where the locking duration is less than or equal to the second duration threshold, it is prompted that the state change of the first record fails.
[0045] In a case where the locking duration is greater than the second duration threshold, the first record is changed state based on a locking interaction mechanism.
[0046] In an embodiment, the record control module is configured to perform the following operation:
[0047] The request exclusive lock is taken over, and a locking time corresponding to the request exclusive lock is reset.
[0048] In a case where the request exclusive lock is reset completely, the first record is changed state.
[0049] In a case where the state change succeeds, the request exclusive lock is deleted.
[0050] In an embodiment, the record control module is configured to perform the following operation:
[0051] In a case where the request exclusive lock exists and a locking duration of the request exclusive lock is less than or equal to the first duration threshold, it is prompted that the state change of the first record fails.
[0052] In an embodiment, the record control module is configured to perform the following operation:
[0053] In a case where the mapping record is not queried, a request exclusive lock is added to the first record, the first record is changed state, and in a case where the state change succeeds, the request exclusive lock is deleted.
[0054] On the other hand, an embodiment of the present application provides a computer readable storage medium, wherein at least one instruction or at least one program is stored in the computer readable storage medium, and the at least one instruction or at least one program is loaded and executed by a processor to implement the above-mentioned record management control method.
[0055] In another aspect, the embodiments of the present application provide an electronic device, comprising at least one processor, and a memory connected with the at least one processor in communication; wherein the memory stores instructions executable by the at least one processor, and the at least one processor implements the above-mentioned management record control method by executing the instructions stored in the memory.
[0056] In another aspect, the embodiments of the present application provide a computer program product, comprising a computer program or instructions, which, when executed by a processor, implement the above-mentioned management record control method.
[0057] The embodiments of the present application provide a management record control method, in the case of management record state control, by setting a request exclusive lock, to avoid management confusion caused by concurrent operation, further ensure the rigor of management record state change from the perspective of concurrent control, thereby avoiding multiple virtual goods. Specifically, in the process of management record control based on the request exclusive lock, not only the setting time of the request exclusive lock is considered, but also the task state of the task associated with the request exclusive lock, thereby greatly reducing the management confusion caused by forced unlocking, while ensuring that reasonable state changes can be smoothly implemented. BRIEF DESCRIPTION OF DRAWINGS
[0058] In order to more clearly illustrate the technical solutions and advantages of the embodiments of the present application or related technologies, the following will briefly introduce the drawings needed to be used in the embodiments or related technology descriptions. Obviously, the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other drawings can be obtained without creative labor based on these drawings.
[0059] Figure 1 is a flowchart of the basic scheme of the management record control provided by the embodiments of the present application;
[0060] Figure 2 is a flowchart of the management record control method provided by the embodiments of the present application;
[0061] Figure 3 is a flowchart of the state change of the first record based on the locking interaction mechanism provided by the embodiments of the present application;
[0062] Figure 4 is a block diagram of the management record control device provided by the embodiments of the present application;
[0063] Figure 5 is a hardware structure diagram of a device for implementing the method provided by the embodiments of the present application. DETAILED DESCRIPTION
[0064] The technical solutions in the embodiments of the present application will be described clearly and completely in connection with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the embodiments of the present application, all other embodiments obtained by a person of ordinary skill in the art without creative work belong to the protection scope of the embodiments of the present application.
[0065] It should be noted that the terms "first", "second" and the like in the description and claims of the present application and the above drawings are used to distinguish similar objects, and do not necessarily indicate a specific order or a chronological sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product or server including a series of steps or units does not necessarily have to include only those steps or units clearly listed, but can include other steps or units not clearly listed or inherent to the process, method, product or device.
[0066] In order to make the purposes, technical solutions and advantages of the present application more clear, the embodiments of the present application will be further described in detail below in connection with the drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application, and do not limit the present application.
[0067] Hereinafter, the terms "first", "second" are only used for description purposes, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of indicated technical features. Therefore, the features defined with "first", "second" can explicitly or implicitly include one or more features. In the description of the present embodiment, unless otherwise specified, the meaning of "a plurality of" is two or more.
[0068] The present application provides a management record control method, which is applied to a virtual item management end. For the application scenario of the virtual item management end, the present application is described as follows.
[0069] The virtual item management end, as an intermediate management platform, can communicate with the electronic device held by the user (including the client logging in the user account) and the task publishing platform respectively, thereby decoupling the function of the task publishing platform, so that the task publishing platform does not need to manage virtual items.
[0070] The task publishing platform in the embodiments of the present application can be considered as any task publishing platform accessing the virtual item management terminal, or can be considered as any task publishing platform subscribing to the virtual item management service of the virtual item management terminal. For example, the task publishing platform can be a server of a game program, which can publish game tasks to users, but the users can obtain virtual item rewards in the game tasks through the virtual item management terminal in the embodiments of the present application, and the server can decouple the management function related to the virtual item rewards in the game tasks. For another example, the task publishing platform can be a server of a live broadcast program, which can publish live broadcast tasks to users, but the users can obtain virtual item rewards in the live broadcast tasks through the virtual item management terminal in the embodiments of the present application, and the server can decouple the management function related to the virtual item rewards in the live broadcast tasks. The embodiments of the present application do not limit the type and quantity of the accessed task publishing platform.
[0071] The target object in the embodiments of the present application can be understood as a virtual object corresponding to a user performing a task in any of the above task publishing platforms. The target object is supposed to obtain virtual items published by the task publishing platform as rewards by performing the task, but the virtual items in the embodiments of the present application can be issued by the virtual item management terminal, that is, the task publishing platform can entrust the virtual item management terminal to issue by means of signing a service agreement.
[0072] It should be noted that the virtual item management terminal in the embodiments of the present application can provide different time dimension issuing services for the target object, for example, the virtual item issuing service can be performed according to the behavior performance of the target object in the task publishing platform on a weekly or monthly basis, thereby supporting virtual item distribution in multiple time dimensions and meeting the user's demand for obtaining virtual items in multiple time dimensions, for example, the virtual item management terminal can distribute a part of virtual items to the user on a weekly basis, and at the same time, another part of virtual items can be distributed to the user on a monthly basis, thereby meeting the user's demand for obtaining virtual items in multiple time dimensions.
[0073] However, the satisfaction of the demand for obtaining virtual items in multiple time dimensions brings difficulties in virtual item management, that is, this function brings difficulties in the state management of virtual item management records. If the state of the virtual item management record cannot be accurately managed, multiple virtual items may be distributed.
[0074] For example, based on the behavior performance information of an object A from August 7 to August 13, a virtual item with a value of 500 virtual coins is distributed to the object A in the corresponding "week". Of course, the virtual item management terminal corresponds to a record, that is, record 1. It is assumed that the state of record 1 is state 1, which represents that the virtual item in record 1 has been distributed.
[0075] When the virtual items are issued monthly in the month, the performance information of object A in August is integrated, and a virtual item with a value of 5000 virtual coins should be issued to object A. Of course, the virtual item management end corresponds to a record, that is, record 2. It is assumed that the state of record 2 at this time is state 2, indicating that the virtual item in record 2 has not been issued.
[0076] When determining the virtual items that should be issued in August based on record 1 and record 2 and their respective states, 5000-500=4500 virtual items should be issued normally. However, since the order of generation of record 1 and record 2 is not unique, and the change order of the states of record 1 and record 2 cannot be preset in advance, it leads to the fact that the total amount of virtual items determined based on record 1 and record 2 and their respective states may not be accurate, thereby causing over-issuing.
[0077] For example, it is assumed that record 1 is generated first, but since the virtual item with a value of 500 virtual coins has not been issued, the state of record 1 is not state 1. In this case, record 2 is obtained, and the virtual items required in record 1 and the virtual items required in record 2 will be issued, that is, 5000+500=5500 virtual items are issued, resulting in over-issuing.
[0078] In order to solve the difficulty in state management of virtual item management records caused by the virtual item acquisition function in multiple time dimensions, ensure that virtual items are not over-issued, and realize accurate circulation of virtual items, the states of related management records can be strictly controlled. The embodiment of the application provides a state control method, which can avoid over-issuing under the control of the method. The method can also be regarded as a basic scheme for management record control in the embodiment of the application, as shown in Figure 1 , which includes:
[0079] S101. In the case of receiving a state change request for a first record, determining target period information of the first record, and the first record being a management record for recording the quantity information of virtual items associated with a target object in a target time period.
[0080] The embodiment of the application supports state conversion of management records in multiple time dimensions. For example, it can support week dimension and month dimension. If the target period information represents week dimension, the first record records the quantity information of virtual items in a week. If the target period information represents month dimension, the first record records the quantity information of virtual items in a month.
[0081] S102. In the case where the target period information represents a first type of period, the state of the first record is changed, and the first type of period is the smallest time period for generating a management record.
[0082] The first type of period in the embodiments of the present application is the minimum time period for generating the management record. Taking the virtual item management end that can support week dimension and month dimension as an example, the first type of period is “week”. For the first record related to such a period, the state change can be directly performed on the above-mentioned first record. Because the embodiments of the present application avoid the multiple sending problem from the virtual item sending link in the non-minimum period, the virtual item sending in the minimum period is not limited, and the item sending in the minimum period can be directly performed. This scheme reduces the influence of state management on the item sending link in the minimum period, and ensures that the virtual item sending can be performed in each period and the multiple sending problem does not occur finally.
[0083] S103. In the case that the target time period information represents the second type of period, all second records associated with the first record are queried, each time period corresponding to each second record is located in the target time period, and each time period information corresponding to each second record is the first type of period, and the second type of period includes a plurality of first type of periods.
[0084] The second type of period is obviously a non-minimum time period. Taking the virtual item management end that can support week dimension and month dimension as an example, the second type of period is “month”. First, the records related to each “week” in the month, i.e. all second records, can be queried.
[0085] S104. In the case that the first record is not associated with any second record, the state change of the first record is performed.
[0086] If the first record is not associated with any second record, it means that the virtual item is not paid by week in the month, and then the multiple sending caused by the virtual item payment by week does not occur, and the virtual item can be sent by month dimension based on the first record, and the multiple sending does not occur.
[0087] In the embodiments of the present application, the state change of the first record can be considered as the state change of the first record under the condition that the multiple sending is ensured not to occur. Because the state change of the first record in the embodiments of the present application is directly related to the virtual item sending, the state change in the embodiments of the present application is strictly managed to ensure that the multiple sending of the virtual item does not occur.
[0088] S105. In the case that all second records associated with the first record are in the first state, the state change of the first record is performed; the first state represents that the virtual item associated in the corresponding second record has been sent to the target object.
[0089] If there are second records that may need to be paid in the week, that is, if these second records are all in the first state, that is, the virtual items in these second records are all paid in the weekly dimension, when the virtual items are paid in the month, only the virtual items paid in advance need to be deducted, and no more will be generated. In this case, the first record can also be changed.
[0090] S106. In the presence of a target second record, no state change is made to the first record. The target second record is a second record that is not in the first state.
[0091] If there are second records (target second records) that are not in the first state, it means that the virtual items in the target second records are ready to be issued in the weekly dimension, but this action has not been implemented. Then, after the virtual items are issued in the month, the virtual items in the target second records may be paid again, resulting in over-issuance. In this case, the embodiment of the present application directly does not allow the state change of the first record, which prevents the issuance of virtual items in the first record, thereby avoiding over-issuance. Only after the target second record is properly handled can the state change of the first record be performed again to ensure that over-issuance does not occur.
[0092] In the above technical solution, over-issuance is avoided through strict state change control, but this method does not consider the case of multiple concurrents. For example, if two administrators trigger a state change request for the first record in succession, if no intervention is made to the management records of the same target object and the same target period by the two administrators, the trigger operations of the two administrators may affect each other. The first record seen by the latter administrator is not the management record uploaded by himself, but the management record uploaded by the former administrator, causing management confusion, and the management confusion may also cause the reoccurrence of the over-issuance problem.
[0093] To ensure that over-issuance is avoided, the embodiment of the present application further strengthens concurrent control on the basis of maintaining strict state change control, avoids the problem of over-issuance of virtual items caused by concurrency under the premise of supporting high concurrency, and thus proposes a management record control method, Figure 2A flowchart of a management record control method provided by an embodiment of the present application is shown, and the method is also run on a virtual item management end. The embodiment provides the method operation steps as described above in the embodiments or flowcharts, but more or fewer operation steps can be included based on conventional or non-creative labor. The order of steps listed in the embodiments is only one of the many step execution orders, and does not represent the only execution order. In actual system, terminal device or server product execution, the method order shown in the embodiments can be executed in sequence or in parallel (for example, in a parallel processor or multi-threaded processing environment), and the above method can include:
[0094] S201. In the case of needing to change the state of a first record, a mapping record is queried, the mapping record being a record having the same primary key as the first record and having the same target time period, and the first record being a management record for recording the quantity information of virtual items associated by a target object in a target time period.
[0095] The embodiment can receive a state change request for the first record, determine whether state change is needed in the case of receiving the request, and execute step S201 in the case of determining that state change is needed. Details of how to determine whether state change is needed in the case of receiving a state change request for the first record are described above and will not be repeated here.
[0096] The state change request in the embodiment can be a preview request or a warehouse request. The preview request can provide a preview function for the management record for the client. The warehouse request can provide a preview and warehouse function for the management record for the client. In the embodiment, only the virtual items in the management record that have been entered into the database and set to the first state can be issued to the corresponding object.
[0097] In the embodiment, the state of the management record after implementing the preview request is referred to as the second state, and the management record in the second state has not been entered into the database. In the embodiment, the state of the management record after implementing the warehouse request is referred to as the third state, and the management record in the third state has been entered into the database but has not yet taken effect, which is the difference between the third state and the first state.
[0098] For the first record, if a preview request for the first record is received, the client can view the content related to the first record by accessing the virtual item management end, but the content in the first record has not been entered into the database of the virtual item management end, that is, the first record can be placed in the second state. If a warehousing request for the first record is received, the client can view the content related to the first record by accessing the virtual item management end, and enter the content in the first record into the database of the virtual item management end, that is, the first record can be placed in the third state.
[0099] Taking the state change request as a preview request as an example, before determining the target time period information of the first record in the case of receiving a state change request for the first record, the method further comprises:
[0100] S301. Obtain behavior performance information, the behavior performance information being performance information corresponding to the behavior of the target object related to the virtual item in the target time period.
[0101] For example, the target object obtains virtual items by performing a game task on the task publishing platform 1, and the behavior performance information indicates the game task execution of the target object in the target time period. The target object obtains virtual items by performing a media resource editing task on the task publishing platform 2, and the behavior performance information indicates the execution of the media resource editing task of the target object in the target time period.
[0102] S302. Generate a first record according to the first identifier, the second identifier and the behavior performance information, the first identifier being an identifier of a virtual item provider corresponding to the target object, and the second identifier being an identifier of a virtual item manager corresponding to the target object.
[0103] The first identifier can be an identifier of the task publishing platform 1 or the task publishing platform 2, and the second identifier can be an identifier of an administrator of the virtual item management end. The virtual item management end can be configured with multiple administrators, each of which is used to manage the task execution of multiple users on each task publishing platform, and to manage the corresponding management records of the multiple users on the virtual item management end. In this case, the primary key of the first record generated is “first identifier and second identifier”.
[0104] S303. Generate the preview request according to the first record.
[0105] Taking the state change request as a warehousing request as an example, the warehousing request is used to change the first record to the third state, and before determining the target time period information of the first record in the case of receiving a state change request for the first record, the method further comprises:
[0106] S401. Obtain behavior performance information, the behavior performance information being performance information corresponding to a behavior of the target object related to a virtual item in a target time period.
[0107] S402. Generate a first record according to the first identifier, the second identifier, and the behavior performance information, the first identifier being an identifier of a virtual item provider corresponding to the target object, and the second identifier being an identifier of a virtual item manager corresponding to the target object.
[0108] S403. Generate the warehousing request according to the first record.
[0109] The warehousing request is generated in a similar manner to the preview request, and thus the present embodiment will not be described again. Both the warehousing request and the preview request can be triggered and generated by an administrator of the virtual item management end and transmitted to the virtual item management end. In a specific embodiment, generating the first record according to the first identifier, the second identifier, and the behavior performance information can specifically include: generating the first record according to the first identifier, the second identifier, a third identifier, and the behavior performance information, the third identifier being an identity identifier of the target object. In this case, the primary key of the generated first record is “first identifier and second identifier and third identifier”. The setting of the primary key is more detailed than that in the foregoing, and can achieve more refined state management of the management record.
[0110] S202. In the case where the mapping record is queried, a request exclusive lock corresponding to the mapping record is queried, the request exclusive lock being used to prevent other threads except a takeover thread of the request exclusive lock from processing a record having the same primary key as the mapping record.
[0111] In the present embodiment, in order to ensure the uniqueness of the state change operation on the first record, a locking interaction mechanism needs to be designed. The lock added in the present embodiment is a request exclusive lock, or a thread exclusive lock, which is used to prevent other threads except a takeover thread of the request exclusive lock from processing a record having the same primary key as the mapping record. The first record and the mapping record have the same primary key, so that, except the thread of the request exclusive lock taking over the mapping record, other threads cannot operate the first record and the mapping record. The currently running thread is a response thread for the first record, and obviously is not the takeover thread of the request exclusive lock of the mapping record, and thus cannot perform state change on the first record. That is, if the request exclusive lock is valid, the state change operation to be performed by the currently running thread can be prevented.
[0112] S203. In the case where the request exclusive lock exists and the locking duration of the request exclusive lock is greater than a first time threshold, a record state corresponding to the mapping record is obtained.
[0113] The embodiment of the present application not only considers whether the request exclusive lock exists, but also needs to consider the locking duration of the request exclusive lock. In an embodiment, the request exclusive lock can be forcibly unlocked when the locking duration is greater than a first duration threshold, facilitating the state change of the first record, but the embodiment of the present application does not adopt this method, because the fact that the request exclusive lock has not been released indicates that the task corresponding to the thread applying for the request exclusive lock is likely to have not been executed, that is, the task for the mapping record has not been executed. For example, the task for the mapping record is a task related to state change or warehousing, and these tasks can all affect the management record in the database. Forcibly unlocking when the task has not been executed can indeed facilitate the smooth implementation of the state change of the first record, but can also cause the task that has not been executed to be forcibly suspended. After the state change of the first record is completed, the suspended task will continue to be executed, which can still cause management confusion of the management record and cause multiple virtual items to be issued. Therefore, in the embodiment of the present application, the request exclusive lock is not directly and blindly forcibly unlocked when the locking duration is greater than the first duration threshold, but the record state corresponding to the mapping record needs to be obtained first.
[0114] In an embodiment, before the above-mentioned obtaining of the record state corresponding to the mapping record, the method further includes: generating a task identifier in a case where the task corresponding to the mapping record is created successfully; and establishing an association relationship between the task identifier and the mapping record.
[0115] The virtual item management end can trigger the state change of the mapping record when receiving the state change request for the mapping record. The state change request for the mapping record is obviously prior to the state change request for the first record received by the virtual item management end.
[0116] The state change of the mapping record is implemented by a specific task. The task can implement the state change, and can also implement at least one of operations such as management record warehousing, management record verification, and the like. The state change request for the mapping record can be considered to be successfully responded only when the task is executed. The task is implemented asynchronously, and a task identifier is generated when the task is created successfully. The task identifier has a one-to-one correspondence with the mapping record, and the task state of the task can be queried by asynchronously calling an asynchronous state query interface provided by the virtual item management end through the task identifier.
[0117] Correspondingly, the obtaining of the record state corresponding to the mapping record comprises: determining the task identifier corresponding to the mapping record according to the association relationship; calling an asynchronous state query interface based on the task identifier to obtain the task state of the task corresponding to the mapping record; and taking the task state as the record state corresponding to the mapping record.
[0118] S204. According to the record state, the first record is controlled to change the state.
[0119] In the case where the record state represents that the task is executed, the first record is changed in state based on the locking interaction mechanism. In the case where the record state represents that the task is executed, it represents that the task corresponding to the mapping record has been executed, and the request exclusive lock should be released. It may be caused by objective reasons such as program defects, network fluctuations, message delays, etc. that the request exclusive lock has not been released. In this case, forcibly releasing the lock will not cause the virtual goods to be issued multiple times, so in this case, the first record is controlled to change the state.
[0120] In the case where the record state represents that the task is not executed, it is judged whether the locking duration is greater than a second duration threshold, and the first record is controlled to change the state according to the judgment result. In the case where the record state represents that the task is not executed, it represents that the task corresponding to the mapping record is being executed. If the request exclusive lock is released recklessly, the task may be suspended, and the task will be continued to be executed until it is executed at the appropriate time. In this case, forcibly releasing the lock may cause the virtual goods to be issued multiple times, so in this case, the state of the request exclusive lock needs to be further judged.
[0121] Specifically, in the case where the locking duration is less than or equal to the second duration threshold, it is prompted that the state change of the first record fails. In the case where the locking duration is greater than the second duration threshold, the first record is changed in state based on the locking interaction mechanism.
[0122] The second duration threshold in the embodiment of the application is significantly higher than the first duration threshold. For example, the first duration threshold can be 5 minutes, and the second duration threshold can be 30 minutes. If the request exclusive lock is not contacted when the second duration threshold is reached, it can be determined that the task corresponding to the mapping record has a high probability of being dead, which will not cause the virtual goods to be issued multiple times. In this case, it is not a problem to forcibly release the request exclusive lock. On the contrary, it can be considered that the task corresponding to the mapping record is likely to be dead, and the request exclusive lock cannot be released. In this case, the state of the first record cannot be changed recklessly, so it is prompted that the state change of the first record fails.
[0123] In one embodiment, the first record is changed in state based on the locking interaction mechanism as described above.Figure 3 As shown, comprising:
[0124] S501. Take over the above-mentioned request exclusive lock, and reset the locking time corresponding to the above-mentioned request exclusive lock.
[0125] The thread currently processing the first record takes over the request exclusive lock and resets the locking time corresponding to the above-mentioned request exclusive lock, so that the request exclusive lock is reactivated above the first record. The reason for setting the request exclusive lock on the first record is that after the state change request later than the first record, the state change request of other records is exclusively prevented, in which case the first record becomes the "mapping record" in the foregoing with respect to the other record.
[0126] S502. In the case where the above-mentioned request exclusive lock is reset, the state of the above-mentioned first record is changed.
[0127] S503. In the case where the state change is successful, the above-mentioned request exclusive lock is deleted.
[0128] The timely deletion of the request exclusive lock is conducive to the smooth and successful processing of subsequent state change requests by the virtual item management end.
[0129] S205. In the case where the above-mentioned request exclusive lock exists and the locking time of the above-mentioned request exclusive lock is less than or equal to the above-mentioned first time threshold, it is prompted that the state change for the above-mentioned first record fails.
[0130] In this case, the request exclusive lock is valid, and the state change processing operation to be performed by the current thread is prevented, and the response fails, successfully avoiding the possible preview or warehouse chaos.
[0131] S206. In the case where the above-mentioned mapping record is not queried, a request exclusive lock is added to the above-mentioned first record, the state of the above-mentioned first record is changed, and in the case where the state change is successful, the above-mentioned request exclusive lock is deleted.
[0132] If there is no mapping record, it means that there is no administrator to upload the record for the target object and the target time period before, that is, the first record is a brand new record, in which case the state change can be triggered directly. Specifically, the state of the above-mentioned first record can be changed to the above-mentioned second state or the third state; in the case where the above-mentioned state change is successful, the above-mentioned request exclusive lock is deleted. Specifically, if it is a preview request, it is changed to the second state, and if it is a warehouse request, it is changed to the third state, of course, the warehouse operation also needs to be performed, which is not the focus of the present application and will not be described here.
[0133] In the case of performing management record state control, the embodiment of the application avoids management confusion caused by concurrent operation by setting a request exclusive lock, further ensures the rigor of management record state change from the perspective of concurrent control, and thus avoids multiple virtual items. Specifically, in the process of performing management record control based on a request exclusive lock, not only the setting time of the request exclusive lock is considered, but also the task state of the task associated with the request exclusive lock is considered, so that management confusion caused by forced unlocking is greatly reduced, and reasonable state change can be smoothly implemented.
[0134] Reference is made to Figure 4 which shows a block diagram of a management record control device in the embodiment, and the device includes:
[0135] The mapping record query module 401 is configured to query a mapping record in the case of needing to change the state of a first record, the mapping record being a record having the same primary key as the first record and having the same target time period, and the first record being a management record used to record the quantity information of virtual items associated by a target object in a target time period.
[0136] The request exclusive lock query module 402 is configured to query a request exclusive lock corresponding to the mapping record in the case of querying the mapping record, the request exclusive lock being used to prevent threads other than a takeover thread of the request exclusive lock from processing a record having the same primary key as the mapping record.
[0137] The record control module 403 is configured to acquire a record state of a record corresponding to the mapping record in the case of the request exclusive lock existing and the lock duration of the request exclusive lock being greater than a first time threshold, and control the first record to change the state according to the record state.
[0138] In one embodiment, the record control module is configured to perform the following operations:
[0139] In the case of the task corresponding to the mapping record being successfully created, a task identifier is generated.
[0140] An association between the task identifier and the mapping record is established.
[0141] The task identifier corresponding to the mapping record is determined according to the association.
[0142] An asynchronous state query interface is called based on the task identifier, and a task state of the task corresponding to the mapping record is obtained.
[0143] The task state is taken as the record state corresponding to the mapping record.
[0144] In an embodiment, the record control module is configured to perform the following operations:
[0145] In a case where the record state representation task is executed, the first record is changed in state based on the locking interaction mechanism.
[0146] In a case where the record state representation task is not executed, it is determined whether the locking duration is greater than a second duration threshold, and the first record is changed in state according to a determination result.
[0147] In an embodiment, the record control module is configured to perform the following operations:
[0148] In a case where the locking duration is less than or equal to the second duration threshold, it is prompted that the change in state of the first record fails.
[0149] In a case where the locking duration is greater than the second duration threshold, the first record is changed in state based on the locking interaction mechanism.
[0150] In an embodiment, the record control module is configured to perform the following operations:
[0151] The request exclusive lock is taken over, and a locking time corresponding to the request exclusive lock is reset.
[0152] In a case where the request exclusive lock is reset, the first record is changed in state.
[0153] In a case where the change in state succeeds, the request exclusive lock is deleted.
[0154] In an embodiment, the record control module is configured to perform the following operations:
[0155] In a case where the request exclusive lock exists and a locking duration of the request exclusive lock is less than or equal to the first duration threshold, it is prompted that the change in state of the first record fails.
[0156] In an embodiment, the record control module is configured to perform the following operations:
[0157] In a case where the mapping record is not queried, a request exclusive lock is added to the first record, the first record is changed in state, and in a case where the change in state succeeds, the request exclusive lock is deleted.
[0158] The device embodiment and the method embodiment are based on the same inventive concept, and thus no further description is provided.
[0159] On the other hand, embodiments of this application provide a computer-readable storage medium storing at least one instruction or at least one program, wherein the at least one instruction or at least one program is loaded and executed by a processor to implement the aforementioned management record control method.
[0160] The apparatus portion of the embodiments in this application is based on the same inventive concept as the method embodiment, and will not be described in detail here.
[0161] Furthermore, Figure 5 A schematic diagram of a hardware structure for implementing the method provided in the embodiments of this application is shown. This device can participate in or include the apparatus or system provided in the embodiments of this application. Figure 5 As shown, device 10 may include one or more processors 102 (shown as 102a, 102b, ..., 102n in the figure) 102 (processor 102 may include, but is not limited to, a microprocessor MCU or a programmable logic device FPGA, etc.), a memory 104 for storing data, and a transmission device 106 for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the I / O interface), a network interface, a power supply, and / or a camera. Those skilled in the art will understand that... Figure 5 The structure shown is for illustrative purposes only and does not limit the structure of the electronic device described above. For example, device 10 may also include a... Figure 5 The more or fewer components shown, or having the same Figure 5 The different configurations shown.
[0162] It should be noted that the aforementioned one or more processors 102 and / or other data processing circuitry are generally referred to herein as "data processing circuitry". This data processing circuitry may be embodied, in whole or in part, in software, hardware, firmware, or any other combination thereof. Furthermore, the data processing circuitry may be a single, independent processing module, or may be wholly or partially integrated into any other element within device 10 (or mobile device). As involved in the embodiments of this application, this data processing circuitry serves as a processor control mechanism (e.g., selection of a variable resistor termination path connected to an interface).
[0163] The memory 104 can be used to store software programs of application software and modules, such as the program instructions / data storage means corresponding to the method described in the embodiments of the present application. The processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, i.e. implements the above-mentioned management record control method. The memory 104 can include a high-speed random access memory, and can also include a non-volatile memory, such as one or more magnetic storage devices, flash memories, or other non-volatile solid-state memories. In some examples, the memory 104 can further include memories remotely arranged with respect to the processor 102, which can be connected to the device 10 through a network. Examples of the above-mentioned network include but are not limited to the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0164] The transmission device 106 is used to receive or send data via a network. Specific examples of the above-mentioned network can include a wireless network provided by a communication provider of the device 10. In one example, the transmission device 106 includes a network interface controller (NIC) which can be connected to other network devices through a base station so as to be able to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module which is used to communicate with the Internet in a wireless manner.
[0165] The display can be, for example, a touch screen type liquid crystal display (LCD) which can enable a user to interact with the user interface of the device 10 (or mobile device).
[0166] It should be noted that the above-mentioned sequence of the embodiments of the present application is only for description, and does not represent the advantages and disadvantages of the embodiments. The above-mentioned embodiments of the present application are described for specific embodiments. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or sequential order shown to achieve the desired results. In some embodiments, multi-task processing and parallel processing are possible or can be advantageous.
[0167] Each of the embodiments in the embodiments of the present application is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other. Each embodiment focuses on the differences from other embodiments. In particular, for the device and server embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the part of the method embodiments.
[0168] Those skilled in the art can understand that all or part of the steps of the above-mentioned embodiments can be completed by hardware, or by programs instructing relevant hardware to complete. The above-mentioned programs can be stored in a computer readable storage medium. The above-mentioned storage medium can be a read-only memory, a magnetic disk or an optical disk, etc.
[0169] The instructions in the above-mentioned storage medium can execute a management record control method, and the method comprises:
[0170] In the case of needing to change the state of a first record, a mapping record is queried, the mapping record is a record having the same primary key as the first record and having the same target time period, and the first record is a management record for recording the quantity information of virtual items associated by a target object in a target time period;
[0171] In the case of querying the mapping record, a request exclusive lock corresponding to the mapping record is queried, and the request exclusive lock is used to prevent other threads except for a takeover thread of the request exclusive lock from processing a record having the same primary key as the mapping record;
[0172] In the case of existing the request exclusive lock and the lock duration of the request exclusive lock being greater than a first duration threshold, a record state corresponding to the mapping record is obtained;
[0173] According to the record state, the state change of the first record is controlled.
[0174] In one embodiment, before the record state corresponding to the mapping record is obtained, the method further comprises:
[0175] In the case of successfully creating a task corresponding to the mapping record, a task identifier is generated;
[0176] An association relationship between the task identifier and the mapping record is established;
[0177] The record state corresponding to the mapping record is obtained, comprising:
[0178] According to the association relationship, the task identifier corresponding to the mapping record is determined;
[0179] Based on the task identifier, an asynchronous state query interface is called to obtain the task state of the task corresponding to the mapping record;
[0180] The task state is taken as the record state corresponding to the mapping record.
[0181] In one embodiment, according to the record state, the state change of the first record is controlled, comprising:
[0182] In a case where the record state representation task is completed, the first record is changed in state based on a lock interaction mechanism.
[0183] In a case where the record state representation task is not completed, it is determined whether the lock duration is greater than a second duration threshold, and the first record is changed in state according to a determination result.
[0184] In an embodiment, the first record is changed in state according to the determination result, including:
[0185] In a case where the lock duration is less than or equal to the second duration threshold, it is prompted that the state change of the first record fails.
[0186] In a case where the lock duration is greater than the second duration threshold, the first record is changed in state based on the lock interaction mechanism.
[0187] In an embodiment, the first record is changed in state based on the lock interaction mechanism, including:
[0188] The request exclusive lock is taken over, and a lock time corresponding to the request exclusive lock is reset.
[0189] In a case where the request exclusive lock is reset, the first record is changed in state.
[0190] In a case where the state change succeeds, the request exclusive lock is deleted.
[0191] In an embodiment, the method further includes:
[0192] In a case where the request exclusive lock exists and a lock duration of the request exclusive lock is less than or equal to the first duration threshold, it is prompted that the state change of the first record fails.
[0193] In an embodiment, the method further includes:
[0194] In a case where the mapping record is not queried, a request exclusive lock is added to the first record, the first record is changed in state, and in a case where the state change succeeds, the request exclusive lock is deleted.
[0195] The above are only preferred embodiments of the present application, and are not used to limit the present application, and any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the protection scope of the present application.
Claims
1. A management recording control method characterized by comprising: The method comprises: In the case of needing to change the state of a first record, a mapping record is queried, the mapping record being a record having the same primary key as the first record and having the same target time period, the first record being a management record for recording the quantity information of virtual items associated by a target object in a target time period; In the case of querying the mapping record, a request exclusive lock corresponding to the mapping record is queried, the request exclusive lock being used to prevent other threads except a takeover thread of the request exclusive lock from processing a record having the same primary key as the mapping record; In the case of existing the request exclusive lock and the lock duration of the request exclusive lock being greater than a first duration threshold, a record state corresponding to the mapping record is obtained; According to the record state, the state change of the first record is controlled; The method further comprises: In the case of the record state representing that the task is completed, the state change of the first record is controlled based on a lock interaction mechanism; In the case of the record state representing that the task is not completed, it is judged whether the lock duration is greater than a second duration threshold, and the state change of the first record is controlled according to the judgment result; In the case of the lock duration being less than or equal to the second duration threshold, it is prompted that the state change of the first record fails; In the case of the lock duration being greater than the second duration threshold, the state change of the first record is controlled based on the lock interaction mechanism; The method further comprises: The request exclusive lock is taken over, and the lock time corresponding to the request exclusive lock is reset; In the case of the request exclusive lock being reset, the state change of the first record is controlled; In the case of the state change being successful, the request exclusive lock is deleted.
2. The method of claim 1, wherein, Before the record state corresponding to the mapping record is obtained, the method further comprises: In the case of the task corresponding to the mapping record being successfully created, a task identifier is generated; An association relationship between the task identifier and the mapping record is established; The record state corresponding to the mapping record is obtained, comprising: The task identifier corresponding to the mapping record is determined according to the association relationship; An asynchronous state query interface is called based on the task identifier, and the task state of the task corresponding to the mapping record is obtained; The task state is taken as the record state corresponding to the mapping record.
3. The method of claim 1, wherein, The method further comprises: In the case of existing the request exclusive lock and the lock duration of the request exclusive lock being less than or equal to the first duration threshold, it is prompted that the state change of the first record fails.
4. The method of claim 1, wherein, The method further comprises: In the case of not querying the mapping record, a request exclusive lock is added to the first record, the state change of the first record is controlled, and in the case of the state change being successful, the request exclusive lock is deleted.
5. A management recording control device characterized by comprising: The device comprises: The mapping record query module is configured to query a mapping record in a case where a state change of a first record is required, the mapping record being a record having a same primary key as the first record and having a same target time period, the first record being a management record for recording quantity information of a virtual item associated with a target object in a target time period; The request exclusive lock query module is configured to query a request exclusive lock corresponding to the mapping record in a case where the mapping record is queried, the request exclusive lock being configured to prevent threads other than a takeover thread of the request exclusive lock from processing a record having a same primary key as the mapping record; The record control module is configured to acquire a record state of a record corresponding to the mapping record in a case where the request exclusive lock exists and a lock duration of the request exclusive lock is greater than a first time threshold; and control the first record to perform a state change according to the record state. The control of the first record to perform a state change according to the record state includes: In a case where the record state indicates that a task is completed, performing a state change on the first record based on a lock interaction mechanism; In a case where the record state indicates that the task is not completed, determining whether a lock duration is greater than a second time threshold, and controlling the first record to perform a state change according to a determination result; In a case where the lock duration is less than or equal to the second time threshold, prompting a state change failure of the first record; In a case where the lock duration is greater than the second time threshold, performing a state change on the first record based on the lock interaction mechanism. The performing of the state change on the first record based on the lock interaction mechanism includes: Taking over the request exclusive lock, and resetting a lock time corresponding to the request exclusive lock; In a case where the request exclusive lock is reset, performing a state change on the first record; In a case where the state change is successful, deleting the request exclusive lock.
6. A computer-readable storage medium, characterized in that, The computer readable storage medium stores at least one instruction or at least one program, which is loaded and executed by the processor to implement the management record control method in any one of claims 1 to 4.
7. An electronic device, comprising: The computer readable storage medium stores at least one instruction or at least one program, which is loaded and executed by the processor to implement the management record control method in any one of claims 1 to 4.
8. A computer program product comprising computer programs or instructions, characterized in that, The computer program or instruction is executed by the processor to implement the management record control method in any one of claims 1 to 4.
Citation Information
Patent Citations
Issuance method and issuance devices of virtual currency
CN108846654A
Prize claiming system and method based on Internet+
CN112163919A