WO2020238737A1 - Database task processing method and apparatus, electronic device, and readable medium - Google Patents

Database task processing method and apparatus, electronic device, and readable medium Download PDF

Info

Publication number
WO2020238737A1
WO2020238737A1 PCT/CN2020/091467 CN2020091467W WO2020238737A1 WO 2020238737 A1 WO2020238737 A1 WO 2020238737A1 CN 2020091467 W CN2020091467 W CN 2020091467W WO 2020238737 A1 WO2020238737 A1 WO 2020238737A1
Authority
WO
WIPO (PCT)
Prior art keywords
task
queue
database
writing
log
Prior art date
Application number
PCT/CN2020/091467
Other languages
French (fr)
Chinese (zh)
Inventor
王剑英
黄贵
王鲁俊
Original Assignee
阿里巴巴集团控股有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 阿里巴巴集团控股有限公司 filed Critical 阿里巴巴集团控股有限公司
Publication of WO2020238737A1 publication Critical patent/WO2020238737A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/21Design, administration or maintenance of databases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/25Integrating or interfacing systems involving database management systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/546Message passing systems or structures, e.g. queues
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/54Indexing scheme relating to G06F9/54
    • G06F2209/548Queue

Definitions

  • the embodiments of this application relate to the field of Internet technology, and in particular to a method, device, electronic device, and computer-readable medium for processing database tasks.
  • the purpose of this application is to propose a database task processing method, device, electronic equipment and computer readable medium, which are used to solve the problem of low task throughput of the database system caused by the loss of computing resources of the database system in the prior art .
  • a method for processing database tasks includes: determining information of a database writing task corresponding to the writing request according to a writing request to the database; decomposing the database writing task to obtain multiple subtasks corresponding to the database writing task ; According to the lock detection results of the resources occupied by each task queue in the multiple task queues, the multiple subtasks are concurrently written into the multiple task queues.
  • a device for processing database tasks includes: a determining module, which is used to determine information of a database write task corresponding to the write request according to a write request to the database; a decomposition module, which is used to decompose the database write task to obtain all The multiple subtasks corresponding to the database write task; the concurrent write module is used to write the multiple subtasks concurrently to the multiple task queues according to the lock detection results of the resources occupied by each task queue in the multiple task queues Task queue.
  • an electronic device including: one or more processors; a computer-readable medium configured to store one or more programs, when the one or more programs are The one or more processors execute, so that the one or more processors implement the method for processing database tasks as described in the first aspect of the foregoing embodiment.
  • a computer-readable medium having a computer program stored thereon, and when the program is executed by a processor, the method for processing database tasks as described in the first aspect of the above-mentioned embodiment is implemented .
  • the information of the database write task corresponding to the write request is determined, and the database write task is decomposed to obtain multiple subtasks corresponding to the database write task.
  • the database write task is decomposed to obtain multiple subtasks corresponding to the database write task.
  • multiple subtasks are concurrently written into multiple task queues.
  • the computing resources of the database system can be reduced. Loss, thereby effectively improving the task throughput of the database system.
  • FIG. 1 is a flowchart of the steps of a method for processing database tasks in Embodiment 1 of the application;
  • FIG. 3 is a schematic structural diagram of a processing device for database tasks in Embodiment 3 of this application;
  • FIG. 4 is a schematic structural diagram of a processing device for database tasks in Embodiment 4 of this application;
  • FIG. 5 is a schematic structural diagram of a processing device for database tasks in Embodiment 5 of this application;
  • FIG. 6 is a schematic diagram of the structure of the electronic device in the sixth embodiment of the application.
  • FIG. 7 is the hardware structure of the electronic device in the seventh embodiment of the application.
  • the method for processing database tasks in this embodiment includes the following steps:
  • step S101 the information of the database write task corresponding to the write request is determined according to the write request to the database.
  • the solutions provided by the embodiments of the present invention can be applied to databases based on the LSM structure, including but not limited to X-DB databases, LevelDB databases, RocksDB databases, and the like.
  • the write request may include a database transaction write request, or a write request for database operations.
  • the information of the database write task may include the information of the write task corresponding to the database transaction, such as the write log information, the flushing information of the log data of the database transaction, the write memory information of the database transaction, or the commit information of the database transaction, etc. . It can be understood that the above description is only exemplary, and the embodiments of the present application do not make any limitation thereto.
  • the write request may be parsed to obtain the information of the database write task corresponding to the write request .
  • step S102 the database writing task is decomposed to obtain multiple subtasks corresponding to the database writing task.
  • the decomposition of the database writing task may be implemented in any suitable manner to obtain multiple subtasks corresponding to the database writing task.
  • database writing tasks can be divided into multiple different writing logics, and each writing logic can correspond to multiple sub-logics. Based on this, database writing tasks can be decomposed to obtain different writing Logic and/or subtasks corresponding to different sub-logics.
  • WAL writing tasks it may include writing active memory table tasks, writing frozen memory table tasks, persistent storage tasks, and so on.
  • a certain write task may write a batch of data at a time
  • the write task can be divided into multiple subtasks, and each subtask writes part of the data, and so on.
  • step S103 the multiple subtasks are concurrently written into the multiple task queues according to the lock detection result on the resources occupied by each task queue in the multiple task queues.
  • each task requires a certain amount of resource support.
  • subtasks are grouped to form a task queue, and resources are allocated in units of task queues.
  • Each group of task queues can accommodate multiple (two or more) ) Subtasks.
  • the subtask can be written into the unlocked task queue according to the lock status of each task queue.
  • multiple sets of slot slots are used, and each set of slots corresponds to a task queue.
  • the multiple subtasks may try to organize the grouping of subtasks on the task queue corresponding to any group Slot.
  • the multiple subtasks when the multiple subtasks are concurrently written to the multiple task queues according to the lock detection result on the resources occupied by each task queue in the multiple task queues, Select a task queue in the task queue to determine whether the selected task queue has been locked; if it has been locked, select another task queue from the remaining task queues, and add the subtasks to be added to the selected task Queue; if it is not locked, add the subtask to be added to the selected task queue. Specifically, through the lock flag bit of the selected task queue, it is determined whether the selected task queue has been locked. If it is determined that the selected queue has been locked, it is immediately determined whether the task queues corresponding to other group slots have been locked. . Accordingly, by locking the resources occupied by the task queue, the execution efficiency of the subtasks added to the task queue can be guaranteed. It can be understood that the above description is only exemplary, and the embodiments of the present application do not make any limitation thereto.
  • the trylock mechanism can be used to lock the resources occupied by the task queue. Specifically, the execution thread of the task queue first tries to lock once in a very lightweight manner, and executes normally if the lock is successful. If the lock fails, the thread will not block, but immediately exit the kernel to do other tasks. It can be understood that the above description is only exemplary, and the embodiments of the present application do not make any limitation thereto.
  • the method further includes: for each task queue, allocating an execution thread for the first subtask to be added to the current task queue, wherein the execution thread is used to execute the tasks in the current task queue All subtasks. In this way, it is not necessary to allocate execution threads to all subtasks in the current task queue, which reduces the number of concurrent threads of the database system, and thereby reduces the scheduling overhead of the database system for the working status of the execution threads. It can be understood that the above description is only exemplary, and the embodiments of the present application do not make any limitation thereto.
  • an execution thread is allocated to the first subtask that enters the task queue corresponding to the slot, and the execution thread is used to execute all the subtasks in the task queue. In other words, the execution thread is in the "leader" position in the task queue.
  • the method further includes: if all the subtasks in the current task queue are executed, unlocking the resources of the current task queue; according to the idleness of the current task queue after unlocking
  • the waiting time and/or the subtask information received again is processed on the execution thread corresponding to the current task queue.
  • the idle waiting time may include an idle waiting time period
  • the information of the subtasks received again may include the number of subtasks received again.
  • processing the execution thread corresponding to the current task queue according to the idle waiting time of the current task queue after unlocking or the information of the subtask received again includes: If no new subtask is received again within the waiting time period, the corresponding relationship between the execution thread and the current task queue is released; if a new subtask is received again within the idle waiting time period, And the number of the new subtasks reaches the preset threshold, the execution thread is awakened, and the new subtasks are executed through the execution thread.
  • the time period of the idle waiting time can be set by those skilled in the art according to actual needs, which is not limited in the embodiment of the present application.
  • the preset threshold can be set by those skilled in the art according to actual needs, and the embodiment of the present application does not make any limitation on this. It can be understood that the above description is only exemplary, and the embodiments of the present application do not make any limitation thereto.
  • the execution thread automatically switches from the sleep state to the wake state, and then releases the execution thread and all the subtasks. Describe the corresponding relationship of the current task queue. If a new subtask is received again within the time period of the idle waiting time, and the number of the new subtask reaches the preset threshold, the new subtask is passed as the last one to enter the current task queue. The auxiliary thread assigned by the task triggers the wake-up of the execution thread. If a new subtask is received again within the time period of the idle waiting time, and the number of the new subtask does not reach the preset threshold, the new subtask is passed as the last one to enter the current task queue. The auxiliary thread allocated by the subtask triggers the awakening of the execution thread, and the new subtask is executed through the execution thread. It can be understood that the above description is only exemplary, and the embodiments of the present application do not make any limitation thereto.
  • the first write request to enter the Slot will become the leader, and the execution thread will be allocated to it.
  • the leader in the current Slot releases the lock of the Slot, it will cond_wait for a period of time (this time can be configured by those skilled in the art according to actual needs). If the number of followers collected by the leader exceeds max_group_size (the maximum capacity of a task queue within the waiting time) ), the leader is awakened (triggered by the last follower). Otherwise, when the timeout period is reached, the leader wakes up by itself and switches the leader of the slot where it is empty (that is, the relationship between the execution thread corresponding to the leader and the slot is released).
  • the method further includes: for each task queue, allocating an auxiliary thread for the subtask that is not the first to join the current task queue, wherein the auxiliary thread is used to transfer the non-first subtask
  • the task is handed over to the execution thread for processing; it is determined whether the auxiliary thread has successfully handed over the non-first subtask to the execution thread, and if so, the auxiliary thread is allocated to obtain a new subtask.
  • This method can be implemented through an asynchronous API. After the follower gives its subtask to the leader, it can immediately return to handle the new subtask. After the leader completes the task of the follower, it can call a callback function to complete the cleaning of the current task queue.
  • an asynchronous API can be used to allocate the auxiliary thread to obtain a new subtask.
  • fewer threads are used to serve more tasks, and the loss of effective computing resources caused by thread scheduling of the database system is reduced.
  • the callback function is called to complete the cleaning work.
  • the auxiliary thread will wait for the execution thread to complete the processing of all the subtasks in the current task queue before returning to obtain a new subtask.
  • the information of the database write task corresponding to the write request is determined, and the database write task is decomposed to obtain the database write task corresponding Multiple subtasks, and then based on the lock detection results of the resources occupied by each task queue in the multiple task queues, write multiple subtasks concurrently into multiple task queues.
  • it can reduce the database system
  • the loss of computing resources effectively improves the task throughput of the database system.
  • the method for processing database tasks in this embodiment can be executed by any appropriate device with data processing capabilities, including but not limited to: cameras, terminals, mobile terminals, PCs, servers, in-vehicle devices, entertainment devices, advertising devices, and personal digital devices.
  • Assistant PDA
  • tablet computer notebook computer
  • handheld game console smart glasses
  • smart watch wearable device
  • virtual display device or display enhancement device such as Google Glass, Oculus Rift, Hololens, Gear VR, etc.
  • FIG. 2 there is shown a flowchart of the steps of a method for processing a database task in the second embodiment of the present application.
  • the method for processing database tasks in this embodiment includes the following steps:
  • step S201 according to the write request to the database, the information of the database write task corresponding to the write request is determined.
  • step S201 is similar to the above step S101, it will not be repeated here.
  • step S202 the database writing task is decomposed to obtain multiple subtasks corresponding to the database writing task.
  • step S202 is similar to the above step S102, it will not be repeated here.
  • step S203 the multiple subtasks are concurrently written into the multiple task queues according to the lock detection result on the resources occupied by each task queue in the multiple task queues.
  • step S203 is similar to the above step S103, it will not be repeated here.
  • step S204 if all the subtasks in the current task queue have been executed, the database transaction log data corresponding to all the subtasks are collected, and the corresponding log write task is generated.
  • the execution thread of the current task queue collects the database transaction log data of all subtasks in the current task queue into the local cache of the task, and calculates all the subtasks in the current task queue The crc32 checksum data of the database transaction log data. Then, generate the corresponding log writing task.
  • step S205 the database transaction log data is written into the log copy queue through the log writing task.
  • the method when the database transaction log data is written into the log copy queue through the log writing task, the method further includes: allocating a log transaction identifier for the log writing task, and The log transaction identifier determines whether all log writing tasks are completed. In this way, it can be judged whether all log writing tasks are completed through the log transaction identifier.
  • the log transaction identifier is recorded and stored in the corresponding variable as a basis for whether the log writing task is completed.
  • the log transaction identifier may be a local serial number.
  • the prerequisite for exiting the kernel is that the global sequence number is greater than or equal to the local sequence number. This ensures that all log writing tasks have been completed before the last thread exits the kernel.
  • step S206 the log data in the log copy queue is written into the cache for storing log data through the first working thread.
  • the first working thread extracts database transaction log data from the log copy queue, and writes the database transaction log data into a cache for storing log data.
  • the first working thread may be a foreground thread or a background thread.
  • finer scheduling and task allocation can be performed.
  • the fixed allocation of the number of log writing threads is reasonably set according to the number of physical CPUs of the machine. It can be understood that the above description is only exemplary, and the embodiments of the present application do not make any limitation thereto.
  • the method further includes: sending the database transaction log data in the cache to the log flushing queue through a flushing task, so as to persistently store the database transaction log data; Two working threads, which persistently store the database transaction log data in the log flushing queue. By this, it can ensure the persistent storage of the database transaction log data in the log flushing queue.
  • the second working thread may be a foreground thread or a background thread.
  • the second working thread can be a background thread.
  • finer scheduling and task allocation can be performed.
  • the database transaction log data is written into the cache for storing log data, the corresponding disk flushing task is generated. Then, the database transaction log data in the cache is persistently stored through the flashing task.
  • the sending the log data in the cache to the log flushing queue through the flushing task includes: determining whether the current flushing task has preempted the flushing lock, and if so, passing the current The flushing task sends the corresponding log data to the log flushing queue. In this way, preemptive execution of the task of brushing can be realized.
  • the flashing task can only be executed in series by one thread, so an atomic flag is set to implement preemptive execution of the task.
  • the method further includes: recording the number corresponding to the log data, and according to the Specify the number and send the corresponding log data to the write memory table queue. With this, it can be ensured that the log data that has been flushed is sent to the write memory table queue.
  • the second worker thread will try to flush the database transaction log data in the cache.
  • the log sequence number of the database transaction log data advances, it will extract the current transactions that meet the conditions from the log flush queue.
  • Database transaction log data is extracted from the log flushing queue.
  • the method further includes: concurrently writing the log data in the memory table writing queue to the memory table through multiple memory table writing tasks. With this, the database transaction log data can be written into the memory table concurrently.
  • multiple corresponding memory table writing tasks are generated.
  • the database transaction log data in the memory table write queue is concurrently written into the memory table through multiple tasks of writing the memory table.
  • the multiple tasks of writing memory tables can be executed concurrently, and most of the work threads are concentrated in this place, and concurrently obtain database transaction log data from the writing memory tables, and perform the operation of writing the memory tables.
  • the concurrently writing the log data in the memory table writing queue to the memory table through multiple memory table writing tasks includes: obtaining the task number of the submitted memory table writing task; The largest task number among the consecutive task numbers is determined as the current task number; according to the current task number, it is determined whether the multiple tasks of writing memory tables are all completed. In this way, the task number can ensure the completion of multiple tasks of writing memory tables.
  • the memory table writing tasks corresponding to task numbers 1, 2, 3, and 6 have all been executed, but the memory table writing tasks corresponding to task numbers 4 and 5 have not been executed yet, and the current task number is updated at this time Is 3. After the task of writing memory table corresponding to task numbers 4 and 5 is executed, the current task number is updated to 6. It can be understood that the above description is only exemplary, and the embodiments of the present application do not make any limitation thereto.
  • the method further includes: performing a cleanup operation on multiple submitted tasks for writing memory tables through multiple submission tasks. With this, it is possible to clean up multiple submitted tasks for writing memory tables. It can be understood that the above description is only exemplary, and the embodiments of the present application do not make any limitation thereto.
  • the memory table task that meets the submission condition will be pushed to the execution queue.
  • the memory table task to be submitted will be pushed to the execution queue for cleaning.
  • the cleaning operations of the memory table tasks in the execution queue can be executed concurrently. Specifically, locks are released on the computing resources occupied by the memory table task, and the memory occupied by the memory table task is reclaimed. More specifically, call the callback function to complete the cleanup work. In the synchronous mode, after the task is submitted, it is necessary to wake up the thread waiting for the task to be submitted and return the package. In asynchronous mode, use the callback function to complete the task lock and memory release.
  • the leader of the slot will collect the logs of all the followers of the slot into a large write batch, and calculate the crc32 check of the WAL log; then, the log The write task is pushed to the log copy queue.
  • a transaction ID will be assigned to the log write task. This transaction ID will be recorded and stored in the local_expected_sequence_number as the basis for whether the transaction can exit the pipeline.
  • the first worker thread extracts the log content written by the log writing task from the copy log queue, writes the log content into the buffer of the WAL log module, records the lsn (the number corresponding to the log data), and then writes the contents of the memory table Push the task to the log flushing queue. This part of the task can only be executed serially by one thread, so an atomic flag is set to achieve preemptive execution of the task.
  • the log content of the tasks in the queue has been written to the log buffer, but there is no flushing.
  • the worker thread will try to flush the buffer in the log module.
  • the lsn of the log file is advanced, it will extract the (flush_lsn>append_lsn) task that meets the conditions from the log flush queue and push it to the write memtable queue.
  • the tasks in the writememtable queue have completed the log flushing and are waiting for the task of writing the memory table. This part of the task can be executed concurrently. Most of the work threads are concentrated in this place, and concurrently obtain tasks from write_memtable_queue and execute the operation of writing the memory table. .
  • the read operation can be read.
  • a sliding window needs to be maintained to update the global read version number. For example, transactions 1, 2, 3, and 6 have been executed. But transactions 4 and 5 have not been executed yet, and the global version number is updated to 3. When 4 and 5 are submitted, the global version number is updated to 6.
  • the global version number advances, tasks that meet the submission conditions will be pushed to commit_queue. The tasks in commit_queue need to complete submission, unlocking and memory recovery, etc. This part of the task can be executed concurrently.
  • a callback function is used to complete the transaction lock and memory release. When used as an engine of MySQL, the callback function here also needs to complete the task of returning the package to the client.
  • the database transaction log data corresponding to all subtasks are collected, and the corresponding log writing task is generated, and then the log writing The task writes database transaction log data into the log copy queue, and then through the first working thread, writes the database transaction log data in the log copy queue into the cache for storing log data.
  • the database transaction log data corresponding to the subtasks that have been executed are written into the cache for storing the log data, thereby ensuring the consistency of the execution of the database tasks.
  • the method for processing database tasks in this embodiment can be executed by any appropriate device with data processing capabilities, including but not limited to: cameras, terminals, mobile terminals, PCs, servers, in-vehicle devices, entertainment devices, advertising devices, and personal digital devices.
  • Assistant PDA
  • tablet computer notebook computer
  • handheld game console smart glasses
  • smart watch wearable device
  • virtual display device or display enhancement device such as Google Glass, Oculus Rift, Hololens, Gear VR, etc.
  • FIG. 3 there is shown a schematic structural diagram of an apparatus for processing database tasks in Embodiment 3 of the present application.
  • the database task processing device of this embodiment includes: a determining module 301, configured to determine the information of the database write task corresponding to the write request according to a write request to the database; and a decomposition module 302, configured to check the database
  • the writing task is decomposed to obtain multiple subtasks corresponding to the database writing task;
  • the concurrent writing module 303 is configured to detect the multiple task queues according to the lock detection result of the resources occupied by each task queue in the multiple task queues.
  • the subtasks are concurrently written into the multiple task queues.
  • the database task processing apparatus of this embodiment is used to implement the corresponding database task processing methods in the foregoing multiple method embodiments, and has the beneficial effects of the corresponding method embodiments, which will not be repeated here.
  • FIG. 4 there is shown a schematic structural diagram of a database task processing device in the fourth embodiment of the present application.
  • the database task processing device of this embodiment includes: a determining module 401, configured to determine the database write task information corresponding to the write request according to a write request to the database; The writing task is decomposed to obtain multiple subtasks corresponding to the database writing task; the concurrent writing module 403 is configured to detect the multiple task queues according to the lock detection result of the resources occupied by each task queue in the multiple task queues. The subtasks are concurrently written into the multiple task queues.
  • the concurrent writing module 403 is specifically configured to: select a task queue from the multiple task queues, and determine whether the selected task queue has been locked; if it has been locked, select a task queue from the remaining Another task queue is selected from the task queue, and the subtask to be added is added to the selected task queue; if it is not locked, the subtask to be added is added to the selected task queue.
  • the device further includes: a first allocation module 404, configured to allocate an execution thread for the first subtask added to the current task queue for each task queue, wherein the execution thread is used to execute the current task queue. All subtasks in the task queue.
  • a first allocation module 404 configured to allocate an execution thread for the first subtask added to the current task queue for each task queue, wherein the execution thread is used to execute the current task queue. All subtasks in the task queue.
  • the device further includes: a resource unlocking module 405, configured to unlock the resources of the current task queue if all subtasks in the current task queue are executed; a processing module 406, configured to unlock resources according to the unlock The subsequent idle waiting time of the current task queue and/or the information of the subtask received again is processed on the execution thread corresponding to the current task queue.
  • a resource unlocking module 405 configured to unlock the resources of the current task queue if all subtasks in the current task queue are executed
  • a processing module 406 configured to unlock resources according to the unlock The subsequent idle waiting time of the current task queue and/or the information of the subtask received again is processed on the execution thread corresponding to the current task queue.
  • the processing module 406 is specifically configured to: if a new subtask is not received again within the idle waiting time period, release the corresponding relationship between the execution thread and the current task queue; If a new subtask is received again within the period of the idle waiting time, and the number of the new subtask reaches the preset threshold, the execution thread is awakened, and the new execution thread is executed Of subtasks.
  • the device further includes: a second allocation module 407, configured to allocate auxiliary threads to the subtasks that are not the first to join the current task queue for each task queue, wherein the auxiliary thread is used for The non-first subtask is handed over to the execution thread for processing; the third allocation module 408 is used to determine whether the auxiliary thread has successfully handed over the non-first subtask to the execution thread, and if so, allocate the The auxiliary thread acquires a new subtask.
  • a second allocation module 407 configured to allocate auxiliary threads to the subtasks that are not the first to join the current task queue for each task queue, wherein the auxiliary thread is used for The non-first subtask is handed over to the execution thread for processing
  • the third allocation module 408 is used to determine whether the auxiliary thread has successfully handed over the non-first subtask to the execution thread, and if so, allocate the The auxiliary thread acquires a new subtask.
  • the database task processing apparatus of this embodiment is used to implement the corresponding database task processing methods in the foregoing multiple method embodiments, and has the beneficial effects of the corresponding method embodiments, which will not be repeated here.
  • FIG. 5 there is shown a schematic structural diagram of a database task processing device in Embodiment 5 of the present application.
  • the database task processing device of this embodiment includes: a determining module 501, configured to determine the information of the database write task corresponding to the write request according to a write request to the database; and a decomposition module 502, configured to check the database
  • the writing task is decomposed to obtain multiple subtasks corresponding to the database writing task;
  • the concurrent writing module 503 is configured to detect the multiple task queues according to the lock detection result of the resources occupied by each task queue in the multiple task queues.
  • the subtasks are concurrently written into the multiple task queues.
  • the device further includes: a collection module 504, configured to collect database transaction log data corresponding to all subtasks if all subtasks in the current task queue have been executed, and generate corresponding log writes Into the task; the first writing module 505, used to write the log data into the log copy queue through the log writing task; the second writing module 506, used to copy the log through the first working thread The log data in the queue is written into the buffer for storing the log data.
  • a collection module 504 configured to collect database transaction log data corresponding to all subtasks if all subtasks in the current task queue have been executed, and generate corresponding log writes Into the task
  • the first writing module 505 used to write the log data into the log copy queue through the log writing task
  • the second writing module 506 used to copy the log through the first working thread
  • the log data in the queue is written into the buffer for storing the log data.
  • the device further includes: a fourth allocation module 507, configured to allocate a log transaction identifier for the log writing task; a judging module 508, configured to determine whether all log writing tasks are all based on the log transaction identifier carry out.
  • a fourth allocation module 507 configured to allocate a log transaction identifier for the log writing task
  • a judging module 508 configured to determine whether all log writing tasks are all based on the log transaction identifier carry out.
  • the device further includes: a sending module 509, configured to send the log data in the cache to the log flushing queue through a flushing task, so as to perform persistent storage on the log data; a persistent storage module 510, configured to perform persistent storage on the log data in the log flushing queue through a second working thread.
  • a sending module 509 configured to send the log data in the cache to the log flushing queue through a flushing task, so as to perform persistent storage on the log data
  • a persistent storage module 510 configured to perform persistent storage on the log data in the log flushing queue through a second working thread.
  • the sending module 509 is specifically configured to: determine whether the current flashing task has seized the flashing lock, and if so, sending the corresponding log data to the log flashing through the current flashing task queue.
  • the device further includes: a recording module 511, configured to record a serial number corresponding to the log data, and according to the serial number, send the corresponding log data to the write memory table queue.
  • a recording module 511 configured to record a serial number corresponding to the log data, and according to the serial number, send the corresponding log data to the write memory table queue.
  • the device further includes: a third writing module 512, configured to concurrently write the log data in the memory table writing queue into the memory table through multiple memory table writing tasks.
  • a third writing module 512 configured to concurrently write the log data in the memory table writing queue into the memory table through multiple memory table writing tasks.
  • the third writing module 512 is specifically configured to: obtain the task number of the task of writing the memory table that has been submitted; determine the largest task number among multiple consecutive task numbers as the current task number; according to the current task Numbering determines whether the multiple tasks of writing memory tables are all completed.
  • the device further includes: a cleaning module 513, configured to perform cleaning operations on multiple submitted tasks for writing memory tables through multiple submission tasks.
  • a cleaning module 513 configured to perform cleaning operations on multiple submitted tasks for writing memory tables through multiple submission tasks.
  • the database task processing apparatus of this embodiment is used to implement the corresponding database task processing methods in the foregoing multiple method embodiments, and has the beneficial effects of the corresponding method embodiments, which will not be repeated here.
  • FIG. 6 is a schematic structural diagram of an electronic device in Embodiment 6 of this application; the electronic device may include:
  • the computer-readable medium 602 can be configured to store one or more programs,
  • the one or more processors When the one or more programs are executed by the one or more processors, the one or more processors implement the method for processing database tasks as described in the first embodiment or the second embodiment.
  • FIG. 7 is the hardware structure of the electronic device in the seventh embodiment of the application; as shown in FIG. 7, the hardware structure of the electronic device may include: a processor 701, a communication interface 702, a computer-readable medium 703 and a communication bus 704;
  • the processor 701, the communication interface 702, and the computer-readable medium 703 communicate with each other through the communication bus 704;
  • the communication interface 702 may be an interface of a communication module, such as an interface of a GSM module;
  • the processor 701 may be specifically configured to: according to a write request to the database, determine the information of the database write task corresponding to the write request; decompose the database write task to obtain the database write task Corresponding multiple subtasks; according to the lock detection result of the resources occupied by each task queue in the multiple task queues, the multiple subtasks are concurrently written into the multiple task queues.
  • the processor 701 may be a general-purpose processor, including a central processing unit (Central Processing Unit, CPU), a network processor (Network Processor, NP), etc.; it may also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), etc. ), ready-made programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components.
  • the methods, steps, and logical block diagrams disclosed in the embodiments of the present application can be implemented or executed.
  • the general-purpose processor may be a microprocessor or the processor may also be any conventional processor or the like.
  • the computer-readable medium 703 may be, but is not limited to, a random access storage medium (Random Access Memory, RAM), a read-only storage medium (Read Only Memory, ROM), and a programmable read-only storage medium (Programmable Read-Only Memory, PROM), Erasable Programmable Read-Only Memory (EPROM), Electrically Erasable Programmable Read-Only Memory (EEPROM), etc.
  • RAM Random Access Memory
  • ROM Read Only Memory
  • PROM Programmable Read-Only Memory
  • EPROM Erasable Programmable Read-Only Memory
  • EEPROM Electrically Erasable Programmable Read-Only Memory
  • an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes program code configured to execute the method shown in the flowchart.
  • the computer program may be downloaded and installed from the network through the communication part, and/or installed from a removable medium.
  • CPU central processing unit
  • the above-mentioned functions defined in the method of the present application are executed.
  • the computer-readable medium described in this application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the two.
  • the computer-readable medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections with one or more wires, portable computer disks, hard disks, random access storage media (RAM), read-only storage media (ROM), erasable Type programmable read-only storage medium (EPROM or flash memory), optical fiber, portable compact disk read-only storage medium (CD-ROM), optical storage medium, magnetic storage medium, or any suitable combination of the above.
  • RAM random access storage media
  • ROM read-only storage media
  • EPROM or flash memory erasable Type programmable read-only storage medium
  • CD-ROM portable compact disk read-only storage medium
  • magnetic storage medium or any suitable combination of the above.
  • the computer-readable storage medium may be any tangible medium that contains or stores a program, and the program may be used by or in combination with an instruction execution system, apparatus, or device.
  • a computer-readable signal medium may include a data signal propagated in a baseband or as a part of a carrier wave, and a computer-readable program code is carried therein. This propagated data signal can take many forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the foregoing.
  • the computer-readable signal medium may also be any computer-readable medium other than the computer-readable storage medium.
  • the computer-readable medium may send, propagate, or transmit a program configured to be used by or in combination with the instruction execution system, apparatus, or device .
  • the program code contained on the computer-readable medium can be transmitted by any suitable medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
  • the computer program code configured to perform the operations of the present application can be written in one or more programming languages or a combination thereof.
  • the programming languages include object-oriented programming languages—such as Java, Smalltalk, C++, and also conventional Procedural programming language-such as "C" language or similar programming language.
  • the program code can be executed entirely on the user's computer, partly on the user's computer, executed as an independent software package, partly on the user's computer and partly executed on a remote computer, or entirely executed on the remote computer or server.
  • the remote computer can be connected to the user's computer through any kind of network: including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computer (for example, using an Internet service provider to connect to the Internet connection).
  • LAN local area network
  • WAN wide area network
  • each block in the flowchart or block diagram can represent a module, program segment, or part of code, and the module, program segment, or part of code contains one or more configurations to achieve the specified logical function Executable instructions.
  • sequence relationships there are specific sequence relationships, but these sequence relationships are only exemplary. In specific implementation, these steps may be fewer, more, or the execution order may be adjusted. That is, in some alternative implementations, the functions marked in the block may also occur in a different order from the order marked in the drawings.
  • each block in the block diagram and/or flowchart, and the combination of the blocks in the block diagram and/or flowchart can be implemented by a dedicated hardware-based system that performs the specified functions or operations Or it can be realized by a combination of dedicated hardware and computer instructions.
  • the modules involved in the embodiments described in the present application can be implemented in software or hardware.
  • the described module may also be provided in the processor, for example, it may be described as: a processor includes a determination module, a decomposition module, and a concurrent writing module.
  • the names of these modules do not constitute a limitation on the module itself under certain circumstances.
  • the determining module can also be described as "based on a write request to the database, determine the database write corresponding to the write request Module of task information".
  • the present application also provides a computer-readable medium on which a computer program is stored, and when the program is executed by a processor, the method for processing database tasks as described in the first embodiment or the second embodiment is realized.
  • the present application also provides a computer-readable medium, which may be included in the device described in the above-mentioned embodiments; or it may exist alone without being assembled into the device.
  • the above-mentioned computer-readable medium carries one or more programs, and when the above-mentioned one or more programs are executed by the device, the device is caused to determine the database write task corresponding to the write request according to the write request to the database Decompose the database write task to obtain multiple subtasks corresponding to the database write task; according to the lock detection results of the resources occupied by each task queue in the multiple task queues, the multiple subtasks Tasks are written into the multiple task queues concurrently.
  • first, second, the first or “the second” used in various embodiments of the present disclosure may modify various components regardless of order and/or importance , But these expressions do not limit the corresponding components.
  • the above expressions are only configured for the purpose of distinguishing elements from other elements.
  • the first user equipment and the second user equipment represent different user equipment, although both are user equipment.
  • the first element may be referred to as the second element, and similarly, the second element may be referred to as the first element.
  • an element for example, a first element
  • another element for example, a second element
  • an element e.g., a second element
  • an element e.g., a second element
  • the one element is directly connected to the other element or the one element passes through another element (e.g., The third element) is indirectly connected to the other element.

Abstract

A database task processing method and apparatus, an electronic device, and a readable medium, relating to the technical field of Internet. The method comprises: determining, according to a write request to a database, information of a database write task corresponding to the write request (S101); decomposing the database write task to obtain multiple subtasks corresponding to the database write task (S102); and concurrently writing, according to a locking detection result of a resource occupied by each of multiple task queues, the multiple subtasks into the multiple task queues (S103). The present invention can reduce consumption of computing resources of a database system, thereby effectively improving the task throughput of the database system.

Description

数据库任务的处理方法、装置、电子设备及可读介质Database task processing method, device, electronic equipment and readable medium
本申请要求2019年05月30日递交的申请号为201910462682.0、发明名称为“数据库任务的处理方法、装置、电子设备及可读介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of a Chinese patent application filed on May 30, 2019 with the application number 201910462682.0 and the invention title "Database task processing method, device, electronic equipment and readable medium", the entire content of which is incorporated by reference In this application.
技术领域Technical field
本申请实施例涉及互联网技术领域,尤其涉及一种数据库任务的处理方法、装置、电子设备及计算机可读介质。The embodiments of this application relate to the field of Internet technology, and in particular to a method, device, electronic device, and computer-readable medium for processing database tasks.
背景技术Background technique
传统数据库系统的并发事务的调度过程中,对于数据库系统中大量存在的需串行访问的任务,一般会通过让执行线程排队等待的方式来规避互斥访问。但是,会导致执行线程的睡眠状态和唤醒状态的频繁调度,从而降低数据库系统的任务吞吐量,太多的串行执行会带来数据库系统的性能的回退。In the scheduling of concurrent transactions in traditional database systems, for a large number of tasks that require serial access in the database system, mutual exclusive access is generally avoided by queuing execution threads. However, it will cause frequent scheduling of the sleep state and wake state of the execution thread, thereby reducing the task throughput of the database system. Too much serial execution will bring about the performance of the database system.
并且,在多阶段的执行逻辑的执行过程中,大部分线程虽然不参与并发执行,但是需要在不同阶段的信号量上等待,以决定下一步是唤醒一个或者多个线程来执行任务。此过程带来的线程的工作状态的切换在任务高并发时会导致数据库系统的计算资源的大量损耗,进而大大降低数据库系统的任务吞吐量。Moreover, in the execution of the multi-stage execution logic, although most threads do not participate in concurrent execution, they need to wait on the semaphores of different stages to decide the next step is to wake up one or more threads to perform tasks. The switching of the working status of the threads brought about by this process will cause a large loss of computing resources of the database system when tasks are high in concurrency, thereby greatly reducing the task throughput of the database system.
发明内容Summary of the invention
本申请的目的在于提出一种数据库任务的处理方法、装置、电子设备及计算机可读介质,用于解决现有技术中存在的数据库系统的计算资源损耗导致的数据库系统的任务吞吐量低的问题。The purpose of this application is to propose a database task processing method, device, electronic equipment and computer readable medium, which are used to solve the problem of low task throughput of the database system caused by the loss of computing resources of the database system in the prior art .
根据本申请实施例的第一方面,提供了一种数据库任务的处理方法。所述方法包括:根据对数据库的写入请求,确定所述写入请求对应的数据库写入任务的信息;对所述数据库写入任务进行分解,获得所述数据库写入任务对应的多个子任务;根据对多个任务队列中各个任务队列占用的资源的加锁检测结果,将所述多个子任务并发写入所述多个任务队列。According to the first aspect of the embodiments of the present application, a method for processing database tasks is provided. The method includes: determining information of a database writing task corresponding to the writing request according to a writing request to the database; decomposing the database writing task to obtain multiple subtasks corresponding to the database writing task ; According to the lock detection results of the resources occupied by each task queue in the multiple task queues, the multiple subtasks are concurrently written into the multiple task queues.
根据本申请实施例的第二方面,提供了一种数据库任务的处理装置。所述装置包括:确定模块,用于根据对数据库的写入请求,确定所述写入请求对应的数据库写入任务的 信息;分解模块,用于对所述数据库写入任务进行分解,获得所述数据库写入任务对应的多个子任务;并发写入模块,用于根据对多个任务队列中各个任务队列占用的资源的加锁检测结果,将所述多个子任务并发写入所述多个任务队列。According to a second aspect of the embodiments of the present application, a device for processing database tasks is provided. The device includes: a determining module, which is used to determine information of a database write task corresponding to the write request according to a write request to the database; a decomposition module, which is used to decompose the database write task to obtain all The multiple subtasks corresponding to the database write task; the concurrent write module is used to write the multiple subtasks concurrently to the multiple task queues according to the lock detection results of the resources occupied by each task queue in the multiple task queues Task queue.
根据本申请实施例的第三方面,提供了一种电子设备,包括:一个或多个处理器;计算机可读介质,配置为存储一个或多个程序,当所述一个或多个程序被所述一个或多个处理器执行,使得所述一个或多个处理器实现如上述实施例的第一方面所述的数据库任务的处理方法。According to a third aspect of the embodiments of the present application, there is provided an electronic device, including: one or more processors; a computer-readable medium configured to store one or more programs, when the one or more programs are The one or more processors execute, so that the one or more processors implement the method for processing database tasks as described in the first aspect of the foregoing embodiment.
根据本申请实施例的第四方面,提供了一种计算机可读介质,其上存储有计算机程序,该程序被处理器执行时实现如上述实施例的第一方面所述的数据库任务的处理方法。According to a fourth aspect of the embodiments of the present application, there is provided a computer-readable medium having a computer program stored thereon, and when the program is executed by a processor, the method for processing database tasks as described in the first aspect of the above-mentioned embodiment is implemented .
通过本申请实施例提供的技术方案,根据对数据库的写入请求,确定写入请求对应的数据库写入任务的信息,并对数据库写入任务进行分解,获得数据库写入任务对应的多个子任务,再根据对多个任务队列中各个任务队列占用的资源的加锁检测结果,将多个子任务并发写入多个任务队列,与现有的其它方式相比,能够减少数据库系统的计算资源的损耗,进而有效提高数据库系统的任务吞吐量。According to the technical solution provided by the embodiments of the present application, according to the write request to the database, the information of the database write task corresponding to the write request is determined, and the database write task is decomposed to obtain multiple subtasks corresponding to the database write task. , And then based on the lock detection results of the resources occupied by each task queue in the multiple task queues, multiple subtasks are concurrently written into multiple task queues. Compared with other existing methods, the computing resources of the database system can be reduced. Loss, thereby effectively improving the task throughput of the database system.
附图说明Description of the drawings
通过阅读参照以下附图所作的对非限制性实施例所作的详细描述,本申请的其它特征、目的和优点将会变得更明显:By reading the detailed description of the non-limiting embodiments with reference to the following drawings, other features, purposes and advantages of the present application will become more apparent:
图1为本申请实施例一中数据库任务的处理方法的步骤流程图;FIG. 1 is a flowchart of the steps of a method for processing database tasks in Embodiment 1 of the application;
图2为本申请实施例二中数据库任务的处理方法的步骤流程图;2 is a flowchart of the steps of the method for processing database tasks in the second embodiment of this application;
图3为本申请实施例三中数据库任务的处理装置的结构示意图;3 is a schematic structural diagram of a processing device for database tasks in Embodiment 3 of this application;
图4为本申请实施例四中数据库任务的处理装置的结构示意图;4 is a schematic structural diagram of a processing device for database tasks in Embodiment 4 of this application;
图5为本申请实施例五中数据库任务的处理装置的结构示意图;5 is a schematic structural diagram of a processing device for database tasks in Embodiment 5 of this application;
图6为本申请实施例六中电子设备的结构示意图;6 is a schematic diagram of the structure of the electronic device in the sixth embodiment of the application;
图7为本申请实施例七中电子设备的硬件结构。FIG. 7 is the hardware structure of the electronic device in the seventh embodiment of the application.
具体实施方式Detailed ways
下面结合附图和实施例对本申请作进一步的详细说明。可以理解的是,此处所描述的具体实施例仅仅配置为解释相关发明,而非对该发明的限定。另外还需要说明的是,为了便于描述,附图中仅示出了与有关发明相关的部分。The application will be further described in detail below with reference to the drawings and embodiments. It can be understood that the specific embodiments described here are only configured to explain the related invention, but not to limit the invention. In addition, it should be noted that, for ease of description, only the parts related to the relevant invention are shown in the drawings.
需要说明的是,在不冲突的情况下,本申请中的实施例及实施例中的特征可以相互组合。下面将参考附图并结合实施例来详细说明本申请。It should be noted that the embodiments in this application and the features in the embodiments can be combined with each other if there is no conflict. Hereinafter, the present application will be described in detail with reference to the drawings and in conjunction with embodiments.
参照图1,示出了本申请实施例一的数据库任务的处理方法的步骤流程图。1, it shows a flowchart of the steps of a method for processing a database task in Embodiment 1 of the present application.
具体地,本实施例的数据库任务的处理方法包括以下步骤:Specifically, the method for processing database tasks in this embodiment includes the following steps:
在步骤S101中,根据对数据库的写入请求,确定所述写入请求对应的数据库写入任务的信息。In step S101, the information of the database write task corresponding to the write request is determined according to the write request to the database.
本发明实施例提供的方案可应用于基于LSM结构的数据库,包括但不限于X-DB数据库、LevelDB数据库、RocksDB数据库等。The solutions provided by the embodiments of the present invention can be applied to databases based on the LSM structure, including but not limited to X-DB databases, LevelDB databases, RocksDB databases, and the like.
在本实施例中,所述写入请求可包括数据库事务写入请求,或者针对数据库的操作的写入请求等。所述数据库写入任务的信息可包括数据库事务对应的写入任务的信息,如,写日志信息、数据库事务的日志数据的刷盘信息、数据库事务的写内存信息,或者数据库事务的提交信息等。可以理解的是,以上描述仅为示例性的,本申请实施例对此不做任何限定。In this embodiment, the write request may include a database transaction write request, or a write request for database operations. The information of the database write task may include the information of the write task corresponding to the database transaction, such as the write log information, the flushing information of the log data of the database transaction, the write memory information of the database transaction, or the commit information of the database transaction, etc. . It can be understood that the above description is only exemplary, and the embodiments of the present application do not make any limitation thereto.
在一些可选实施例中,在确定所述写入请求对应的数据库写入任务的信息时,可对所述写入请求进行解析,以获得所述写入请求对应的数据库写入任务的信息。可以理解的是,以上描述仅为示例性的,本申请实施例对此不做任何限定。In some optional embodiments, when the information of the database write task corresponding to the write request is determined, the write request may be parsed to obtain the information of the database write task corresponding to the write request . It can be understood that the above description is only exemplary, and the embodiments of the present application do not make any limitation thereto.
在步骤S102中,对所述数据库写入任务进行分解,获得所述数据库写入任务对应的多个子任务。In step S102, the database writing task is decomposed to obtain multiple subtasks corresponding to the database writing task.
在一些可选实施例中,对所述数据库写入任务进行分解可以采用任意适当的方式实现,以获得所述数据库写入任务对应的多个子任务。一般来说,数据库写入任务可以分为多个不同的写入逻辑,每个写入逻辑又可以对应有多个子逻辑,基于此,可对数据库写入任务进行分解,以获得不同的写入逻辑和/或不同的子逻辑对应的子任务。例如,对于WAL写入任务,其可包括写活跃内存表任务、写冻结内存表任务、持久化存储任务等。又例如,某一写入任务一次可能写入一批数据,则可以将该写入任务分解为多个子任务,每个子任务写入其中的一部分数据,等等。可以理解的是,以上描述仅为示例性的,本申请实施例对此不做任何限定。In some optional embodiments, the decomposition of the database writing task may be implemented in any suitable manner to obtain multiple subtasks corresponding to the database writing task. Generally speaking, database writing tasks can be divided into multiple different writing logics, and each writing logic can correspond to multiple sub-logics. Based on this, database writing tasks can be decomposed to obtain different writing Logic and/or subtasks corresponding to different sub-logics. For example, for WAL writing tasks, it may include writing active memory table tasks, writing frozen memory table tasks, persistent storage tasks, and so on. For another example, if a certain write task may write a batch of data at a time, the write task can be divided into multiple subtasks, and each subtask writes part of the data, and so on. It can be understood that the above description is only exemplary, and the embodiments of the present application do not make any limitation thereto.
在步骤S103中,根据对多个任务队列中各个任务队列占用的资源的加锁检测结果,将所述多个子任务并发写入所述多个任务队列。In step S103, the multiple subtasks are concurrently written into the multiple task queues according to the lock detection result on the resources occupied by each task queue in the multiple task queues.
每个任务的执行都需要一定的资源支持,本实施例中,对子任务进行分组以组成任务队列,以任务队列为单位分配资源,每组任务队列可以容纳多个(两个及两个以上) 子任务。在需要将子任务写入任务队列时,可以根据各个任务队列的加锁情况,将子任务写入未加锁的任务队列。The execution of each task requires a certain amount of resource support. In this embodiment, subtasks are grouped to form a task queue, and resources are allocated in units of task queues. Each group of task queues can accommodate multiple (two or more) ) Subtasks. When the subtask needs to be written into the task queue, the subtask can be written into the unlocked task queue according to the lock status of each task queue.
在本实施例中,采用多组槽位Slot,每组Slot对应有一个任务队列。所述多个子任务可在任意组Slot对应的任务队列上尝试组织子任务的分组group。可以理解的是,以上描述仅为示例性的,本申请实施例对此不做任何限定。In this embodiment, multiple sets of slot slots are used, and each set of slots corresponds to a task queue. The multiple subtasks may try to organize the grouping of subtasks on the task queue corresponding to any group Slot. It can be understood that the above description is only exemplary, and the embodiments of the present application do not make any limitation thereto.
在一些可选实施例中,在根据对多个任务队列中各个任务队列占用的资源的加锁检测结果,将所述多个子任务并发写入所述多个任务队列时,从所述多个任务队列中选择一个任务队列,判断选择的任务队列是否已被加锁;若已被加锁,则从剩余的任务队列中再选择一个任务队列,并将待加入的子任务加入再选择的任务队列;若未被加锁,则将所述待加入的子任务加入所述选择的任务队列。具体地,通过选择的任务队列的加锁标志位,判断选择的任务队列是否已被加锁,若判断选择的队列已被加锁,立即判断其他组槽位对应的任务队列是否已被加锁。籍此,通过对任务队列占用的资源进行加锁的方式,可保证该任务队列中加入的子任务的执行效率。可以理解的是,以上描述仅为示例性的,本申请实施例对此不做任何限定。In some optional embodiments, when the multiple subtasks are concurrently written to the multiple task queues according to the lock detection result on the resources occupied by each task queue in the multiple task queues, Select a task queue in the task queue to determine whether the selected task queue has been locked; if it has been locked, select another task queue from the remaining task queues, and add the subtasks to be added to the selected task Queue; if it is not locked, add the subtask to be added to the selected task queue. Specifically, through the lock flag bit of the selected task queue, it is determined whether the selected task queue has been locked. If it is determined that the selected queue has been locked, it is immediately determined whether the task queues corresponding to other group slots have been locked. . Accordingly, by locking the resources occupied by the task queue, the execution efficiency of the subtasks added to the task queue can be guaranteed. It can be understood that the above description is only exemplary, and the embodiments of the present application do not make any limitation thereto.
在一个具体的例子中,可通过trylock机制,对任务队列占用的资源进行加锁。具体地,任务队列的执行线程以很轻量的方式先尝试加锁一次,如果加锁成功就正常执行。如果加锁失败,线程也不会阻塞,而是立即退出内核做其他任务。可以理解的是,以上描述仅为示例性的,本申请实施例对此不做任何限定。In a specific example, the trylock mechanism can be used to lock the resources occupied by the task queue. Specifically, the execution thread of the task queue first tries to lock once in a very lightweight manner, and executes normally if the lock is successful. If the lock fails, the thread will not block, but immediately exit the kernel to do other tasks. It can be understood that the above description is only exemplary, and the embodiments of the present application do not make any limitation thereto.
在一些可选实施例中,所述方法还包括:对于所述各个任务队列,为首个加入当前任务队列的子任务分配执行线程,其中,所述执行线程用于执行所述当前任务队列中的所有子任务。籍此,不需要为当前任务队列中的所有子任务都分配执行线程,减少了数据库系统的并发线程的数量,进而减少了数据库系统针对执行线程的工作状态的调度开销。可以理解的是,以上描述仅为示例性的,本申请实施例对此不做任何限定。In some optional embodiments, the method further includes: for each task queue, allocating an execution thread for the first subtask to be added to the current task queue, wherein the execution thread is used to execute the tasks in the current task queue All subtasks. In this way, it is not necessary to allocate execution threads to all subtasks in the current task queue, which reduces the number of concurrent threads of the database system, and thereby reduces the scheduling overhead of the database system for the working status of the execution threads. It can be understood that the above description is only exemplary, and the embodiments of the present application do not make any limitation thereto.
在一个具体的例子中,为第一个进入槽位对应的任务队列的子任务分配执行线程,该执行线程用于执行该任务队列中的所有子任务。也就是说,该执行线程在该任务队列中处于“领导”地位。可以理解的是,以上描述仅为示例性的,本申请实施例对此不做任何限定。In a specific example, an execution thread is allocated to the first subtask that enters the task queue corresponding to the slot, and the execution thread is used to execute all the subtasks in the task queue. In other words, the execution thread is in the "leader" position in the task queue. It can be understood that the above description is only exemplary, and the embodiments of the present application do not make any limitation thereto.
在一些可选实施例中,所述方法还包括:若所述当前任务队列中的所有子任务执行完毕,则对所述当前任务队列进行资源解锁;根据解锁后的所述当前任务队列的空闲等待时间和/或再次接收的子任务的信息,对所述当前任务队列对应的执行线程进行处理。 其中,所述空闲等待时间可包括空闲等待时间段,所述再次接收的子任务的信息可包括再次接收的子任务的数量。籍此,在保证任务执行的同时,能够有效的节约数据库系统的计算资源。可以理解的是,以上描述仅为示例性的,本申请实施例对此不做任何限定。In some optional embodiments, the method further includes: if all the subtasks in the current task queue are executed, unlocking the resources of the current task queue; according to the idleness of the current task queue after unlocking The waiting time and/or the subtask information received again is processed on the execution thread corresponding to the current task queue. Wherein, the idle waiting time may include an idle waiting time period, and the information of the subtasks received again may include the number of subtasks received again. In this way, while ensuring task execution, the computing resources of the database system can be effectively saved. It can be understood that the above description is only exemplary, and the embodiments of the present application do not make any limitation thereto.
在一个具体的例子中,在根据解锁后的所述当前任务队列的空闲等待时间或再次接收的子任务的信息,对所述当前任务队列对应的执行线程进行处理,包括:若在所述空闲等待时间的时间段内未再次接收到新的子任务,则释放所述执行线程与所述当前任务队列的对应关系;若在所述空闲等待时间的时间段内再次接收到新的子任务,且所述新的子任务的数量达到预设阈值,则唤醒所述执行线程,并通过所述执行线程执行所述新的子任务。其中,所述空闲等待时间的时间段可由本领域技术人员根据实际需要进行设定,本申请实施例对此不做任何限定。所述预设阈值可由本领域技术人员根据实际需要进行设定,本申请实施例对此不做任何限定。可以理解的是,以上描述仅为示例性的,本申请实施例对此不做任何限定。In a specific example, processing the execution thread corresponding to the current task queue according to the idle waiting time of the current task queue after unlocking or the information of the subtask received again includes: If no new subtask is received again within the waiting time period, the corresponding relationship between the execution thread and the current task queue is released; if a new subtask is received again within the idle waiting time period, And the number of the new subtasks reaches the preset threshold, the execution thread is awakened, and the new subtasks are executed through the execution thread. Wherein, the time period of the idle waiting time can be set by those skilled in the art according to actual needs, which is not limited in the embodiment of the present application. The preset threshold can be set by those skilled in the art according to actual needs, and the embodiment of the present application does not make any limitation on this. It can be understood that the above description is only exemplary, and the embodiments of the present application do not make any limitation thereto.
在一个具体的例子中,若在所述空闲等待时间的时间段内未再次接收到新的子任务,则所述执行线程自发地由休眠状态切换至唤醒状态,然后释放所述执行线程与所述当前任务队列的对应关系。若在所述空闲等待时间的时间段内再次接收到新的子任务,且所述新的子任务的数量达到预设阈值,则通过为最后一个进入所述当前任务队列的所述新的子任务分配的辅助线程触发所述执行线程的唤醒。若在所述空闲等待时间的时间段内再次接收到新的子任务,且所述新的子任务的数量未达到预设阈值,则通过为最后一个进入所述当前任务队列的所述新的子任务分配的辅助线程触发所述执行线程的唤醒,并通过所述执行线程执行所述新的子任务。可以理解的是,以上描述仅为示例性的,本申请实施例对此不做任何限定。In a specific example, if a new subtask is not received again within the period of the idle waiting time, the execution thread automatically switches from the sleep state to the wake state, and then releases the execution thread and all the subtasks. Describe the corresponding relationship of the current task queue. If a new subtask is received again within the time period of the idle waiting time, and the number of the new subtask reaches the preset threshold, the new subtask is passed as the last one to enter the current task queue. The auxiliary thread assigned by the task triggers the wake-up of the execution thread. If a new subtask is received again within the time period of the idle waiting time, and the number of the new subtask does not reach the preset threshold, the new subtask is passed as the last one to enter the current task queue. The auxiliary thread allocated by the subtask triggers the awakening of the execution thread, and the new subtask is executed through the execution thread. It can be understood that the above description is only exemplary, and the embodiments of the present application do not make any limitation thereto.
例如,针对每个Slot,第一个进入该Slot的写入请求将成为leader,为其分配执行线程,在一个Slot中已经有leader存在时,其他进入的写入请求成为follower,为其分配辅助线程,follower会将自己的写入请求交付给leader完成。在当前Slot中的leader释放该Slot的锁之后,会cond_wait一段时间(该时间可由本领域技术人员根据实际需求配置),如果等待时间内,leader收集的follower数目超过max_group_size(一个任务队列的最大容量),则leader被唤醒(由最后一个follower触发)。否则达到超时时间后,leader自己醒来,并切换其所在Slot的leader为空(即释放leader对应的执行线程与该Slot的关系)。For example, for each Slot, the first write request to enter the Slot will become the leader, and the execution thread will be allocated to it. When a leader already exists in a Slot, other incoming write requests will become followers, which will be assigned auxiliary Thread, follower will deliver its own write request to the leader for completion. After the leader in the current Slot releases the lock of the Slot, it will cond_wait for a period of time (this time can be configured by those skilled in the art according to actual needs). If the number of followers collected by the leader exceeds max_group_size (the maximum capacity of a task queue within the waiting time) ), the leader is awakened (triggered by the last follower). Otherwise, when the timeout period is reached, the leader wakes up by itself and switches the leader of the slot where it is empty (that is, the relationship between the execution thread corresponding to the leader and the slot is released).
在一些可选实施例中,所述方法还包括:对于所述各个任务队列,为非首个加入所 述当前任务队列的子任务分配辅助线程,其中,所述辅助线程用于将非首个子任务交给所述执行线程进行处理;判断所述辅助线程是否已成功将所述非首个子任务交给所述执行线程,若是,则分配所述辅助线程获取新的子任务。这种方式可以通过异步化API实现,follower在将其子任务交给leader后,可以立即返回去处理新的子任务。而leader完成follower的任务之后则可以调用一个回调函数完成当前任务队列的清理工作。籍此,不需要为当前任务队列中的所有子任务都分配执行线程,减少了数据库系统的并发线程的数量,进而减少了数据库系统针对执行线程的工作状态的调度开销。可以理解的是,以上描述仅为示例性的,本申请实施例对此不做任何限定。需要说明的是,若在同步模式下,follower在将其子任务交给leader后,需等待leader完成工作之后,再返回去处理新的子任务。In some optional embodiments, the method further includes: for each task queue, allocating an auxiliary thread for the subtask that is not the first to join the current task queue, wherein the auxiliary thread is used to transfer the non-first subtask The task is handed over to the execution thread for processing; it is determined whether the auxiliary thread has successfully handed over the non-first subtask to the execution thread, and if so, the auxiliary thread is allocated to obtain a new subtask. This method can be implemented through an asynchronous API. After the follower gives its subtask to the leader, it can immediately return to handle the new subtask. After the leader completes the task of the follower, it can call a callback function to complete the cleaning of the current task queue. In this way, it is not necessary to allocate execution threads to all subtasks in the current task queue, which reduces the number of concurrent threads of the database system, and thereby reduces the scheduling overhead of the database system for the working status of the execution threads. It can be understood that the above description is only exemplary, and the embodiments of the present application do not make any limitation thereto. It should be noted that if in the synchronous mode, after the follower handed over its subtask to the leader, it needs to wait for the leader to complete the work before returning to process the new subtask.
通过上述方式,在判断所述辅助线程已成功将所述非首个子任务交给所述执行线程之后,可使用异步化API,分配所述辅助线程获取新的子任务。通过将任务执行线程和任务执行过程解绑,使用更少的线程服务更多的任务,减少数据库系统的线程调度带来的有效计算资源的损耗。在所述执行线程完成所述当前任务队列中的所有子任务的处理之后,调用回调函数完成清理工作。在同步模式下,所述辅助线程将等待所述执行线程完成所述当前任务队列中的所有子任务的处理之后,再返回获取新的子任务。可以理解的是,以上描述仅为示例性的,本申请实施例对此不做任何限定。In the above manner, after determining that the auxiliary thread has successfully handed over the non-first subtask to the execution thread, an asynchronous API can be used to allocate the auxiliary thread to obtain a new subtask. By unbinding task execution threads and task execution processes, fewer threads are used to serve more tasks, and the loss of effective computing resources caused by thread scheduling of the database system is reduced. After the execution thread completes the processing of all the subtasks in the current task queue, the callback function is called to complete the cleaning work. In the synchronous mode, the auxiliary thread will wait for the execution thread to complete the processing of all the subtasks in the current task queue before returning to obtain a new subtask. It can be understood that the above description is only exemplary, and the embodiments of the present application do not make any limitation thereto.
通过本申请实施例提供的数据库任务的处理方法,根据对数据库的写入请求,确定写入请求对应的数据库写入任务的信息,并对数据库写入任务进行分解,获得数据库写入任务对应的多个子任务,再根据对多个任务队列中各个任务队列占用的资源的加锁检测结果,将多个子任务并发写入多个任务队列,与现有的其它方式相比,能够减少数据库系统的计算资源的损耗,进而有效提高数据库系统的任务吞吐量。Through the database task processing method provided by the embodiments of the present application, according to the write request to the database, the information of the database write task corresponding to the write request is determined, and the database write task is decomposed to obtain the database write task corresponding Multiple subtasks, and then based on the lock detection results of the resources occupied by each task queue in the multiple task queues, write multiple subtasks concurrently into multiple task queues. Compared with other existing methods, it can reduce the database system The loss of computing resources effectively improves the task throughput of the database system.
本实施例的数据库任务的处理方法可以由任意适当的具有数据处理能力的设备执行,包括但不限于:摄像头、终端、移动终端、PC机、服务器、车载设备、娱乐设备、广告设备、个人数码助理(PDA)、平板电脑、笔记本电脑、掌上游戏机、智能眼镜、智能手表、可穿戴设备、虚拟显示设备或显示增强设备(如Google Glass、Oculus Rift、Hololens、Gear VR)等。The method for processing database tasks in this embodiment can be executed by any appropriate device with data processing capabilities, including but not limited to: cameras, terminals, mobile terminals, PCs, servers, in-vehicle devices, entertainment devices, advertising devices, and personal digital devices. Assistant (PDA), tablet computer, notebook computer, handheld game console, smart glasses, smart watch, wearable device, virtual display device or display enhancement device (such as Google Glass, Oculus Rift, Hololens, Gear VR), etc.
参照图2,示出了本申请实施例二的数据库任务的处理方法的步骤流程图。Referring to FIG. 2, there is shown a flowchart of the steps of a method for processing a database task in the second embodiment of the present application.
具体地,本实施例的数据库任务的处理方法包括以下步骤:Specifically, the method for processing database tasks in this embodiment includes the following steps:
在步骤S201中,根据对数据库的写入请求,确定所述写入请求对应的数据库写入任 务的信息。In step S201, according to the write request to the database, the information of the database write task corresponding to the write request is determined.
由于步骤S201与上述步骤S101类似,在此不再赘述。Since step S201 is similar to the above step S101, it will not be repeated here.
在步骤S202中,对所述数据库写入任务进行分解,获得所述数据库写入任务对应的多个子任务。In step S202, the database writing task is decomposed to obtain multiple subtasks corresponding to the database writing task.
由于步骤S202与上述步骤S102类似,在此不再赘述。Since step S202 is similar to the above step S102, it will not be repeated here.
在步骤S203中,根据对多个任务队列中各个任务队列占用的资源的加锁检测结果,将所述多个子任务并发写入所述多个任务队列。In step S203, the multiple subtasks are concurrently written into the multiple task queues according to the lock detection result on the resources occupied by each task queue in the multiple task queues.
由于步骤S203与上述步骤S103类似,在此不再赘述。Since step S203 is similar to the above step S103, it will not be repeated here.
在步骤S204中,若所述当前任务队列中的所有子任务均已执行完毕,则收集所有子任务对应的数据库事务日志数据,并生成对应的日志写入任务。In step S204, if all the subtasks in the current task queue have been executed, the database transaction log data corresponding to all the subtasks are collected, and the corresponding log write task is generated.
在本实施例中,所述当前任务队列的执行线程将所述当前任务队列中的所有子任务的数据库事务日志数据收集到任务的本地缓存中,并计算所述当前任务队列中的所有子任务的数据库事务日志数据的crc32校验数据。然后,生成对应的日志写入任务。可以理解的是,以上描述仅为示例性的,本申请实施例对此不做任何限定。In this embodiment, the execution thread of the current task queue collects the database transaction log data of all subtasks in the current task queue into the local cache of the task, and calculates all the subtasks in the current task queue The crc32 checksum data of the database transaction log data. Then, generate the corresponding log writing task. It can be understood that the above description is only exemplary, and the embodiments of the present application do not make any limitation thereto.
在步骤S205中,通过所述日志写入任务将所述数据库事务日志数据写入日志拷贝队列。In step S205, the database transaction log data is written into the log copy queue through the log writing task.
在一些可选实施例中,在通过所述日志写入任务将所述数据库事务日志数据写入日志拷贝队列时,所述方法还包括:为所述日志写入任务分配日志事务标识,根据所述日志事务标识判断所有日志写入任务是否全部完成。籍此,可通过日志事务标识判断所有日志写入任务是否全部完成。可以理解的是,以上描述仅为示例性的,本申请实施例对此不做任何限定。In some optional embodiments, when the database transaction log data is written into the log copy queue through the log writing task, the method further includes: allocating a log transaction identifier for the log writing task, and The log transaction identifier determines whether all log writing tasks are completed. In this way, it can be judged whether all log writing tasks are completed through the log transaction identifier. It can be understood that the above description is only exemplary, and the embodiments of the present application do not make any limitation thereto.
在一个具体的例子中,日志事务标识被记录下来存储至相应的变量中,作为该日志写入任务是否完成的依据。具体地,所述日志事务标识可为局部序列号。当当前线程是最后进入的一个线程时,其退出内核的前提条件是全局序列号大于或等于局部序列号,这样可以保证最后一个线程退出内核之前,所有日志写入任务都已经完成。可以理解的是,以上描述仅为示例性的,本申请实施例对此不做任何限定。In a specific example, the log transaction identifier is recorded and stored in the corresponding variable as a basis for whether the log writing task is completed. Specifically, the log transaction identifier may be a local serial number. When the current thread is the last thread to enter, the prerequisite for exiting the kernel is that the global sequence number is greater than or equal to the local sequence number. This ensures that all log writing tasks have been completed before the last thread exits the kernel. It can be understood that the above description is only exemplary, and the embodiments of the present application do not make any limitation thereto.
在步骤S206中,通过第一工作线程,将所述日志拷贝队列中的日志数据写入到用于存储日志数据的缓存中。In step S206, the log data in the log copy queue is written into the cache for storing log data through the first working thread.
在本实施例中,通过第一工作线程,从所述日志拷贝队列中摘取数据库事务日志数据,并将所述数据库事务日志数据写入到用于存储日志数据的缓存中。所述第一工作线 程可为前台线程或者后台线程。当所述第一工作线程可为后台线程时,可以做更精细的调度和任务分配。例如,固定分配写日志线程的数目根据机器物理CPU数目合理设置等。可以理解的是,以上描述仅为示例性的,本申请实施例对此不做任何限定。In this embodiment, the first working thread extracts database transaction log data from the log copy queue, and writes the database transaction log data into a cache for storing log data. The first working thread may be a foreground thread or a background thread. When the first working thread can be a background thread, finer scheduling and task allocation can be performed. For example, the fixed allocation of the number of log writing threads is reasonably set according to the number of physical CPUs of the machine. It can be understood that the above description is only exemplary, and the embodiments of the present application do not make any limitation thereto.
在一些可选实施例中,所述方法还包括:通过刷盘任务将所述缓存中的数据库事务日志数据发送至日志刷盘队列,以对所述数据库事务日志数据进行持久化存储;通过第二工作线程,对所述日志刷盘队列中的数据库事务日志数据进行持久化存储。籍此,能够确保日志刷盘队列中的数据库事务日志数据的持久化存储。可以理解的是,以上描述仅为示例性的,本申请实施例对此不做任何限定。In some optional embodiments, the method further includes: sending the database transaction log data in the cache to the log flushing queue through a flushing task, so as to persistently store the database transaction log data; Two working threads, which persistently store the database transaction log data in the log flushing queue. By this, it can ensure the persistent storage of the database transaction log data in the log flushing queue. It can be understood that the above description is only exemplary, and the embodiments of the present application do not make any limitation thereto.
在一个具体的例子中,所述第二工作线程可为前台线程或者后台线程。当所述第二工作线程可为后台线程时,可以做更精细的调度和任务分配。在将所述数据库事务日志数据写入到用于存储日志数据的缓存中之后生成对应的所述刷盘任务。然后,通过所述刷盘任务对所述缓存中的数据库事务日志数据进行持久化存储。可以理解的是,以上描述仅为示例性的,本申请实施例对此不做任何限定。In a specific example, the second working thread may be a foreground thread or a background thread. When the second working thread can be a background thread, finer scheduling and task allocation can be performed. After the database transaction log data is written into the cache for storing log data, the corresponding disk flushing task is generated. Then, the database transaction log data in the cache is persistently stored through the flashing task. It can be understood that the above description is only exemplary, and the embodiments of the present application do not make any limitation thereto.
在一些可选实施例中,所述通过刷盘任务将所述缓存中的日志数据发送至日志刷盘队列,包括:判断当前刷盘任务是否抢占到刷盘锁,若是,则通过所述当前刷盘任务将对应的所述日志数据发送至所述日志刷盘队列。籍此,能够实现对刷盘任务的抢占式执行。可以理解的是,以上描述仅为示例性的,本申请实施例对此不做任何限定。In some optional embodiments, the sending the log data in the cache to the log flushing queue through the flushing task includes: determining whether the current flushing task has preempted the flushing lock, and if so, passing the current The flushing task sends the corresponding log data to the log flushing queue. In this way, preemptive execution of the task of brushing can be realized. It can be understood that the above description is only exemplary, and the embodiments of the present application do not make any limitation thereto.
在一个具体的例子中,该刷盘任务只能有一个线程串行执行,因此设置了一个原子型的标志,来实现对任务的抢占式执行。可以理解的是,以上描述仅为示例性的,本申请实施例对此不做任何限定。In a specific example, the flashing task can only be executed in series by one thread, so an atomic flag is set to implement preemptive execution of the task. It can be understood that the above description is only exemplary, and the embodiments of the present application do not make any limitation thereto.
在一些可选实施例中,在所述通过刷盘任务将所述缓存中的日志数据发送至日志刷盘队列的同时,所述方法还包括:记录所述日志数据对应的编号,并根据所述编号,将对应的日志数据发送至写内存表队列。籍此,能够确保将完成刷盘的日志数据发送至写内存表队列。可以理解的是,以上描述仅为示例性的,本申请实施例对此不做任何限定。In some optional embodiments, while the log data in the cache is sent to the log flushing queue through the flushing task, the method further includes: recording the number corresponding to the log data, and according to the Specify the number and send the corresponding log data to the write memory table queue. With this, it can be ensured that the log data that has been flushed is sent to the write memory table queue. It can be understood that the above description is only exemplary, and the embodiments of the present application do not make any limitation thereto.
在一个具体的例子中,第二工作线程会尝试对缓存中的数据库事务日志数据进行刷盘,当数据库事务日志数据的日志序列号有推进时,从日志刷盘队列中摘取满足条件的当数据库事务日志数据。具体地,当当前进行刷盘的数据库事务日志数据的日志序列号大于日志刷盘队列中的数据库事务日志数据的日志序列号时,从日志刷盘队列中摘取相应的数据库事务日志数据。可以理解的是,以上描述仅为示例性的,本申请实施例对此不做任何限定。In a specific example, the second worker thread will try to flush the database transaction log data in the cache. When the log sequence number of the database transaction log data advances, it will extract the current transactions that meet the conditions from the log flush queue. Database transaction log data. Specifically, when the log sequence number of the database transaction log data currently being flushed is greater than the log sequence number of the database transaction log data in the log flushing queue, the corresponding database transaction log data is extracted from the log flushing queue. It can be understood that the above description is only exemplary, and the embodiments of the present application do not make any limitation thereto.
在一些可选实施例中,所述方法还包括:通过多个写内存表任务,将所述写内存表队列中的日志数据并发写入内存表。籍此,能够将数据库事务日志数据并发写入内存表。可以理解的是,以上描述仅为示例性的,本申请实施例对此不做任何限定。In some optional embodiments, the method further includes: concurrently writing the log data in the memory table writing queue to the memory table through multiple memory table writing tasks. With this, the database transaction log data can be written into the memory table concurrently. It can be understood that the above description is only exemplary, and the embodiments of the present application do not make any limitation thereto.
在一个具体的例子中,在通过第二工作线程,对所述日志刷盘队列中的数据库事务日志数据进行持久化存储之后,生成对应的多个写内存表任务。然后,通过多个写内存表任务,将所述写内存表队列中的数据库事务日志数据并发写入内存表。该多个写内存表任务可以并发执行,大部分工作线程集中在这个地方,并发的从写内存表中获取数据库事务日志数据,并执行写内存表的操作。可以理解的是,以上描述仅为示例性的,本申请实施例对此不做任何限定。In a specific example, after persistently storing the database transaction log data in the log flushing queue through the second working thread, multiple corresponding memory table writing tasks are generated. Then, the database transaction log data in the memory table write queue is concurrently written into the memory table through multiple tasks of writing the memory table. The multiple tasks of writing memory tables can be executed concurrently, and most of the work threads are concentrated in this place, and concurrently obtain database transaction log data from the writing memory tables, and perform the operation of writing the memory tables. It can be understood that the above description is only exemplary, and the embodiments of the present application do not make any limitation thereto.
在一些可选实施例中,所述通过多个写内存表任务,将所述写内存表队列中的日志数据并发写入内存表,包括:获取已提交的写内存表任务的任务编号;将连续的多个任务编号中最大的任务编号确定为当前任务编号;根据当前任务编号判断所述多个写内存表任务是否全部完成。籍此,通过任务编号能够确保多个写内存表任务的完成。可以理解的是,以上描述仅为示例性的,本申请实施例对此不做任何限定。In some optional embodiments, the concurrently writing the log data in the memory table writing queue to the memory table through multiple memory table writing tasks includes: obtaining the task number of the submitted memory table writing task; The largest task number among the consecutive task numbers is determined as the current task number; according to the current task number, it is determined whether the multiple tasks of writing memory tables are all completed. In this way, the task number can ensure the completion of multiple tasks of writing memory tables. It can be understood that the above description is only exemplary, and the embodiments of the present application do not make any limitation thereto.
在一个具体的例子中,任务编号1,2,3,6对应的写内存表任务都已经执行完毕,但任务编号4,5对应的写内存表任务还未执行完,此时当前任务编号更新为3。当任务编号4,5对应的写内存表任务执行完之后,当前任务编号更新为6。可以理解的是,以上描述仅为示例性的,本申请实施例对此不做任何限定。In a specific example, the memory table writing tasks corresponding to task numbers 1, 2, 3, and 6 have all been executed, but the memory table writing tasks corresponding to task numbers 4 and 5 have not been executed yet, and the current task number is updated at this time Is 3. After the task of writing memory table corresponding to task numbers 4 and 5 is executed, the current task number is updated to 6. It can be understood that the above description is only exemplary, and the embodiments of the present application do not make any limitation thereto.
在一些可选实施例中,所述方法还包括:通过多个提交任务对已提交的多个写内存表任务进行清理操作。籍此,能够对已提交的多个写内存表任务进行清理操作。可以理解的是,以上描述仅为示例性的,本申请实施例对此不做任何限定。In some optional embodiments, the method further includes: performing a cleanup operation on multiple submitted tasks for writing memory tables through multiple submission tasks. With this, it is possible to clean up multiple submitted tasks for writing memory tables. It can be understood that the above description is only exemplary, and the embodiments of the present application do not make any limitation thereto.
在一个具体的例子中,当写内存表任务的任务编号推进时,达到提交条件的内存表任务会被推送到执行队列中。具体地,当当前任务编号为待提交的内存表任务的任务编号时,待提交的内存表任务会被推送到执行队列中进行清理操作。执行队列中内存表任务的清理操作可以并发执行。具体地,对内存表任务占用的计算资源进行放锁,并回收内存表任务占用的内存。更具体地,调用回调函数完成清理工作。在同步模式下,任务被提交后,需要唤醒等待任务提交的线程,并回包。在异步模式下,用回调函数完成任务的放锁,内存的释放。当单机存储引擎X-Engine作为MySQL数据库的一个引擎时,此处回调函数还需要完成向客户端的回包任务。可以理解的是,以上描述仅为示例性的,本申请实施例对此不做任何限定。In a specific example, when the task number of the memory table writing task advances, the memory table task that meets the submission condition will be pushed to the execution queue. Specifically, when the current task number is the task number of the memory table task to be submitted, the memory table task to be submitted will be pushed to the execution queue for cleaning. The cleaning operations of the memory table tasks in the execution queue can be executed concurrently. Specifically, locks are released on the computing resources occupied by the memory table task, and the memory occupied by the memory table task is reclaimed. More specifically, call the callback function to complete the cleanup work. In the synchronous mode, after the task is submitted, it is necessary to wake up the thread waiting for the task to be submitted and return the package. In asynchronous mode, use the callback function to complete the task lock and memory release. When the stand-alone storage engine X-Engine is used as an engine of the MySQL database, the callback function here also needs to complete the task of returning the package to the client. It can be understood that the above description is only exemplary, and the embodiments of the present application do not make any limitation thereto.
由此可见,通过拆分更小粒度的任务执行阶段,让IO设备的工作和CPU计算设备的工作达到均衡,互相不等待,从而数据库系统达到最高的任务吞吐量。It can be seen that, by splitting the task execution phase of a smaller granularity, the work of the IO device and the work of the CPU computing device are balanced without waiting for each other, so that the database system achieves the highest task throughput.
以下,以一个具体实例对上述过程进行示例性说明。例如,一个group(任务队列)从Slot中出队之后,该Slot的leader会将该Slot的所有follower的日志收集到大的write batch中,同时计算好WAL日志的crc32校验;然后,将日志写入任务push到日志拷贝队列,此处push到日志拷贝队列的同时会为日志写入任务分配事务ID,此事务ID会记录下来存在local_expected_sequence_number中,作为该事务能否退出流水线的依据,当当前线程是流水线中最后进入的一个线程时,其退出的前提条件是全局global_version_sequence_number>=local_exptec_sequence_number,这样可以保证最后一个线程退出之前,所有任务队列都被清空。第一工作线程从拷贝日志队列中摘取日志写入任务写入的日志内容,将日志内容写入到WAL日志模块的buffer中,记录lsn(日志数据对应的编号),然后将写内存表的任务push到日志刷盘队列。该部分任务只能有一个线程串行执行,因此设置了一个原子型的flag,来实现对任务的抢占式执行。而对于日志刷盘队列,该队列中的任务,其日志内容已经写到日志buffer,但没有刷盘。工作线程会尝试去日志模块中对buffer进行刷盘,当日志文件的lsn有推进时,会从日志刷盘队列中摘取满足条件的(flush_lsn>append_lsn)任务,并push到write memtable队列。writememtable队列中的任务是都已经完成日志刷盘,等待写内存表的任务,该部分任务可以并发执行,大部分工作线程集中在这个地方,并发的从write_memtable_queue中获取任务并执行写内存表的操作。由于写到内存表中的数据,读取操作就可以读取到了,为了保证一致性,需要维护一个滑动窗口来负责更新全局读版本号,例如事务1,2,3,6都已经执行完毕,但事务4,5还未执行完,此时全局版本号更新为3。当4,5提交之后,全局版本号更新为6。当全局版本号推进时,达到提交条件的任务会被push到commit_queue中。commit_queue中的任务是需要完成提交、解锁和内存的回收等,该部分任务可以并发执行。在同步模式下,事务提交后,需要唤醒等待事务提交的线程,并回包。在异步模式下,用一个回调函数完成事务的放锁,内存的释放。当作为MySQL的一个引擎时,此处回调函数还需要完成向client端的回包任务。Below, a specific example is used to illustrate the above process. For example, after a group (task queue) is dequeued from the slot, the leader of the slot will collect the logs of all the followers of the slot into a large write batch, and calculate the crc32 check of the WAL log; then, the log The write task is pushed to the log copy queue. When pushed to the log copy queue, a transaction ID will be assigned to the log write task. This transaction ID will be recorded and stored in the local_expected_sequence_number as the basis for whether the transaction can exit the pipeline. When a thread is the last entry thread in the pipeline, the precondition for its exit is that the global global_version_sequence_number>=local_exptec_sequence_number, so as to ensure that all task queues are emptied before the last thread exits. The first worker thread extracts the log content written by the log writing task from the copy log queue, writes the log content into the buffer of the WAL log module, records the lsn (the number corresponding to the log data), and then writes the contents of the memory table Push the task to the log flushing queue. This part of the task can only be executed serially by one thread, so an atomic flag is set to achieve preemptive execution of the task. As for the log flushing queue, the log content of the tasks in the queue has been written to the log buffer, but there is no flushing. The worker thread will try to flush the buffer in the log module. When the lsn of the log file is advanced, it will extract the (flush_lsn>append_lsn) task that meets the conditions from the log flush queue and push it to the write memtable queue. The tasks in the writememtable queue have completed the log flushing and are waiting for the task of writing the memory table. This part of the task can be executed concurrently. Most of the work threads are concentrated in this place, and concurrently obtain tasks from write_memtable_queue and execute the operation of writing the memory table. . Because of the data written to the memory table, the read operation can be read. In order to ensure consistency, a sliding window needs to be maintained to update the global read version number. For example, transactions 1, 2, 3, and 6 have been executed. But transactions 4 and 5 have not been executed yet, and the global version number is updated to 3. When 4 and 5 are submitted, the global version number is updated to 6. When the global version number advances, tasks that meet the submission conditions will be pushed to commit_queue. The tasks in commit_queue need to complete submission, unlocking and memory recovery, etc. This part of the task can be executed concurrently. In the synchronous mode, after the transaction is committed, the thread waiting for the transaction to be submitted needs to be awakened and returned to the package. In asynchronous mode, a callback function is used to complete the transaction lock and memory release. When used as an engine of MySQL, the callback function here also needs to complete the task of returning the package to the client.
在本申请实施例一的基础上,若当前任务队列中的所有子任务均已执行完毕,则收集所有子任务对应的数据库事务日志数据,并生成对应的日志写入任务,再通过日志写入任务将数据库事务日志数据写入日志拷贝队列,再通过第一工作线程,将日志拷贝队列中的数据库事务日志数据写入到用于存储日志数据的缓存中,与现有其它方式相比, 能够将均已执行完毕的子任务对应的数据库事务日志数据写入到用于存储日志数据的缓存中,从而保证数据库任务执行的一致性。On the basis of the first embodiment of this application, if all subtasks in the current task queue have been executed, the database transaction log data corresponding to all subtasks are collected, and the corresponding log writing task is generated, and then the log writing The task writes database transaction log data into the log copy queue, and then through the first working thread, writes the database transaction log data in the log copy queue into the cache for storing log data. Compared with other existing methods, it can The database transaction log data corresponding to the subtasks that have been executed are written into the cache for storing the log data, thereby ensuring the consistency of the execution of the database tasks.
本实施例的数据库任务的处理方法可以由任意适当的具有数据处理能力的设备执行,包括但不限于:摄像头、终端、移动终端、PC机、服务器、车载设备、娱乐设备、广告设备、个人数码助理(PDA)、平板电脑、笔记本电脑、掌上游戏机、智能眼镜、智能手表、可穿戴设备、虚拟显示设备或显示增强设备(如Google Glass、Oculus Rift、Hololens、Gear VR)等。The method for processing database tasks in this embodiment can be executed by any appropriate device with data processing capabilities, including but not limited to: cameras, terminals, mobile terminals, PCs, servers, in-vehicle devices, entertainment devices, advertising devices, and personal digital devices. Assistant (PDA), tablet computer, notebook computer, handheld game console, smart glasses, smart watch, wearable device, virtual display device or display enhancement device (such as Google Glass, Oculus Rift, Hololens, Gear VR), etc.
参照图3,示出了本申请实施例三中数据库任务的处理装置的结构示意图。Referring to FIG. 3, there is shown a schematic structural diagram of an apparatus for processing database tasks in Embodiment 3 of the present application.
本实施例的数据库任务的处理装置包括:确定模块301,用于根据对数据库的写入请求,确定所述写入请求对应的数据库写入任务的信息;分解模块302,用于对所述数据库写入任务进行分解,获得所述数据库写入任务对应的多个子任务;并发写入模块303,用于根据对多个任务队列中各个任务队列占用的资源的加锁检测结果,将所述多个子任务并发写入所述多个任务队列。The database task processing device of this embodiment includes: a determining module 301, configured to determine the information of the database write task corresponding to the write request according to a write request to the database; and a decomposition module 302, configured to check the database The writing task is decomposed to obtain multiple subtasks corresponding to the database writing task; the concurrent writing module 303 is configured to detect the multiple task queues according to the lock detection result of the resources occupied by each task queue in the multiple task queues. The subtasks are concurrently written into the multiple task queues.
本实施例的数据库任务的处理装置用于实现前述多个方法实施例中相应的数据库任务的处理方法,并具有相应的方法实施例的有益效果,在此不再赘述。The database task processing apparatus of this embodiment is used to implement the corresponding database task processing methods in the foregoing multiple method embodiments, and has the beneficial effects of the corresponding method embodiments, which will not be repeated here.
参照图4,示出了本申请实施例四中数据库任务的处理装置的结构示意图。Referring to FIG. 4, there is shown a schematic structural diagram of a database task processing device in the fourth embodiment of the present application.
本实施例的数据库任务的处理装置包括:确定模块401,用于根据对数据库的写入请求,确定所述写入请求对应的数据库写入任务的信息;分解模块402,用于对所述数据库写入任务进行分解,获得所述数据库写入任务对应的多个子任务;并发写入模块403,用于根据对多个任务队列中各个任务队列占用的资源的加锁检测结果,将所述多个子任务并发写入所述多个任务队列。The database task processing device of this embodiment includes: a determining module 401, configured to determine the database write task information corresponding to the write request according to a write request to the database; The writing task is decomposed to obtain multiple subtasks corresponding to the database writing task; the concurrent writing module 403 is configured to detect the multiple task queues according to the lock detection result of the resources occupied by each task queue in the multiple task queues. The subtasks are concurrently written into the multiple task queues.
可选地,所述并发写入模块403,具体用于:从所述多个任务队列中选择一个任务队列,判断选择的任务队列是否已被加锁;若已被加锁,则从剩余的任务队列中再选择一个任务队列,并将待加入的子任务加入再选择的任务队列;若未被加锁,则将所述待加入的子任务加入所述选择的任务队列。Optionally, the concurrent writing module 403 is specifically configured to: select a task queue from the multiple task queues, and determine whether the selected task queue has been locked; if it has been locked, select a task queue from the remaining Another task queue is selected from the task queue, and the subtask to be added is added to the selected task queue; if it is not locked, the subtask to be added is added to the selected task queue.
可选地,所述装置还包括:第一分配模块404,用于对于所述各个任务队列,为首个加入当前任务队列的子任务分配执行线程,其中,所述执行线程用于执行所述当前任务队列中的所有子任务。Optionally, the device further includes: a first allocation module 404, configured to allocate an execution thread for the first subtask added to the current task queue for each task queue, wherein the execution thread is used to execute the current task queue. All subtasks in the task queue.
可选地,所述装置还包括:资源解锁模块405,用于若所述当前任务队列中的所有子任务执行完毕,则对所述当前任务队列进行资源解锁;处理模块406,用于根据解锁 后的所述当前任务队列的空闲等待时间和/或再次接收的子任务的信息,对所述当前任务队列对应的执行线程进行处理。Optionally, the device further includes: a resource unlocking module 405, configured to unlock the resources of the current task queue if all subtasks in the current task queue are executed; a processing module 406, configured to unlock resources according to the unlock The subsequent idle waiting time of the current task queue and/or the information of the subtask received again is processed on the execution thread corresponding to the current task queue.
可选地,所述处理模块406,具体用于:若在所述空闲等待时间的时间段内未再次接收到新的子任务,则释放所述执行线程与所述当前任务队列的对应关系;若在所述空闲等待时间的时间段内再次接收到新的子任务,且所述新的子任务的数量达到预设阈值,则唤醒所述执行线程,并通过所述执行线程执行所述新的子任务。Optionally, the processing module 406 is specifically configured to: if a new subtask is not received again within the idle waiting time period, release the corresponding relationship between the execution thread and the current task queue; If a new subtask is received again within the period of the idle waiting time, and the number of the new subtask reaches the preset threshold, the execution thread is awakened, and the new execution thread is executed Of subtasks.
可选地,所述装置还包括:第二分配模块407,用于对于所述各个任务队列,为非首个加入所述当前任务队列的子任务分配辅助线程,其中,所述辅助线程用于将非首个子任务交给所述执行线程进行处理;第三分配模块408,用于判断所述辅助线程是否已成功将所述非首个子任务交给所述执行线程,若是,则分配所述辅助线程获取新的子任务。Optionally, the device further includes: a second allocation module 407, configured to allocate auxiliary threads to the subtasks that are not the first to join the current task queue for each task queue, wherein the auxiliary thread is used for The non-first subtask is handed over to the execution thread for processing; the third allocation module 408 is used to determine whether the auxiliary thread has successfully handed over the non-first subtask to the execution thread, and if so, allocate the The auxiliary thread acquires a new subtask.
本实施例的数据库任务的处理装置用于实现前述多个方法实施例中相应的数据库任务的处理方法,并具有相应的方法实施例的有益效果,在此不再赘述。The database task processing apparatus of this embodiment is used to implement the corresponding database task processing methods in the foregoing multiple method embodiments, and has the beneficial effects of the corresponding method embodiments, which will not be repeated here.
参照图5,示出了本申请实施例五中数据库任务的处理装置的结构示意图。Referring to FIG. 5, there is shown a schematic structural diagram of a database task processing device in Embodiment 5 of the present application.
本实施例的数据库任务的处理装置包括:确定模块501,用于根据对数据库的写入请求,确定所述写入请求对应的数据库写入任务的信息;分解模块502,用于对所述数据库写入任务进行分解,获得所述数据库写入任务对应的多个子任务;并发写入模块503,用于根据对多个任务队列中各个任务队列占用的资源的加锁检测结果,将所述多个子任务并发写入所述多个任务队列。The database task processing device of this embodiment includes: a determining module 501, configured to determine the information of the database write task corresponding to the write request according to a write request to the database; and a decomposition module 502, configured to check the database The writing task is decomposed to obtain multiple subtasks corresponding to the database writing task; the concurrent writing module 503 is configured to detect the multiple task queues according to the lock detection result of the resources occupied by each task queue in the multiple task queues. The subtasks are concurrently written into the multiple task queues.
可选地,所述装置还包括:收集模块504,用于若所述当前任务队列中的所有子任务均已执行完毕,则收集所有子任务对应的数据库事务日志数据,并生成对应的日志写入任务;第一写入模块505,用于通过所述日志写入任务将所述日志数据写入日志拷贝队列;第二写入模块506,用于通过第一工作线程,将所述日志拷贝队列中的日志数据写入到用于存储日志数据的缓存中。Optionally, the device further includes: a collection module 504, configured to collect database transaction log data corresponding to all subtasks if all subtasks in the current task queue have been executed, and generate corresponding log writes Into the task; the first writing module 505, used to write the log data into the log copy queue through the log writing task; the second writing module 506, used to copy the log through the first working thread The log data in the queue is written into the buffer for storing the log data.
可选地,所述装置还包括:第四分配模块507,用于为所述日志写入任务分配日志事务标识;判断模块508,用于根据所述日志事务标识判断所有日志写入任务是否全部完成。Optionally, the device further includes: a fourth allocation module 507, configured to allocate a log transaction identifier for the log writing task; a judging module 508, configured to determine whether all log writing tasks are all based on the log transaction identifier carry out.
可选地,所述装置还包括:发送模块509,用于通过刷盘任务将所述缓存中的日志数据发送至日志刷盘队列,以对所述日志数据进行持久化存储;持久化存储模块510,用于通过第二工作线程,对所述日志刷盘队列中的日志数据进行持久化存储。Optionally, the device further includes: a sending module 509, configured to send the log data in the cache to the log flushing queue through a flushing task, so as to perform persistent storage on the log data; a persistent storage module 510, configured to perform persistent storage on the log data in the log flushing queue through a second working thread.
可选地,所述发送模块509,具体用于:判断当前刷盘任务是否抢占到刷盘锁,若是,则通过所述当前刷盘任务将对应的所述日志数据发送至所述日志刷盘队列。Optionally, the sending module 509 is specifically configured to: determine whether the current flashing task has seized the flashing lock, and if so, sending the corresponding log data to the log flashing through the current flashing task queue.
可选地,所述装置还包括:记录模块511,用于记录所述日志数据对应的编号,并根据所述编号,将对应的日志数据发送至写内存表队列。Optionally, the device further includes: a recording module 511, configured to record a serial number corresponding to the log data, and according to the serial number, send the corresponding log data to the write memory table queue.
可选地,所述装置还包括:第三写入模块512,用于通过多个写内存表任务,将所述写内存表队列中的日志数据并发写入内存表。Optionally, the device further includes: a third writing module 512, configured to concurrently write the log data in the memory table writing queue into the memory table through multiple memory table writing tasks.
可选地,所述第三写入模块512,具体用于:获取已提交的写内存表任务的任务编号;将连续的多个任务编号中最大的任务编号确定为当前任务编号;根据当前任务编号判断所述多个写内存表任务是否全部完成。Optionally, the third writing module 512 is specifically configured to: obtain the task number of the task of writing the memory table that has been submitted; determine the largest task number among multiple consecutive task numbers as the current task number; according to the current task Numbering determines whether the multiple tasks of writing memory tables are all completed.
可选地,所述装置还包括:清理模块513,用于通过多个提交任务对已提交的多个写内存表任务进行清理操作。Optionally, the device further includes: a cleaning module 513, configured to perform cleaning operations on multiple submitted tasks for writing memory tables through multiple submission tasks.
本实施例的数据库任务的处理装置用于实现前述多个方法实施例中相应的数据库任务的处理方法,并具有相应的方法实施例的有益效果,在此不再赘述。The database task processing apparatus of this embodiment is used to implement the corresponding database task processing methods in the foregoing multiple method embodiments, and has the beneficial effects of the corresponding method embodiments, which will not be repeated here.
图6为本申请实施例六中电子设备的结构示意图;该电子设备可以包括:FIG. 6 is a schematic structural diagram of an electronic device in Embodiment 6 of this application; the electronic device may include:
一个或多个处理器601;One or more processors 601;
计算机可读介质602,可以配置为存储一个或多个程序,The computer-readable medium 602 can be configured to store one or more programs,
当所述一个或多个程序被所述一个或多个处理器执行,使得所述一个或多个处理器实现如上述实施例一或实施例二所述的数据库任务的处理方法。When the one or more programs are executed by the one or more processors, the one or more processors implement the method for processing database tasks as described in the first embodiment or the second embodiment.
图7为本申请实施例七中电子设备的硬件结构;如图7所示,该电子设备的硬件结构可以包括:处理器701,通信接口702,计算机可读介质703和通信总线704;FIG. 7 is the hardware structure of the electronic device in the seventh embodiment of the application; as shown in FIG. 7, the hardware structure of the electronic device may include: a processor 701, a communication interface 702, a computer-readable medium 703 and a communication bus 704;
其中处理器701、通信接口702、计算机可读介质703通过通信总线704完成相互间的通信;The processor 701, the communication interface 702, and the computer-readable medium 703 communicate with each other through the communication bus 704;
可选地,通信接口702可以为通信模块的接口,如GSM模块的接口;Optionally, the communication interface 702 may be an interface of a communication module, such as an interface of a GSM module;
其中,处理器701具体可以配置为:根据对数据库的写入请求,确定所述写入请求对应的数据库写入任务的信息;对所述数据库写入任务进行分解,获得所述数据库写入任务对应的多个子任务;根据对多个任务队列中各个任务队列占用的资源的加锁检测结果,将所述多个子任务并发写入所述多个任务队列。The processor 701 may be specifically configured to: according to a write request to the database, determine the information of the database write task corresponding to the write request; decompose the database write task to obtain the database write task Corresponding multiple subtasks; according to the lock detection result of the resources occupied by each task queue in the multiple task queues, the multiple subtasks are concurrently written into the multiple task queues.
处理器701可以是通用处理器,包括中央处理器(Central Processing Unit,简称CPU)、网络处理器(Network Processor,简称NP)等;还可以是数字信号处理器(DSP)、专用集成电路(ASIC)、现成可编程门阵列(FPGA)或者其它可编程逻辑器件、分立门或者晶体管逻 辑器件、分立硬件组件。可以实现或者执行本申请实施例中的公开的各方法、步骤及逻辑框图。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。The processor 701 may be a general-purpose processor, including a central processing unit (Central Processing Unit, CPU), a network processor (Network Processor, NP), etc.; it may also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), etc. ), ready-made programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps, and logical block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor or the like.
计算机可读介质703可以是,但不限于,随机存取存储介质(Random Access Memory,RAM),只读存储介质(Read Only Memory,ROM),可编程只读存储介质(Programmable Read-Only Memory,PROM),可擦除只读存储介质(Erasable Programmable Read-Only Memory,EPROM),电可擦除只读存储介质(Electric Erasable Programmable Read-Only Memory,EEPROM)等。The computer-readable medium 703 may be, but is not limited to, a random access storage medium (Random Access Memory, RAM), a read-only storage medium (Read Only Memory, ROM), and a programmable read-only storage medium (Programmable Read-Only Memory, PROM), Erasable Programmable Read-Only Memory (EPROM), Electrically Erasable Programmable Read-Only Memory (EEPROM), etc.
特别地,根据本公开的实施例,上文参考流程图描述的过程可以被实现为计算机软件程序。例如,本公开的实施例包括一种计算机程序产品,其包括承载在计算机可读介质上的计算机程序,该计算机程序包含配置为执行流程图所示的方法的程序代码。在这样的实施例中,该计算机程序可以通过通信部分从网络上被下载和安装,和/或从可拆卸介质被安装。在该计算机程序被中央处理单元(CPU)执行时,执行本申请的方法中限定的上述功能。需要说明的是,本申请所述的计算机可读介质可以是计算机可读信号介质或者计算机可读存储介质或者是上述两者的任意组合。计算机可读介质例如可以但不限于是电、磁、光、电磁、红外线、或半导体的系统、装置或器件,或者任意以上的组合。计算机可读存储介质的更具体的例子可以包括但不限于:具有一个或多个导线的电连接、便携式计算机磁盘、硬盘、随机访问存储介质(RAM)、只读存储介质(ROM)、可擦式可编程只读存储介质(EPROM或闪存)、光纤、便携式紧凑磁盘只读存储介质(CD-ROM)、光存储介质件、磁存储介质件、或者上述的任意合适的组合。在本申请中,计算机可读存储介质可以是任何包含或存储程序的有形介质,该程序可以被指令执行系统、装置或者器件使用或者与其结合使用。而在本申请中,计算机可读的信号介质可以包括在基带中或者作为载波一部分传播的数据信号,其中承载了计算机可读的程序代码。这种传播的数据信号可以采用多种形式,包括但不限于电磁信号、光信号或上述的任意合适的组合。计算机可读的信号介质还可以是计算机可读存储介质以外的任何计算机可读介质,该计算机可读介质可以发送、传播或者传输配置为由指令执行系统、装置或者器件使用或者与其结合使用的程序。计算机可读介质上包含的程序代码可以用任何适当的介质传输,包括但不限于:无线、电线、光缆、RF等等,或者上述的任意合适的组合。In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes program code configured to execute the method shown in the flowchart. In such an embodiment, the computer program may be downloaded and installed from the network through the communication part, and/or installed from a removable medium. When the computer program is executed by a central processing unit (CPU), the above-mentioned functions defined in the method of the present application are executed. It should be noted that the computer-readable medium described in this application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the two. The computer-readable medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections with one or more wires, portable computer disks, hard disks, random access storage media (RAM), read-only storage media (ROM), erasable Type programmable read-only storage medium (EPROM or flash memory), optical fiber, portable compact disk read-only storage medium (CD-ROM), optical storage medium, magnetic storage medium, or any suitable combination of the above. In this application, the computer-readable storage medium may be any tangible medium that contains or stores a program, and the program may be used by or in combination with an instruction execution system, apparatus, or device. In this application, a computer-readable signal medium may include a data signal propagated in a baseband or as a part of a carrier wave, and a computer-readable program code is carried therein. This propagated data signal can take many forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the foregoing. The computer-readable signal medium may also be any computer-readable medium other than the computer-readable storage medium. The computer-readable medium may send, propagate, or transmit a program configured to be used by or in combination with the instruction execution system, apparatus, or device . The program code contained on the computer-readable medium can be transmitted by any suitable medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
可以以一种或多种程序设计语言或其组合来编写配置为执行本申请的操作的计算机程序代码,所述程序设计语言包括面向对象的程序设计语言—诸如Java、Smalltalk、C++, 还包括常规的过程式程序设计语言—诸如”C”语言或类似的程序设计语言。程序代码可以完全地在用户计算机上执行、部分地在用户计算机上执行、作为一个独立的软件包执行、部分在用户计算机上部分在远程计算机上执行、或者完全在远程计算机或服务器上执行。在涉及远程计算机的情形中,远程计算机可以通过任意种类的网络:包括局域网(LAN)或广域网(WAN)—连接到用户计算机,或者,可以连接到外部计算机(例如利用因特网服务提供商来通过因特网连接)。The computer program code configured to perform the operations of the present application can be written in one or more programming languages or a combination thereof. The programming languages include object-oriented programming languages—such as Java, Smalltalk, C++, and also conventional Procedural programming language-such as "C" language or similar programming language. The program code can be executed entirely on the user's computer, partly on the user's computer, executed as an independent software package, partly on the user's computer and partly executed on a remote computer, or entirely executed on the remote computer or server. In the case of a remote computer, the remote computer can be connected to the user's computer through any kind of network: including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computer (for example, using an Internet service provider to connect to the Internet connection).
附图中的流程图和框图,图示了按照本申请各种实施例的系统、方法和计算机程序产品的可能实现的体系架构、功能和操作。在这点上,流程图或框图中的每个方框可以代表一个模块、程序段、或代码的一部分,该模块、程序段、或代码的一部分包含一个或多个配置为实现规定的逻辑功能的可执行指令。上述具体实施例中有特定先后关系,但这些先后关系只是示例性的,在具体实现的时候,这些步骤可能会更少、更多或执行顺序有调整。即在有些作为替换的实现中,方框中所标注的功能也可以以不同于附图中所标注的顺序发生。例如,两个接连地表示的方框实际上可以基本并行地执行,它们有时也可以按相反的顺序执行,这依所涉及的功能而定。也要注意的是,框图和/或流程图中的每个方框、以及框图和/或流程图中的方框的组合,可以用执行规定的功能或操作的专用的基于硬件的系统来实现,或者可以用专用硬件与计算机指令的组合来实现。The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation of the system architecture, functions, and operations of the system, method, and computer program product according to various embodiments of the present application. In this regard, each block in the flowchart or block diagram can represent a module, program segment, or part of code, and the module, program segment, or part of code contains one or more configurations to achieve the specified logical function Executable instructions. In the foregoing specific embodiments, there are specific sequence relationships, but these sequence relationships are only exemplary. In specific implementation, these steps may be fewer, more, or the execution order may be adjusted. That is, in some alternative implementations, the functions marked in the block may also occur in a different order from the order marked in the drawings. For example, two blocks shown in succession can actually be executed substantially in parallel, or they can sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and/or flowchart, and the combination of the blocks in the block diagram and/or flowchart, can be implemented by a dedicated hardware-based system that performs the specified functions or operations Or it can be realized by a combination of dedicated hardware and computer instructions.
描述于本申请实施例中所涉及到的模块可以通过软件的方式实现,也可以通过硬件的方式来实现。所描述的模块也可以设置在处理器中,例如,可以描述为:一种处理器包括确定模块、分解模块和并发写入模块。其中,这些模块的名称在某种情况下并不构成对该模块本身的限定,例如,确定模块还可以被描述为“根据对数据库的写入请求,确定所述写入请求对应的数据库写入任务的信息的模块”。The modules involved in the embodiments described in the present application can be implemented in software or hardware. The described module may also be provided in the processor, for example, it may be described as: a processor includes a determination module, a decomposition module, and a concurrent writing module. Among them, the names of these modules do not constitute a limitation on the module itself under certain circumstances. For example, the determining module can also be described as "based on a write request to the database, determine the database write corresponding to the write request Module of task information".
作为另一方面,本申请还提供了一种计算机可读介质,其上存储有计算机程序,该程序被处理器执行时实现如上述实施例一或实施例二所描述的数据库任务的处理方法。As another aspect, the present application also provides a computer-readable medium on which a computer program is stored, and when the program is executed by a processor, the method for processing database tasks as described in the first embodiment or the second embodiment is realized.
作为另一方面,本申请还提供了一种计算机可读介质,该计算机可读介质可以是上述实施例中描述的装置中所包含的;也可以是单独存在,而未装配入该装置中。上述计算机可读介质承载有一个或者多个程序,当上述一个或者多个程序被该装置执行时,使得该装置:根据对数据库的写入请求,确定所述写入请求对应的数据库写入任务的信息;对所述数据库写入任务进行分解,获得所述数据库写入任务对应的多个子任务;根据对多个任务队列中各个任务队列占用的资源的加锁检测结果,将所述多个子任务并发写入所述多个任务队列。As another aspect, the present application also provides a computer-readable medium, which may be included in the device described in the above-mentioned embodiments; or it may exist alone without being assembled into the device. The above-mentioned computer-readable medium carries one or more programs, and when the above-mentioned one or more programs are executed by the device, the device is caused to determine the database write task corresponding to the write request according to the write request to the database Decompose the database write task to obtain multiple subtasks corresponding to the database write task; according to the lock detection results of the resources occupied by each task queue in the multiple task queues, the multiple subtasks Tasks are written into the multiple task queues concurrently.
在本公开的各种实施方式中所使用的表述“第一”、“第二”、“所述第一”或“所述第二”可修饰各种部件而与顺序和/或重要性无关,但是这些表述不限制相应部件。以上表述仅配置为将元件与其它元件区分开的目的。例如,第一用户设备和第二用户设备表示不同的用户设备,虽然两者均是用户设备。例如,在不背离本公开的范围的前提下,第一元件可称作第二元件,类似地,第二元件可称作第一元件。The expressions "first", "second", "the first" or "the second" used in various embodiments of the present disclosure may modify various components regardless of order and/or importance , But these expressions do not limit the corresponding components. The above expressions are only configured for the purpose of distinguishing elements from other elements. For example, the first user equipment and the second user equipment represent different user equipment, although both are user equipment. For example, without departing from the scope of the present disclosure, the first element may be referred to as the second element, and similarly, the second element may be referred to as the first element.
当一个元件(例如,第一元件)称为与另一元件(例如,第二元件)“(可操作地或可通信地)联接”或“(可操作地或可通信地)联接至”另一元件(例如,第二元件)或“连接至”另一元件(例如,第二元件)时,应理解为该一个元件直接连接至该另一元件或者该一个元件经由又一个元件(例如,第三元件)间接连接至该另一个元件。相反,可理解,当元件(例如,第一元件)称为“直接连接”或“直接联接”至另一元件(第二元件)时,则没有元件(例如,第三元件)插入在这两者之间。When an element (for example, a first element) is referred to as being "(operably or communicatively) coupled" or "(operably or communicatively) coupled to" another element (for example, a second element) When an element (e.g., a second element) or "connected to" another element (e.g., a second element), it should be understood that the one element is directly connected to the other element or the one element passes through another element (e.g., The third element) is indirectly connected to the other element. On the contrary, it can be understood that when an element (e.g., a first element) is referred to as being "directly connected" or "directly coupled" to another element (a second element), no element (e.g., a third element) is inserted between the two elements. Between those.
以上描述仅为本申请的较佳实施例以及对所运用技术原理的说明。本领域技术人员应当理解,本申请中所涉及的发明范围,并不限于上述技术特征的特定组合而成的技术方案,同时也应涵盖在不脱离上述发明构思的情况下,由上述技术特征或其等同特征进行任意组合而形成的其它技术方案。例如上述特征与本申请中公开的(但不限于)具有类似功能的技术特征进行互相替换而形成的技术方案。The above description is only a preferred embodiment of the application and an explanation of the applied technical principles. Those skilled in the art should understand that the scope of the invention involved in this application is not limited to the technical solution formed by the specific combination of the above technical features, and should also cover the above technical features or technical solutions without departing from the above inventive concept. Other technical solutions formed by any combination of its equivalent features. For example, the above-mentioned features and the technical features disclosed in this application (but not limited to) with similar functions are mutually replaced to form a technical solution.

Claims (22)

  1. 一种数据库任务的处理方法,其特征在于,所述方法包括:A method for processing database tasks, characterized in that the method includes:
    根据对数据库的写入请求,确定所述写入请求对应的数据库写入任务的信息;Determine the information of the database write task corresponding to the write request according to the write request to the database;
    对所述数据库写入任务进行分解,获得所述数据库写入任务对应的多个子任务;Decompose the database writing task to obtain multiple subtasks corresponding to the database writing task;
    根据对多个任务队列中各个任务队列占用的资源的加锁检测结果,将所述多个子任务并发写入所述多个任务队列。The multiple subtasks are concurrently written into the multiple task queues according to the lock detection result on the resources occupied by each task queue in the multiple task queues.
  2. 根据权利要求1所述的方法,其特征在于,所述根据对多个任务队列中各个任务队列占用的资源的加锁检测结果,将所述多个子任务并发写入所述多个任务队列,包括:The method according to claim 1, wherein the multiple subtasks are concurrently written into the multiple task queues according to the lock detection result of the resources occupied by each task queue in the multiple task queues, include:
    从所述多个任务队列中选择一个任务队列,判断选择的任务队列是否已被加锁;Select a task queue from the multiple task queues, and determine whether the selected task queue has been locked;
    若已被加锁,则从剩余的任务队列中再选择一个任务队列,并将待加入的子任务加入再选择的任务队列;If it has been locked, select another task queue from the remaining task queues, and add the subtasks to be added to the selected task queue;
    若未被加锁,则将所述待加入的子任务加入所述选择的任务队列。If it is not locked, the subtask to be added is added to the selected task queue.
  3. 根据权利要求1或2所述的方法,其特征在于,所述方法还包括:The method according to claim 1 or 2, wherein the method further comprises:
    对于所述各个任务队列,为首个加入当前任务队列的子任务分配执行线程,其中,所述执行线程用于执行所述当前任务队列中的所有子任务。For each task queue, an execution thread is allocated to the first subtask that joins the current task queue, where the execution thread is used to execute all the subtasks in the current task queue.
  4. 根据权利要求3所述的方法,其特征在于,所述方法还包括:The method according to claim 3, wherein the method further comprises:
    若所述当前任务队列中的所有子任务执行完毕,则对所述当前任务队列进行资源解锁;If all subtasks in the current task queue are executed, unlock the resources of the current task queue;
    根据解锁后的所述当前任务队列的空闲等待时间和/或再次接收的子任务的信息,对所述当前任务队列对应的执行线程进行处理。The execution thread corresponding to the current task queue is processed according to the unlocked idle waiting time of the current task queue and/or the information of the subtasks received again.
  5. 根据权利要求4所述的方法,其特征在于,所述根据解锁后的所述当前任务队列的空闲等待时间或再次接收的子任务的信息,对所述当前任务队列对应的执行线程进行处理,包括:The method according to claim 4, wherein the processing is performed on the execution thread corresponding to the current task queue according to the unlocked idle waiting time of the current task queue or the information of the subtask received again, include:
    若在所述空闲等待时间的时间段内未再次接收到新的子任务,则释放所述执行线程与所述当前任务队列的对应关系;If no new subtask is received again within the time period of the idle waiting time, releasing the corresponding relationship between the execution thread and the current task queue;
    若在所述空闲等待时间的时间段内再次接收到新的子任务,且所述新的子任务的数量达到预设阈值,则唤醒所述执行线程,并通过所述执行线程执行所述新的子任务。If a new subtask is received again within the period of the idle waiting time, and the number of the new subtask reaches the preset threshold, the execution thread is awakened, and the new execution thread is executed Subtasks.
  6. 根据权利要求3所述的方法,其特征在于,所述方法还包括:The method according to claim 3, wherein the method further comprises:
    对于所述各个任务队列,为非首个加入所述当前任务队列的子任务分配辅助线程,其中,所述辅助线程用于将非首个子任务交给所述执行线程进行处理;For each task queue, an auxiliary thread is allocated to the subtask that is not the first to join the current task queue, where the auxiliary thread is used to hand the non-first subtask to the execution thread for processing;
    判断所述辅助线程是否已成功将所述非首个子任务交给所述执行线程,若是,则分配所述辅助线程获取新的子任务。It is determined whether the auxiliary thread has successfully handed over the non-first subtask to the execution thread, and if so, the auxiliary thread is allocated to obtain a new subtask.
  7. 根据权利要求1所述的方法,其特征在于,所述方法还包括:The method of claim 1, wherein the method further comprises:
    若当前任务队列中的所有子任务均已执行完毕,则收集所有子任务对应的数据库事务日志数据,并生成对应的日志写入任务;If all subtasks in the current task queue have been executed, collect the database transaction log data corresponding to all subtasks, and generate corresponding log write tasks;
    通过所述日志写入任务将所述日志数据写入日志拷贝队列;Writing the log data into the log copy queue through the log writing task;
    通过第一工作线程,将所述日志拷贝队列中的日志数据写入到用于存储日志数据的缓存中。Through the first working thread, the log data in the log copy queue is written into the cache for storing the log data.
  8. 根据权利要求7所述的方法,其特征在于,在通过所述日志写入任务将所述日志数据写入日志拷贝队列时,所述方法还包括:8. The method according to claim 7, wherein when the log data is written to the log copy queue through the log writing task, the method further comprises:
    为所述日志写入任务分配日志事务标识;Allocating a log transaction identifier for the log writing task;
    根据所述日志事务标识判断所有日志写入任务是否全部完成。According to the log transaction identifier, it is determined whether all log writing tasks are completed.
  9. 根据权利要求7所述的方法,其特征在于,所述方法还包括:The method according to claim 7, wherein the method further comprises:
    通过刷盘任务将所述缓存中的日志数据发送至日志刷盘队列,以对所述日志数据进行持久化存储;Sending the log data in the cache to the log flushing queue through a flushing task, so as to perform persistent storage on the log data;
    通过第二工作线程,对所述日志刷盘队列中的日志数据进行持久化存储。Through the second working thread, the log data in the log flushing queue is persistently stored.
  10. 根据权利要求9所述的方法,其特征在于,所述通过刷盘任务将所述缓存中的日志数据发送至日志刷盘队列,包括:The method according to claim 9, wherein the sending the log data in the cache to the log flushing queue through a flushing task comprises:
    判断当前刷盘任务是否抢占到刷盘锁,若是,则通过所述当前刷盘任务将对应的所述日志数据发送至所述日志刷盘队列。It is determined whether the current flashing task has seized the flashing lock, and if so, the corresponding log data is sent to the log flashing queue through the current flashing task.
  11. 根据权利要求9所述的方法,其特征在于,在所述通过刷盘任务将所述缓存中的日志数据发送至日志刷盘队列的同时,所述方法还包括:The method according to claim 9, wherein while the log data in the cache is sent to the log flushing queue through the flushing task, the method further comprises:
    记录所述日志数据对应的编号,并根据所述编号,将对应的日志数据发送至写内存表队列。Record the number corresponding to the log data, and send the corresponding log data to the write memory table queue according to the number.
  12. 根据权利要求11所述的方法,其特征在于,所述方法还包括:The method of claim 11, wherein the method further comprises:
    通过多个写内存表任务,将所述写内存表队列中的日志数据并发写入内存表。The log data in the memory table writing queue is concurrently written into the memory table through multiple tasks of writing the memory table.
  13. 根据权利要求12所述的方法,其特征在于,所述通过多个写内存表任务,将所述写内存表队列中的日志数据并发写入内存表,包括:The method according to claim 12, wherein the concurrently writing the log data in the memory table writing queue to the memory table through multiple tasks of writing the memory table includes:
    获取已提交的写内存表任务的任务编号;Get the task number of the submitted task of writing memory table;
    将连续的多个任务编号中最大的任务编号确定为当前任务编号;Determine the largest task number among consecutive task numbers as the current task number;
    根据当前任务编号判断所述多个写内存表任务是否全部完成。According to the current task number, it is determined whether the multiple tasks of writing memory tables are all completed.
  14. 根据权利要求13所述的方法,其特征在于,所述方法还包括:The method of claim 13, wherein the method further comprises:
    通过多个提交任务对已提交的多个写内存表任务进行清理操作。Multiple submitted tasks are used to clean up multiple submitted tasks for writing memory tables.
  15. 一种数据库任务的处理装置,其特征在于,所述装置包括:A processing device for database tasks, characterized in that the device comprises:
    确定模块,用于根据对数据库的写入请求,确定所述写入请求对应的数据库写入任务的信息;The determining module is used to determine the information of the database write task corresponding to the write request according to the write request to the database;
    分解模块,用于对所述数据库写入任务进行分解,获得所述数据库写入任务对应的多个子任务;The decomposition module is used to decompose the database writing task to obtain multiple subtasks corresponding to the database writing task;
    并发写入模块,用于根据对多个任务队列中各个任务队列占用的资源的加锁检测结果,将所述多个子任务并发写入所述多个任务队列。The concurrent writing module is configured to concurrently write the multiple subtasks into the multiple task queues according to the lock detection result of the resources occupied by each task queue in the multiple task queues.
  16. 根据权利要求15所述的装置,其特征在于,所述并发写入模块,具体用于:The apparatus according to claim 15, wherein the concurrent writing module is specifically configured to:
    从所述多个任务队列中选择一个任务队列,判断选择的任务队列是否已被加锁;Select a task queue from the multiple task queues, and determine whether the selected task queue has been locked;
    若已被加锁,则从剩余的任务队列中再选择一个任务队列,并将待加入的子任务加入再选择的任务队列;If it has been locked, select another task queue from the remaining task queues, and add the subtasks to be added to the selected task queue;
    若未被加锁,则将所述待加入的子任务加入所述选择的任务队列。If it is not locked, the subtask to be added is added to the selected task queue.
  17. 根据权利要求15或16所述的装置,其特征在于,所述装置还包括:The device according to claim 15 or 16, wherein the device further comprises:
    第一分配模块,用于对于所述各个任务队列,为首个加入当前任务队列的子任务分配执行线程,其中,所述执行线程用于执行所述当前任务队列中的所有子任务。The first allocation module is configured to allocate execution threads to the first subtasks added to the current task queue for each task queue, wherein the execution threads are used to execute all subtasks in the current task queue.
  18. 根据权利要求17所述的装置,其特征在于,所述装置还包括:The device according to claim 17, wherein the device further comprises:
    资源解锁模块,用于若所述当前任务队列中的所有子任务执行完毕,则对所述当前任务队列进行资源解锁;The resource unlocking module is configured to unlock the resources of the current task queue if all the subtasks in the current task queue are executed;
    处理模块,用于根据解锁后的所述当前任务队列的空闲等待时间和/或再次接收的子任务的信息,对所述当前任务队列对应的执行线程进行处理。The processing module is configured to process the execution thread corresponding to the current task queue according to the unlocked idle waiting time of the current task queue and/or the information of the subtasks received again.
  19. 根据权利要求18所述的装置,其特征在于,所述处理模块,具体用于:The device according to claim 18, wherein the processing module is specifically configured to:
    若在所述空闲等待时间的时间段内未再次接收到新的子任务,则释放所述执行线程与所述当前任务队列的对应关系;If no new subtask is received again within the time period of the idle waiting time, releasing the corresponding relationship between the execution thread and the current task queue;
    若在所述空闲等待时间的时间段内再次接收到新的子任务,且所述新的子任务的数量达到预设阈值,则唤醒所述执行线程,并通过所述执行线程执行所述新的子任务。If a new subtask is received again within the period of the idle waiting time, and the number of the new subtask reaches the preset threshold, the execution thread is awakened, and the new execution thread is executed Subtasks.
  20. 根据权利要求17所述的装置,其特征在于,所述装置还包括:The device according to claim 17, wherein the device further comprises:
    第二分配模块,用于对于所述各个任务队列,为非首个加入所述当前任务队列的子 任务分配辅助线程,其中,所述辅助线程用于将非首个子任务交给所述执行线程进行处理;The second allocation module is configured to allocate auxiliary threads for each task queue that is not the first subtask to join the current task queue, wherein the auxiliary thread is used to hand over the non-first subtask to the execution thread To process
    第三分配模块,用于判断所述辅助线程是否已成功将所述非首个子任务交给所述执行线程,若是,则分配所述辅助线程获取新的子任务。The third allocation module is used to determine whether the auxiliary thread has successfully handed over the non-first subtask to the execution thread, and if so, allocate the auxiliary thread to obtain a new subtask.
  21. 一种电子设备,包括:处理器、存储器、通信接口和通信总线,所述处理器、所述存储器和所述通信接口通过所述通信总线完成相互间的通信;An electronic device, comprising: a processor, a memory, a communication interface, and a communication bus. The processor, the memory, and the communication interface communicate with each other through the communication bus;
    所述存储器用于存放至少一可执行指令,所述可执行指令使所述处理器执行如权利要求1-14中任意一项权利要求所述的数据库任务的处理方法。The memory is used to store at least one executable instruction, and the executable instruction causes the processor to execute the database task processing method according to any one of claims 1-14.
  22. 一种计算机存储介质,其上存储有计算机程序,该程序被处理器执行时实现如权利要求1-14中任意一项权利要求所述的数据库任务的处理方法。A computer storage medium with a computer program stored thereon, and when the program is executed by a processor, the method for processing database tasks according to any one of claims 1-14 is realized.
PCT/CN2020/091467 2019-05-30 2020-05-21 Database task processing method and apparatus, electronic device, and readable medium WO2020238737A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910462682.0 2019-05-30
CN201910462682.0A CN112015713B (en) 2019-05-30 2019-05-30 Database task processing method and device, electronic equipment and readable medium

Publications (1)

Publication Number Publication Date
WO2020238737A1 true WO2020238737A1 (en) 2020-12-03

Family

ID=73501417

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/091467 WO2020238737A1 (en) 2019-05-30 2020-05-21 Database task processing method and apparatus, electronic device, and readable medium

Country Status (2)

Country Link
CN (1) CN112015713B (en)
WO (1) WO2020238737A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11922026B2 (en) 2022-02-16 2024-03-05 T-Mobile Usa, Inc. Preventing data loss in a filesystem by creating duplicates of data in parallel, such as charging data in a wireless telecommunications network

Families Citing this family (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112632031A (en) * 2020-12-08 2021-04-09 北京思特奇信息技术股份有限公司 Method and system for realizing long connection use of distributed memory database, electronic device and storage medium
CN112541824B (en) * 2020-12-11 2024-04-30 中信银行股份有限公司 Drawing method and system of K-line candle graph and storage medium
CN113296966A (en) * 2021-05-21 2021-08-24 中国邮政储蓄银行股份有限公司 Data processing method and device
CN113269590B (en) * 2021-05-31 2023-06-06 五八到家有限公司 Data processing method, device and system for resource subsidy
CN113377502A (en) * 2021-06-10 2021-09-10 上海达梦数据库有限公司 Transaction processing method, device, server, database management system and medium
CN113407544A (en) * 2021-07-13 2021-09-17 南方电网数字电网研究院有限公司 Multi-model data synchronization method and device
CN113297228B (en) * 2021-07-27 2021-10-08 深圳华锐金融技术股份有限公司 MySQL writing method, device, equipment and medium based on multiple live instances
CN113704354B (en) * 2021-08-30 2023-10-20 康键信息技术(深圳)有限公司 Data synchronization method and device, computer equipment and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101714167A (en) * 2009-11-03 2010-05-26 北京高信达网络科技有限公司 Method and device for accessing monofile database
CN106294841A (en) * 2016-08-19 2017-01-04 上海携程商务有限公司 The processing method of db transaction and processing system
CN108694199A (en) * 2017-04-10 2018-10-23 北京京东尚科信息技术有限公司 Data synchronization unit, method, storage medium and electronic equipment
CN109634974A (en) * 2018-12-04 2019-04-16 郑州云海信息技术有限公司 A kind of data processing method, system and associated component

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20150019516A1 (en) * 2013-07-09 2015-01-15 David Wein Providing Durability of In-Memory Columnar Datastores Using Multile Logs

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101714167A (en) * 2009-11-03 2010-05-26 北京高信达网络科技有限公司 Method and device for accessing monofile database
CN106294841A (en) * 2016-08-19 2017-01-04 上海携程商务有限公司 The processing method of db transaction and processing system
CN108694199A (en) * 2017-04-10 2018-10-23 北京京东尚科信息技术有限公司 Data synchronization unit, method, storage medium and electronic equipment
CN109634974A (en) * 2018-12-04 2019-04-16 郑州云海信息技术有限公司 A kind of data processing method, system and associated component

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11922026B2 (en) 2022-02-16 2024-03-05 T-Mobile Usa, Inc. Preventing data loss in a filesystem by creating duplicates of data in parallel, such as charging data in a wireless telecommunications network

Also Published As

Publication number Publication date
CN112015713A (en) 2020-12-01
CN112015713B (en) 2024-03-26

Similar Documents

Publication Publication Date Title
WO2020238737A1 (en) Database task processing method and apparatus, electronic device, and readable medium
US8190845B2 (en) System and method for allocating and deallocating memory within transactional code
US8544022B2 (en) Transactional memory preemption mechanism
US8914805B2 (en) Rescheduling workload in a hybrid computing environment
US9536014B1 (en) Parallel processing of data
US20160283282A1 (en) Optimization of map-reduce shuffle performance through shuffler i/o pipeline actions and planning
US9021303B1 (en) Multi-threaded in-memory processing of a transaction log for concurrent access to data during log replay
US8607239B2 (en) Lock mechanism to reduce waiting of threads to access a shared resource by selectively granting access to a thread before an enqueued highest priority thread
CN108595282A (en) A kind of implementation method of high concurrent message queue
US20110252426A1 (en) Processing batch transactions
US9141540B2 (en) Garbage collection of interned strings
US20080263309A1 (en) Creating a Physical Trace from a Virtual Trace
US9553951B1 (en) Semaphores in distributed computing environments
US20210365285A1 (en) Voice data procession method, apparatus, device and storage medium
CN110851276A (en) Service request processing method, device, server and storage medium
CN111611221A (en) Hybrid computing system, data processing method and device
US9940269B2 (en) Conditionally releasing locks in response to requests
US9473565B2 (en) Data transmission for transaction processing in a networked environment
CN111290842A (en) Task execution method and device
CN111459882B (en) Namespace transaction processing method and device for distributed file system
CN113051055A (en) Task processing method and device
CN114675890B (en) Instruction execution method, device, equipment and storage medium
US10447607B2 (en) System and method for dequeue optimization using conditional iteration
US11645154B2 (en) Enhanced recovery from externally initiated adjunct processor queue reset
US10185587B2 (en) Wait-free process request execution utilizing a dedicated helper thread

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20814837

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20814837

Country of ref document: EP

Kind code of ref document: A1