CN117370129A - Thread state recording method and computing device - Google Patents

Thread state recording method and computing device Download PDF

Info

Publication number
CN117370129A
CN117370129A CN202311177704.1A CN202311177704A CN117370129A CN 117370129 A CN117370129 A CN 117370129A CN 202311177704 A CN202311177704 A CN 202311177704A CN 117370129 A CN117370129 A CN 117370129A
Authority
CN
China
Prior art keywords
thread
linked list
written
state data
file
Prior art date
Legal status (The legal status 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 status listed.)
Pending
Application number
CN202311177704.1A
Other languages
Chinese (zh)
Inventor
吕温
谢卫平
刘影
张�浩
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
XFusion Digital Technologies Co Ltd
Original Assignee
XFusion Digital Technologies Co Ltd
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 XFusion Digital Technologies Co Ltd filed Critical XFusion Digital Technologies Co Ltd
Priority to CN202311177704.1A priority Critical patent/CN117370129A/en
Publication of CN117370129A publication Critical patent/CN117370129A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/34Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment
    • G06F11/3466Performance evaluation by tracing or monitoring
    • G06F11/3476Data logging
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3055Monitoring arrangements for monitoring the status of the computing system or of the computing system component, e.g. monitoring if the computing system is on, off, available, not available

Abstract

The application discloses a thread state recording method and computing equipment, relates to the technical field of databases, and is used for improving the efficiency of recording the running state of an auxiliary thread. The method is applied to a database system, the database system comprises a first thread, a second thread and a file linked list to be written, and the method comprises the following steps: in the running process of the first thread, the first thread records the thread state data of the first thread to a file linked list to be written, and a sub-memory slot of a memory is mounted in the file linked list to be written, wherein one sub-memory slot is used for storing the thread state data of one first thread; and the second thread writes the thread state data in the file linked list to be written into the data file of the magnetic disk.

Description

Thread state recording method and computing device
Technical Field
The present disclosure relates to the field of database technologies, and in particular, to a thread state recording method and a computing device.
Background
Currently, computing devices implement database management by running worker threads and helper threads. Wherein the worker thread is used to add, delete or modify data in the database. The auxiliary thread is used for assisting in storing the data information modified by the working thread. The computing device generally adopts a Write Ahead Log (WAL) mechanism, writes the processing of data by a working thread in a memory into a WAL memory buffer area to generate a WAL log, and writes the WAL log in the WAL memory buffer area into a disk (disk) by an assist thread WAL write thread (WAL Writer) to obtain a WAL log file. The process is beneficial to the technicians to recover the data information by reading the WAL log file when the data information in the memory is emptied due to the power failure of the database, so that the data in the memory is prevented from being lost due to the fact that the data is not stored in the disk. Similarly, the auxiliary threads further comprise a WAL sending thread (WAL Sender) and a WAL receiving thread (WAL Receiver), and the two threads are used for backing up WAL logs between the primary and the secondary machines, so as to avoid data loss when the WAL logs in the database cannot be accessed.
The auxiliary thread can also record thread state data indicating the running state in the running process so as to help monitor the running of the auxiliary thread, and when the auxiliary thread causes the performance problem of the database, the auxiliary thread can perform positioning analysis through the thread state data. Currently, the auxiliary thread usually records thread state data in a log or a system table for storing system configuration information, and specifically, the auxiliary thread records the thread state data in a memory in the running process and then stores the thread state data in a disk. However, this approach is inefficient to record, affecting the invocation of the auxiliary thread by the computing device.
Disclosure of Invention
The embodiment of the application provides a thread state recording method and computing equipment, which are used for improving the efficiency of recording the running state of an auxiliary thread, and facilitating the positioning analysis of technicians based on recorded information when the auxiliary thread influences the system performance.
In order to achieve the above purpose, the embodiments of the present application adopt the following technical solutions:
in a first aspect, a method for recording thread status is provided, where the method is applied to a database system, and the database system includes a first thread, a second thread, and a file linked list to be written, and the method includes: in the running process of the first thread, the first thread records the thread state data of the first thread to a file linked list to be written, and a sub-memory slot of a memory is mounted in the file linked list to be written, wherein one sub-memory slot is used for storing the thread state data of one first thread; and the second thread writes the thread state data in the file linked list to be written into the data file of the magnetic disk.
By the method, the thread state data are recorded in the sub-memory slots by each first thread, the thread state data in each sub-memory slot are written into the disk by the second thread, and the method is beneficial to releasing the first thread in advance after the thread state data are written into the memory relative to the method of recording the thread state data in the log or the system table, and the thread state data in the memory are written into the disk by the second thread, so that when the thread state data are recorded by the log or the system table, the first thread waits for the thread state data to be released after the thread state data are written into the disk, and the recording efficiency and the calling efficiency of the auxiliary thread state are improved.
In one possible implementation manner, the database system further includes an idle linked list, where the idle linked list is loaded with a sub-memory slot of the memory, and records the state information of the first thread to a file linked list to be written, and includes: under the condition that the thread state data of the first thread is stored in the sub-memory slot of the idle linked list download mount, the sub-memory slot of the idle linked list download mount is mounted to a file linked list to be written; wherein a sub-memory slot is used to store thread state data of a first thread.
The possible implementation manner provides a management method of the sub-memory slots, wherein the idle sub-memory slots are mounted in an idle linked list, the sub-memory slots written with thread state data are mounted to a file to be written linked list, and the sub-memory slots in different states are managed through different linked lists, so that a second thread can access the file to be written linked list to acquire the sub-memory slots recorded with the thread state data when storing the thread state data into a data file.
In one possible implementation, the database system further includes a temporary linked list, and the second thread writes thread state data in the file linked list to be written to a data file of the disk, including: the second thread mounts the sub-memory slot to the temporary linked list under the condition that the to-be-written file linked list is monitored to mount the sub-memory slot; and the second thread writes the thread state data in the child memory slot downloaded by the temporary linked list into a data file of the disk.
The possible implementation manner is beneficial to the second thread to write the thread state data into the disk based on the temporary linked list, so that the second thread is prevented from accessing the file linked list to be written for a long time to acquire the thread state information, the timeliness of other first threads for storing the thread state data is affected, and the recording efficiency of the thread state and the running efficiency of the system are improved. In addition, the sub-memory slots in the file linked list to be written are mounted to the temporary linked list, so that the file linked list to be written can be emptied in time, and a subsequent new slot can be mounted from the idle linked list to the file linked list to be written conveniently.
In one possible implementation manner, after the second thread writes the thread state data in the temporary linked list downloaded sub-memory slot into the data file of the disk, the method further includes: and re-mounting the sub memory slot to the idle linked list.
The possible implementation manner provides a recovery method of the sub-memory slot, which is beneficial to the first thread running subsequently to record the thread state data by utilizing the sub-memory slot again, so that the utilization rate of the memory resource is improved, and meanwhile, the method is beneficial to saving the time occupied by the first thread to apply or release the memory when recording the thread state data, reducing the memory consumption and improving the recording efficiency of the thread state data.
In one possible implementation, the thread state data includes one or more of a data throughput of the first thread, a start time of the first thread, an end time of the first thread, a number of calls of the first thread, and a run time of the first thread.
The possible implementation manner provides the types of the recorded thread state data, and is beneficial to acquiring the corresponding thread state data based on the search conditions set by each type when the system performance is affected in the subsequent thread running process.
In one possible implementation manner, the first thread is multiple, the file linked list to be written includes a synchronization lock, and the first thread acquiring the synchronization lock has the authority to access the file linked list to be written; in the running process of the first thread, the first thread records the thread state data of the first thread to a file linked list to be written, and the method comprises the following steps: and under the condition that one first thread acquires the synchronous lock, the first thread records the thread state data of the first thread to a file linked list to be written.
The possible implementation manner is helpful to avoid the situation that a plurality of first threads access the file linked list to be written at the same time and access conflict occurs, and is helpful to maintain the stability of the running state of the computing equipment.
In one possible implementation, the second thread is asynchronous to the first thread.
This possible implementation helps the second thread and the first thread access the linked list of files to be written at different times, avoiding causing conflicts.
In one possible implementation, the second thread accesses the linked list of files to be written at first time intervals; if the sub memory slots exist in the file linked list to be written or the number of the sub memory slots is larger than a first threshold value within the adjacent two access time intervals, after the thread state data in the sub memory slots to be downloaded and mounted in the temporary linked list are written into the data file of the magnetic disk, the first time interval is adjusted to be a second time interval; the second time interval is less than the first time interval; if no sub-memory slots exist in the file linked list to be written or the number of the sub-memory slots is smaller than a second threshold value within the adjacent two access time intervals, after the thread state data in the sub-memory slots to be downloaded and mounted in the temporary linked list are written into the data file of the magnetic disk, the first time interval is adjusted to be a third time interval; wherein the third time interval is greater than the first time interval; the first threshold is greater than the second threshold.
The possible implementation manner is beneficial to dynamically adjusting the time interval for starting the second thread according to the sub-memory slots contained in the file linked list to be written, so that the time interval is shortened when the number of the sub-memory slots or the sub-memory slots in the file linked list to be written is large, the writing efficiency of the thread state data is improved, and the time interval is increased when the number of the sub-memory slots or the sub-memory slots in the file linked list to be written is not large, and resource waste caused by frequently starting the second thread is avoided.
In one possible implementation, the method further includes: reading a data file of a disk based on a surface loading mode, and acquiring thread state data of a first thread; based on the thread state data of the first thread, search conditions are set, and the search conditions are used for troubleshooting.
The possible implementation mode has the advantages that the data reading speed is high based on the mode of surface loading, the technicians can be helped to quickly acquire the required thread state data, in addition, the problem location is carried out by setting the search conditions, and the fault detection efficiency is improved.
In one possible implementation, the first thread includes one or more of a pre-write log WAL write thread, a WAL send thread, a WAL receive thread, and a dirty page write thread.
This possible implementation provides a specific type of first thread, which promotes solution implementability.
In a second aspect, a computing device is provided that includes a processor and a memory, the processor and the memory being electrically connected; the processor is used for starting the first thread, and recording thread state data of the first thread to a file linked list to be written in the running process of the first thread, wherein a sub-memory slot of a memory is mounted in the file linked list to be written, and one sub-memory slot is used for storing the thread state data of one first thread; the processor is also used for starting a second thread and writing thread state data in a file linked list to be written into a data file of the magnetic disk; the memory is used for storing thread state data and comprises a memory and a disk
In a third aspect, a computing device is provided, comprising: the functional units for executing any of the methods provided in the first aspect, and actions executed by the respective functional units are implemented by hardware or implemented by hardware executing corresponding software. For example, the computing device may include: a storage unit and a processing unit. The processing unit is used for starting the first thread, and in the running process of the first thread, the first thread records the thread state data of the first thread to a file linked list to be written, and a sub-memory slot of a memory is mounted in the file linked list to be written, wherein one sub-memory slot is used for storing the thread state data of one first thread; the processing unit is further used for starting a second thread, and the second thread writes the thread state data in the file linked list to be written into the data file of the disk.
In a fourth aspect, there is provided a computing device comprising: a processor and a memory, the processor being electrically connected to the memory, the memory being for storing program code, the processor executing the calling program code to perform any of the methods provided in the first aspect.
In a fifth aspect, there is provided a chip comprising: a processor and interface circuit; the interface circuit is used for receiving the code instruction and transmitting the code instruction to the processor; a processor for executing code instructions to perform any of the methods provided in the first aspect.
In a sixth aspect, there is provided a computer readable storage medium comprising computer executable instructions which, when run on a computer, cause the computer to perform any one of the methods provided in the first aspect.
In a seventh aspect, there is provided a computer program product comprising computer-executable instructions which, when run on a computer, cause the computer to perform any one of the methods provided in the first aspect.
The technical effects caused by any implementation manner of the second aspect to the seventh aspect may be referred to technical effects caused by corresponding implementation manners of the first aspect, and are not described herein.
Drawings
FIG. 1 is a schematic diagram of a scenario for running a dirty page write thread according to an embodiment of the present disclosure;
FIG. 2 is a schematic flow chart of recording thread status data based on a log according to an embodiment of the present application;
FIG. 3 is a schematic flow chart of recording thread status data based on a system table according to an embodiment of the present application;
fig. 4 is a schematic hardware structure of a computing device according to an embodiment of the present application;
FIG. 5 is a flowchart of a thread state recording method according to an embodiment of the present disclosure;
FIG. 6 is a schematic diagram of a composition of a predetermined memory area according to an embodiment of the present disclosure;
FIG. 7 is a schematic diagram of a sub-memory area according to an embodiment of the present disclosure;
fig. 8 is a schematic architecture diagram of a slot management module provided in an embodiment of the present application;
fig. 9 is a schematic view of a scenario of a thread state recording method according to an embodiment of the present application;
FIG. 10 is a schematic diagram of a scenario for creating a temporary linked list according to an embodiment of the present application;
FIG. 11 is a schematic view of a scenario in which slots in a temporary linked list are mounted to an idle linked list according to an embodiment of the present application;
FIG. 12 is a flowchart illustrating another thread state recording method according to an embodiment of the present disclosure;
FIG. 13 is a flowchart of storing thread state data based on a second thread according to an embodiment of the present application;
FIG. 14 is a flowchart illustrating another thread state recording method according to an embodiment of the present disclosure;
fig. 15 is a schematic diagram of a composition of a computing device according to an embodiment of the present application.
Detailed Description
In the description of the present application, "/" means "or" unless otherwise indicated, for example, a/B may mean a or B. "and/or" herein is merely an association relationship describing an association object, and means that three relationships may exist, for example, a and/or B may mean: a exists alone, A and B exist together, and B exists alone. Furthermore, "at least one" means one or more, and "a plurality" means two or more. The terms "first," "second," and the like do not limit the number and order of execution, and the terms "first," "second," and the like do not necessarily differ.
In this application, the terms "exemplary" or "such as" are used to mean serving as an example, instance, or illustration. Any embodiment or design described herein as "exemplary" or "for example" should not be construed as preferred or advantageous over other embodiments or designs. Rather, the use of words such as "exemplary" or "such as" is intended to present related concepts in a concrete fashion.
Currently, database systems implement database management by running worker threads and helper threads. Worker threads are used to add, delete, or modify data in a database. The auxiliary thread is used for assisting in storing the data information modified by the working thread.
In a database system employing the WAL mechanism, the assist thread includes a WAL write thread for writing WAL logs to disk, and WAL send threads and WAL receive threads for backing up WAL logs between the primary and backup machines. In addition, the assist threads include a dirty page write thread (pagewriter). Specifically, since the read-write speed of the disk is slow and the read-write speed of the memory is fast, when the database system realizes the function of modifying data, the data page in the disk needs to be read into the memory for modification, and since the modified data page in the memory is inconsistent with the data page in the disk, the modified data page in the memory is called a dirty data page, which is simply called a dirty page. In order to realize the modified data persistent storage, the dirty page writing thread writes dirty pages into a disk, completes data modification, and eliminates the dirty pages.
As shown in FIG. 1, a scenario diagram is provided for running a dirty page write thread. The database system consists of a processor, a memory and a disk, wherein the processor starts a dirty page writing thread for updating a dirty page of a dirty page buffer area in the memory to a data page in the disk.
After the database system is online with new functions or the system is optimized and upgraded, whether each function operates normally or not needs to be verified so as to ensure performance stability. Specifically, the running state of the thread can be monitored by recording the thread state data, so that each function can be verified. For example, the thread state data includes thread name, start time, end time, run time, and so forth.
Among these, thread state data is typically recorded in two ways:
in one aspect, a computing device records thread state data in a log.
The log (log) is used to record various event information generated by the database system during operation. For example, the database system includes log types such as redo log (redo log) and rollback log (undo log). The redo log is used for recording the modification operation of data, when the system is suddenly powered off, the data which is not stored in the memory of the disk can be lost, and the data in the backup disk and the data of the main disk can be synchronized by carrying out corresponding operation on the existing data in the backup disk through the redo log. By rolling back the log, data prior to the transaction commit can be restored.
When the computing device starts the auxiliary thread, the auxiliary thread can call the log interface, record thread state data in the memory, generate a log, and store the log into the disk to form a log file. As shown in fig. 2, taking the dirty page writing thread in fig. 1 as an example, the dirty page writing thread synchronously records thread state data in a memory during operation, and stores a log file in a disk, and releases the dirty page writing thread after the operation is completed. When the secondary thread subsequently causes a system performance problem, such as when the thread runs too long, a technician can determine the past running state of the secondary thread through a playback log, thereby adjusting the relevant configuration information of the thread. For example, when the assist thread is a dirty page write thread, when the data volume written by the dirty page write thread into the disk is too large, the running time of the dirty page write thread may be too long, which causes a system alarm, at this time, a technician may determine the frequency of calling the dirty page write thread through a log, or determine the time interval of the dirty page write thread accessing the dirty page buffer area through the log, and through adaptive adjustment, the data volume written by the dirty page write thread is reduced, so as to improve the system performance.
However, since the log needs to satisfy the records of various event types, and the recorded information types or formats are not limited, it is difficult to locate the running states of the corresponding auxiliary threads in the log, and a technician is required to analyze the log piece by piece according to the log content, so that more time and cost are consumed, and the risk of omission exists, so that the reading efficiency of the thread state data is affected.
And secondly, the computing equipment records the thread state data in a system table.
The system table is used for storing metadata information of various objects in the database, including objects such as tables, columns, indexes and the like. For example, the metadata information includes the information type and length of the names, data types, attributes, storage locations, and the like of the respective objects.
When the computing device starts the auxiliary thread, the auxiliary thread can call the system table interface, record the thread state data in the memory, store the information into the disk, and release the thread after the operation is completed. As shown in fig. 3, in a manner similar to that of fig. 2, but in this manner, since the thread state data is written in a manner defined in the system table, when the assist thread subsequently causes a system performance problem, a technician can search the system table for the thread name and locate the relevant information of the thread.
Compared with the log recording mode, the method can help technicians to quickly position the thread state data when reading the system table later, but the writing efficiency of the thread state data is affected due to the complex recording process.
It can be seen that the recording efficiency of the thread state data in the two modes is not ideal. In addition, the operation state of the thread cannot be monitored by the aid of the high-frequency call auxiliary thread in the two modes. For example, for a helper thread to call ten thousand times in 1 second, ten thousand logs need to be written in 1 second or ten thousand times thread state data need to be recorded in the system table. Obviously, this method cannot be applied, and thus, when the high-frequency calling auxiliary thread affects the system performance, the problem of positioning related parameter information cannot be obtained.
In this regard, the present application provides a thread state recording method, which is applied to the database system described above. The database system may be any computing device that manages a database. The embodiments of the present application are not limited in any way to the specific form of computing device. For example, the computing device may be a server or other computing device that manages a database. The server may be a rack server, a high-density server, a blade server, or a tower server, which is not limited in this embodiment.
In a hardware implementation, the computing device described above may be implemented by a computing device as shown in FIG. 4. Fig. 4 is a schematic hardware structure of a computing device 40 according to an embodiment of the present application. Computing device 40 may be used to implement the functionality of the computing devices described above.
The computing device 40 shown in fig. 4 may include: a processor 401, a memory 402, a communication interface 403, and a bus 404. The processor 401, the memory 402, and the communication interface 403 may be connected by a bus 404.
The processor 401 is a control center of the computing device 40, and includes one or more general-purpose central processing units (central processing unit, CPU), other general-purpose processors, and the like. Wherein the general purpose processor may be a microprocessor or any conventional processor or the like.
As an example, in fig. 4, the processor 401 may include a CPU 0 and a CPU 1. The figures are by way of example only and more or fewer CPUs may be included in a practical application.
Memory 402 may be, but is not limited to, read-only memory (ROM) or other type of static storage device that may store static information and instructions, random access memory (random access memory, RAM) or other type of dynamic storage device that may store information and instructions, as well as electrically erasable programmable read-only memory (EEPROM), magnetic disk storage or other magnetic storage devices, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by a computing device.
In one possible implementation, the memory 402 may exist independent of the processor 401. The memory 402 may be coupled to the processor 401 via a bus 404 for storing data, instructions or program code. The thread state recording method provided in the embodiment of the present application can be implemented when the processor 401 calls and executes instructions or program codes stored in the memory 402.
In another possible implementation, the memory 402 may also be integrated with the processor 401.
In the present embodiment, memory 402 includes an internal memory and an external memory. The internal memory may be simply referred to as a memory, and has a relatively high data access speed and a relatively small capacity, and is used for storing operation data of the CPU and invoking data in the external memory. External memory including magnetic disks (including floppy disks and hard disks), optical disks, U-disks, and the like. The hard disk comprises a solid state disk and a mechanical hard disk. The external memory can be called external memory for short, and has slower data access speed and larger capacity. Data in memory is lost after the computing device is powered down, while data in memory is not lost.
A communication interface 403 for connecting the computing device 40 with other devices via a communication network, which may be ethernet, a radio access network (radio access network, RAN), a wireless local area network (wireless local area networks, WLAN), etc. The communication interface 403 may include a receiving unit for receiving data and a transmitting unit for transmitting data.
Bus 404 may be an industry standard architecture (industry standard architecture, ISA) bus, an external device interconnect (peripheral component interconnect, PCI) bus, or an extended industry standard architecture (extended industry standard architecture, EISA) bus, among others. The bus may be classified as an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown in fig. 4, but not only one bus or one type of bus.
It should be noted that the structure shown in fig. 4 does not constitute a limitation of computing device 40, and that computing device 40 may include more or less components than those shown in fig. 4, or may combine some components, or a different arrangement of components.
As shown in fig. 5, in the method for recording thread state according to the embodiment of the present application, the method may help to improve the recording efficiency of thread state data, thereby further improving the calling efficiency of the thread and improving the overall performance of the system. Specifically, the steps S501-S502 are as follows.
S501, starting a first thread, and recording thread state data of the first thread in a preset memory area, wherein the thread state data are used for indicating the running state of the first thread.
The preset memory area is used for storing thread state data of the first thread. The first thread is an assist thread, and may include any one of a WAL write thread, a WAL send thread, a WAL receive thread, and a dirty page write thread.
In one possible implementation, the preset memory region includes one or more sub-memory regions, and each of the one or more sub-memory regions is configured to store thread state data of a first thread.
It may be appreciated that in the embodiment of the present application, the thread state data corresponds to the first threads one by one, and each running first thread may record the corresponding thread state data.
It can be appreciated that the preset memory area is a portion of the resources in the memory, where the portion of the resources is used to store the thread state data of the first thread.
Exemplary, as shown in fig. 6, a composition diagram of a predetermined memory area is shown. The preset memory area comprises sub memory areas (slot) 1, slot 2, slot 3, … … and slot n, wherein n is an integer greater than zero. The amount of data that can be stored per slot may be the same or different.
It should be noted that, the preset memory area can be flexibly adjusted according to the running number of the auxiliary threads. For example, one slot is used to store thread state data of a first thread (auxiliary thread), and when the number of the first thread is greater than that of the current slots, the database system applies for more memory areas, and increases the available slots to adapt to the number of the first threads. When the number of the first threads is smaller than that of the current slots, the database system can release part of the slots to adapt to the number of the first threads, so that the dynamic adjustment of the preset memory area is realized, and the resource utilization efficiency of the memory is improved.
Optionally, each slot includes one or more predefined fields, one predefined field being used to indicate a type of thread state data, the thread state data comprising the thread state data of the first thread.
Exemplary, as shown in fig. 7, a slot is schematically formed. The slot consists of a field 1, a field 2, a field … … and a field m, wherein m is an integer greater than zero. Different fields store different types of thread state data, which may also be referred to as index entries. For example, field 1 stores the thread name of the first thread recorded by the slot, field 2 stores the start time of the first thread, and so on. The size of each field may be the same or different, e.g., 8 bytes each.
In fig. 7, slots may also be divided into slots header (header) and slots volume (status details). The slot body is used for recording specific state information of the first thread, such as the data volume processed by the first thread, the calling times of the first thread, the running time of the first thread and the like.
For example, assuming that the first thread is the WAL write thread, the slot header includes the WAL write thread, a start time, and an end time, and the slot body includes information such as a data amount written by the WAL write thread, a call number of the WAL write thread, an operation duration of the WAL write thread, and the operation duration may be calculated by the start time and the end time. The sizes of slots corresponding to different threads are different, for example, if the first thread is the WAL Sender, the slot header can store the thread name WAL Sender, starting time and ending time, and the slot body contains information such as data volume sent by the WAL Sender, calling times of the WAL Sender, running time of the WAL Sender, network sending/receiving time and the like; if the first thread is a WAL Writer, the slot header may store the thread name WAL Writer, and the start time and end time of the thread, and the slot body may store information such as the data volume of the write disk, the write disk time, the synchronous/asynchronous write disk call number, and the like.
That is, the amount of data processed for a thread may be recorded based on the actual functionality of the thread. Similarly, the amount of data processed for pagewriter is the amount of data that the thread writes to a dirty page in disk.
In fig. 7, the slot header includes one field (field 1), and the slot body includes a plurality of fields (field 2-field m), and in practical application, the number of fields included in the slot header or the slot body is not limited. In addition, the types of the indicated thread state data of each field are not limited, and the thread state data can be flexibly changed according to the actual functions of the threads and the corresponding configuration requirements.
It should be noted that, the amount of data storable in each sub-memory area may be set according to the maximum amount of data of the recorded thread state data, for example, the maximum amount of data of the thread state data recorded by one thread is 200 bytes, and the amount of data storable in each sub-memory area is set to be 200 bytes. In addition, the amount of data that may be stored in the sub-memory area for recording thread state data for different types of first threads may be the same or different. For example, the sub-memory region that records thread state data for the WAL write thread is different from the amount of data that can be stored in the sub-memory region that records thread state data for the WAL send thread. When the monitored thread state data is increased or decreased, the field can be correspondingly modified in each sub-memory area, so that the storable data quantity of the sub-memory area can be flexibly changed according to the actual monitoring requirement. Wherein each field may be 8 bytes and the size of the different fields may be the same or different.
It can be appreciated that, through the predefined fields, the computing device is facilitated to record corresponding thread state data according to the fields, so as to obtain thread state data of the thread, and facilitate rapid positioning of historical thread state data of the thread when system performance is affected in a subsequent running process of the thread.
Specifically, the slots may be managed in the memory by a slot management module. Fig. 8 is a schematic architecture diagram of a slot management module according to an embodiment of the present application. For example, in fig. 8, the slot management module is configured to manage slots 1-n in a preset memory area, for example, the slot management module may allocate an appropriate number of slots to the system according to the number of first threads.
In order to record the thread state data of the first thread into the external surface, reduce the repeated application of new storage space to the memory, and reduce the consumption of the memory, the database system may create two linked lists, one is a free linked list (freelist) and the other is a file to be written linked list (suspenslist), where the free linked list is mainly used to mount the free slot so as to temporarily store the thread state data of the first thread, specifically, an address of the free slot may be allocated to a row in the free linked list, for example, an address of slot1 may be allocated to a first row in the free linked list, and an address of slot 2 may be allocated to a second row … … slot n in the free linked list to an nth row in the free linked list. When the first thread is started, the slot management module can configure idle slots with the same number as the first thread for the thread to temporarily store thread state data of the first thread in an idle linked list. The file linked list to be written is mainly used for mounting the slot storing the thread state data of the first thread so as to be written into the disk later. It should be understood that a slot is a storage unit of a linked list, and may correspond to a row of data in a linked list, where a linked list may include one or more slots, where each slot implements a link by storing an address of a next slot. For example, in the free linked list of fig. 8, the address of slot 2 is stored in slot1, and the address of slot 3 is stored in slot 2. For another example, in the file linked list to be written in fig. 8, the address of slot b is stored in slot a. The slot a and the slot b are any two occupied slots in the slot n. A slot may be used to store a first thread state data, and the first thread may be an auxiliary thread, such as one or more of a WAL write thread, a WAL send thread, a WAL receive thread, or a dirty page write thread. In the embodiment of the application, in order to save the storage space, the idle linked list may be a dynamic linked list, and when slots of the idle linked list are insufficient, for example, the storage space of the idle linked list is insufficient, the storage space may be dynamically applied. For example, in fig. 8, a new slot may be added after the slot n, specifically, the address of the new slot may be allocated to the n+1st row in the idle linked list, and the address of the newly added slot may be stored in the slot n to update the idle linked list. In addition, in order to reduce the allocation times of the memory or the application times of the memory, after the data stored in the slots of the file linked list to be written is written into the file, the corresponding slots can be used as idle slots again to be hung on the idle linked list.
Specifically, when the above step S501 is applied to the architecture shown in fig. 8, as shown in fig. 9, a schematic view of a thread state recording method provided in an embodiment of the present application is provided, which includes the following steps S901-S902.
S901, recording thread state data of a first thread into idle slots in an idle linked list freelist. Specifically, after the first thread is started, an idle slot in the freelist can be obtained through a slot management module, and in the running process, thread state data of the first thread is written into the idle slot, one slot is used for storing state information of one first thread, and the number of the first threads can be one or more.
It should be noted that, the pointer in the idle linked list always points to the slot1 of the first line, when the slot1 stores the thread state data of one first thread, the slot1 is full of data, and then the thread state data of another first thread may store the thread state data of another thread to the slot 2 according to the address of the slot 2 pointed to in the slot 1.
S902, the first thread mounts the slot storing the thread state data of the first thread in the idle linked list freelist to the to-be-written file linked list sustendlist.
Specifically, when the operation of one first thread a is finished, the thread state data of the first thread a is written into the slot 1, the first thread a mounts the slot 1 under the to-be-written file linked list suspartilist, if the other first thread B is finished after a period of time after the operation of the first thread a is finished, the thread state data of the first thread B is written into the slot 2, the first thread B mounts the slot 2 under the to-be-written file linked list suspartilist, and the allocation mode of the first thread B in the idle linked list freelist is the same as that of the first thread B, the address of the slot 1 can be allocated to the first row in the to-be-written file linked list suspartilist, and the address of the slot 2 can be allocated to the second row in the to-be-written file linked list suspartilist.
When there are multiple first threads running in parallel, there may be two or more threads ending running at the same time, if these threads mount their corresponding slots under the to-be-written file linked list suspenslist, then there may be access conflict of the to-be-written file linked list suspenslist, in order to avoid conflict, the database system may set a synchronization lock for the to-be-written file linked list suspenslist, when one of the first threads a acquires the synchronization lock, it has the authority to access the to-be-written file linked list, and at the same time, the synchronization lock will also record the identifier of the first thread a, during the period that the first thread a accesses the to-be-written file linked list, other first threads cannot access the to-be-written file linked list, wait for the first thread a to access the to-be-written file linked list, and the other first threads that acquire the synchronization lock may access the to-be-written file linked list, and mount their corresponding slots under the to-be-written file linked list.
Through the steps S901-S902, after the auxiliary thread is started, the idle slot for recording the thread state data is obtained through the slot management module, after the recording is finished, the thread state data is fed back to the slot management module, the slot management module mounts the slot into the file linked list to be written again, the time occupied by the memory for recording the thread state data and releasing the memory after the thread is started is reduced, and the thread recording efficiency is improved.
S502, starting an asynchronous second thread, wherein the second thread is used for writing thread state data of the first thread into an external memory.
Specifically, the second thread accesses the preset memory area to obtain the thread state data of the first thread, and writes the thread state data into the external memory. Illustratively, the second thread is an asynchronous write thread. For example, the preset memory area is the file linked list to be written for storing the thread state data.
The external memory is illustratively a magnetic disk. Hereinafter, a disk is described in detail as an example.
The thread state data of the first thread may be written into a data file of the disk. And reads the data file to obtain thread state data based on the manner in which the table is loaded, the table being in read-only form for technician reference and analysis.
It can be understood that by the above manner, the computing device may write the thread state data of the first thread into the disk by starting the second thread, which is helpful to release the first thread in advance after writing the thread state data into the memory, and write the thread state data in the memory into the disk by the second thread, so that when only one thread is used to write the recorded thread state data into the memory, the thread is prevented from being released after waiting for the thread state data to be written into the disk, and the recording efficiency and the subsequent calling efficiency of the first thread are improved. In addition, the historical thread state data of the thread is conveniently and rapidly positioned by a subsequent technician through recording in a mode of predefined fields, and parameter adjustment is correspondingly carried out.
In one possible implementation, the second thread accesses the file linked list to be written to obtain the thread state data of the first thread, and writes the thread state data to the disk.
Specifically, the second thread periodically accesses the file linked list to be written through the slot management module. In order to avoid the conflict between the second thread accessing the file linked list to be written and the process of mounting slots to the file linked list to be written by the other first threads, the synchronous lock set by the database system aiming at the file linked list to be written can be used for avoiding the problem of the conflict that a plurality of threads simultaneously access the file linked list to be written.
Illustratively, when the file linked list to be written is being accessed, it is indicated that the currently accessed thread has acquired the synchronization lock, and the synchronization lock records an identification of the currently accessed thread, the identification indicating that the file linked list to be written is currently being accessed by the first thread or the second thread. At this time, no synchronization lock is obtained for other threads, and no identification of other threads is recorded in the synchronization lock, so that other threads cannot access the file linked list to be written. By the method, an independent access environment can be established for the file linked list to be written, so that the conflict caused by simultaneous access of a plurality of threads is avoided, and the stability of the system is maintained.
Similarly, the database system also creates a corresponding synchronization lock for the free linked list, and the first line Cheng Zhuyi for startup writes its corresponding thread state data into the corresponding slot, avoiding conflicts when accessing simultaneously.
Optionally, in order to further avoid the access conflict of the first thread to the external memory when the second thread writes the thread state data of the first thread into the external memory, the second thread and the first thread simultaneously raise the efficiency of writing the thread state data of the first thread into the external memory, shorten the writing time, create a temporary linked list tmplist by the database system, and periodically monitor whether there is new data in the to-be-written linked list, that is, if the second thread monitors that the to-be-written linked list is loaded with slots, the slots are mounted under the temporary linked list tmplist, specifically, the second thread points the table pointer of the temporary linked list tmplist to the first row of the to-be-written linked list suspondlist, so that all slots mounted under the to-be-written linked list may be mounted under the temporary linked list tmplist, and the to-be-written linked list is set empty, thereby facilitating the first thread to continue to mount the slots or add the thread storing the state data of the first thread to be-written.
Exemplary, as shown in fig. 10, a schematic view of a scenario for creating a temporary linked list is shown. The file to be written includes slot1-slot n storing thread state data of the first thread, and the table pointer of the temporary link table points to the first row of the file to be written, so that slot1 is mounted to the first row of the temporary link table, and the next slot address is stored in each slot, so that all slots in the file to be written link table are mounted to the temporary link table, and the efficiency of transferring data from the file to be written link table to the temporary link table can be improved in this way. And then, the second thread accesses the temporary linked list, and sequentially writes thread state data stored by each slot in the linked list into a data file, wherein the data file is a persistent file in a disk.
Further, after the second thread writes the thread state data in the slots into the data file, each slot can be mounted in the idle linked list again, so that cyclic utilization of the slots is realized. Therefore, when the database system needs to count the thread state data of the first thread, the memory area is applied to the memory again, and the memory consumption is reduced. Illustratively, as shown in FIG. 11, slots 1-slot n in the temporary linked list may be re-mounted to the free linked list.
Specifically, after writing data stored in slots in the temporary linked list (the data is thread state data of the first thread) into the data file, the second thread may mount the first slot in the temporary linked list to the idle linked list, and at this time, if other slots, such as slot a and slot b, are also mounted in the idle linked list, then the second thread may mount slot1 on a row after slot b, specifically, may direct the head pointer of the temporary linked list to the next row of slot b in the idle linked list, so as to implement mounting. In this way, the cyclic utilization of slots is realized, and the utilization rate of memory resources occupied by the thread state data recorded by each thread is improved.
It should be noted that, when the slot to be mounted to the file to be written linked list exists in the idle linked list, as shown in fig. 11, two slots a and b to be mounted to the file to be written linked list are also mounted in the idle linked list, and thread state data of a first thread are stored in the two slots, then the first slot in the temporary linked list is mounted to the next row of the last slot of the idle linked list; when the idle linked list is empty, the head pointer of the temporary linked list points to the first row of the idle linked list, so that slot 1-slot n can be respectively mounted to the 1 st row to the n th row of the idle linked list.
It can be understood that when the computing device starts the second thread to write the data in the slot downloaded from the file list to be written into the data file, the second thread occupies the file list to be written for a long time, and at this time, the thread of the first thread in running cannot access the file list to be written, for example, the slot storing the data in the idle linked list cannot be mounted to the file list to be written, so that the first thread cannot be released in time, the CPU resource is occupied, or the accesses of the first thread and the second thread to the file list to be written collide, resulting in abnormal database system. In this regard, by the above manner of creating the temporary linked list, the slot downloaded and mounted in the file linked list to be written is mounted to the temporary linked list, and the file linked list to be written is emptied, so that the second thread can write the data file in the disk based on the data thread state data in the slot downloaded and mounted in the temporary linked list, thereby avoiding the second thread from accessing the file linked list to be written for a long time, and the first thread can timely release the file after timely storing the state information of the first thread (background assistance), thereby improving the recording efficiency of the thread state and the running efficiency of the system. In addition, after the slots under the file linked list to be written are mounted under the temporary linked list, the file linked list to be written is emptied, so that when the slots in the idle linked list are used for recording thread state data again, the first thread mounts the slots to the file linked list to be written again, and new thread state data is stored in the memory, and the waste of storage space is avoided.
Optionally, the second thread may access the file list to be written according to a certain frequency, specifically, the step S502 includes: the second thread accesses the file linked list to be written according to a first time interval, if the file linked list to be written is accessed twice continuously, slots exist in the file linked list to be written, after the thread state data corresponding to each slot in the file linked list to be written are written into a disk, the first time interval is modified to be a second time interval, and the second time interval is smaller than the first time interval; and if the linked list of the file to be written is accessed twice in succession, and when no slot exists in the linked list of the file to be written, modifying the first time interval into a third time interval, wherein the third time interval is larger than the first time interval.
That is, the database system may periodically start the second thread to access the file list to be written and determine whether the slot of the file to be written exists in the file list to be written, so as to flexibly adjust the period while implementing writing of the thread state data, thereby avoiding resource waste caused by frequently calling the second thread.
By the method, the situation that whether the database system accesses the slot contained in the file linked list to be written each time is facilitated, and the time interval for starting the second thread is dynamically adjusted, so that the time interval is shortened when the slot exists in the file linked list to be written, the writing efficiency of thread state data is improved, the time interval is increased when the slot does not exist in the file linked list to be written, and the resource expense is saved.
The adjustment range of the time interval may be preset, for example, increased or decreased by 1 second each time, which is not limited. In addition, the above-described process may be cyclically performed. For example, if the first time interval is 3 seconds, when the second thread is started and the slot is found to be absent in the file linked list to be written, the first time interval is adjusted to be 4 seconds, and when the second thread is started again after the interval of 4 seconds, if the slot is still absent in the file linked list to be written, the time interval can be continuously adjusted to be 5 seconds. The computing device may further define a minimum time interval and a maximum time interval in advance, so as to limit the value ranges of the first time interval, the second time interval and the third time interval. For example, the minimum time interval is 1 second and the maximum time interval is 10 seconds.
In conjunction with the above description about fig. 9-11, an embodiment of the present application provides a method for recording a thread status record, as shown in fig. 12, where the method is applied to a database system, and the database system includes a first thread, a second thread, and a file linked list to be written, and the method includes:
s601, in the running process of the first thread, the first thread records thread state data of the first thread to the file linked list to be written, and a sub-memory slot of a memory is mounted in the file linked list to be written, wherein one sub-memory slot is used for storing the thread state data of the first thread; step S601 may refer to steps S901-S902, which are not described herein.
S602, the second thread writes the thread state data in the file linked list to be written into a data file of a magnetic disk. Step S602 may be described in part with reference to step S502.
In conjunction with the above detailed description about step S502, as shown in fig. 13, a flowchart of storing thread state data based on the second thread according to an embodiment of the present application is provided.
S1201, starting a second thread, and accessing a file linked list to be written.
The file linked list to be written is used for mounting slots for recording thread state data, and thread state data of an auxiliary thread is stored in one slot. The related description of the second thread accessing the file linked list to be written may refer to the above, and will not be repeated.
S1202, judging whether slots exist in the file linked list to be written.
If yes, go to step S1203-S1204; if not, step S1205 is executed.
S1203, mounting slots in the file linked list to be written to the temporary linked list.
The step of mounting the slots in the file linked list to be written to the temporary linked list comprises the step of pointing a table pointer of the temporary linked list to a first row of the file linked list to be written, wherein the step of mounting the slots 1 indicated by a first row address in the file linked list to be written to the first row of the temporary linked list can be realized.
S1204, clearing the file list to be written.
By clearing the file linked list to be written, the new slots in the idle linked list are facilitated to be stored in the file linked list to be written, so that the new slots can be mounted in the temporary linked list later.
S1205, starting the second thread again after dormancy according to the first time interval.
It can be understood that when a slot does not exist in the file linked list to be written, the first thread which indicates that the current database system does not exist to run is indicated, and accordingly, the second thread can be dormant for a period of time to restart without recording thread state data.
The first time interval may be adjusted according to whether the file linked list to be written in step S1202 includes slots and the number of slots in two adjacent time periods. For example, in the adjacent two access time intervals, slots exist in the file linked list to be written, or the number of slots is larger than a first threshold, the first time interval can be shortened, and in the adjacent two access time intervals, slots do not exist in the file linked list to be written, or the number of slots is smaller than a second threshold, the first time interval can be increased. The first threshold is greater than the second threshold, and the first threshold and the second threshold may be set according to an actual operation condition of the computing device, which is not limited.
S1206, judging that the temporary linked list is loaded with slots.
If yes, go to step S1207; if not, waiting.
S1207, writing the thread state data in the slots of the temporary linked list into the data file one by one.
The data file is a file in a disk, specifically, the second thread may read the thread state data in one slot at a time and write the thread state data into the data file, for example, the second thread reads the thread state data of the first thread a stored in the slot1 first, reads the thread state data of the first thread B stored in the slot2 after writing the information into the data file, and reads the thread state data … … of the first thread C stored in the slot3 after writing the information into the data file.
S1208, traversing slots in the temporary linked list, judging whether thread state information in the slots of the temporary linked list is written into the data file entirely, if so, executing S1209, and if not, executing S1207 until all data stored in all slots of the temporary linked list are written into the data file.
S1209, re-mounting the slots of the temporary linked list to the idle linked list.
Reference may be made specifically to the description of slots mounted to free linked lists in the temporary linked list above.
Optionally, after step S1209 is performed, the temporary linked list may be further cleared, so that a new slot may be mounted to the temporary linked list later.
Through the steps S1201-S1209, the computing device writes the thread state data in the preset memory area into the external memory one by one through the second thread, and realizes flexible call of the second thread through the sleep mode, thereby saving computing resources; by means of creating the temporary linked list, the method is beneficial to reducing the time for the second thread to access the file linked list to be written, and timely clearing elements in the file linked list to be written, so that a storage space is provided for writing new thread state data, and writing efficiency is improved.
Optionally, in the thread state recording method described in the above steps S501 to S502, the recording time interval of the thread state data of the first thread recorded twice is greater than or equal to the preset time interval.
It is understood that when the above steps S501 to S502 are adopted for recording for the thread called at high frequency, there is a problem that the amount of data written in a short time is large. In this regard, the embodiment of the present application further provides a thread recording method, configured to sample a thread called at a high frequency, and record thread state data of the thread according to a preset time interval, so as to prevent an influence on operation of a system while monitoring an operation state of the thread.
In one possible implementation, as shown in FIG. 14, the following steps S1301-S1303 are included.
S1301, after the first thread is started, acquiring the sampling time of the first thread, wherein the sampling time is used for indicating the time of last recording the thread state data of the first thread.
Optionally, the sampling time is a start time of the first thread corresponding to the last recorded thread state data.
S1302, if it is determined that the interval between the starting time of the first thread and the sampling time of the first thread is greater than or equal to a preset time interval, recording thread state data of the first thread currently started in a preset memory area; and stopping recording the thread state data if the interval between the starting time of the first thread and the sampling time of the first thread is smaller than the preset time interval.
The preset time interval may be predefined in the computing device. The preset time interval is, for example, 1 second.
It can be understood that when the interval from the last sampling time is determined to be smaller than the preset time interval after the first thread is started this time, in order to avoid frequent recording of thread state data in a short time, for example, when thread a is called for multiple times in the preset time interval, when thread a called for each time records thread state data, the operation efficiency of the thread a is affected and more thread state data is caused to be written into a file, so that excessive resources are occupied, and at this time, recording is stopped; and recording the thread state data of the first thread when the interval from the last sampling time is larger than or equal to the preset time interval.
The method can be used for monitoring the running state information of threads called at high frequency. For example, assuming that the preset time interval is 1 second, for a thread a that is called ten thousand times within 1 second, when the thread a is started for the first time, the sampling time of the thread a is 0, the thread state data of the thread a called this time is recorded, and the sampling time is updated to the starting time of the thread a called this time, for example, the first time; when the thread a is started for the second time, the starting time of the thread a is obtained, for example, the second time is calculated, the time interval between the time and the last sampling time is calculated, for example, the difference between the second time and the first time is ten thousand times in 1 second, and therefore, the difference between the second time and the first time is smaller than the preset time interval by 1 second, and the thread state data of the thread a called for the second time is not recorded. And repeating the judging process when the thread a is called every time later until the first ten thousand times when the thread a is started, recording the thread state data of the thread a again when the time interval between the starting time and the sampling time of the thread is more than 1 second, and recording the thread state data of the thread a called at high frequency according to the time interval of 1 second.
S1303, after the thread state data of the first thread started currently is recorded in the preset memory area, the sampling time is updated.
It can be appreciated that after the thread state data is recorded again, the sampling time is updated to the start time of the corresponding thread, so that the subsequent thread can be judged again when being called.
By adopting the mode, the thread which is called at high frequency can be monitored, compared with the recording mode adopting a log or a system table, the recording mode of the thread state data is smaller in recorded data quantity and higher in recording efficiency, and the problem location is carried out by observing the state information of the thread in the history time when the subsequent thread influences the running of the system, so that the monitoring strength of the system to the thread is improved.
Optionally, after the step S502, the method further includes: reading a data file in an external memory based on an external loading mode, and acquiring thread state data of one or more first threads; based on one or more predefined fields in the thread state data of one or more first threads, a search condition is set, the search condition being used to troubleshoot the fault.
Illustratively, taking the first thread as a pagewriter as an example, wherein dirty pages are stored in a dirty page buffer in the memory, after each activation of the pagewriter, all dirty pages of the dirty page buffer are written to disk. When the pagewriter is called for a certain time, if the data in the dirty page buffer is more, system jitter is caused. The technician may call the table for recording the thread state data, and further, set a search condition for processing data amount in the table, for example, search for thread state data with processing data amount greater than 500MB, and if the result of satisfying the search condition is found to be more, the time interval for calling pagewriter may be shortened. It will be appreciated that when the time interval for calling pagewriter is shortened, the frequency of the pagewriter accessing the dirty page buffer is increased, so that the data volume of each called pagewriter written into the disk is reduced, and the possibility of jitter generated by the system due to the pagewriter is reduced.
It can be understood that, based on the steps S501-S502, the thread state data is written into the disk file for storage, and the method of loading the appearance is more convenient and quicker than the method of querying the internal table, which is helpful for technicians to quickly obtain the thread state data affecting the system performance, and set the search condition to locate problems according to the recorded thread state data, thereby improving the efficiency of fault detection.
The foregoing description of the embodiments of the present application has been presented primarily from a method perspective. It is to be understood that the computing device, in order to implement the above-described functionality, includes at least one of corresponding hardware structures and software modules that perform the respective functions. Those of skill in the art will readily appreciate that the elements and algorithm steps of the examples described in connection with the embodiments disclosed herein may be implemented as hardware or combinations of hardware and computer software. Whether a function is implemented as hardware or computer software driven hardware depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
The embodiment of the application may divide the functional units of the computing device according to the above method example, for example, each functional unit may be divided corresponding to each function, or two or more functions may be integrated in one processing unit. The integrated units may be implemented in hardware or in software functional units. It should be noted that, in the embodiment of the present application, the division of the units is schematic, which is merely a logic function division, and other division manners may be implemented in actual practice.
Fig. 15 shows a possible structural diagram of the computing device involved in the above-described embodiment in the case where respective functional blocks are divided with corresponding respective functions.
As shown in fig. 15, the computing device 140 includes a processing unit 1401 and a storage unit 1402. The processing unit 1401 is configured to start a first thread, record thread state data of the first thread to a file linked list to be written in a running process of the first thread, where a sub-memory slot of a memory is mounted in the file linked list to be written, where one sub-memory slot is used to store thread state data of the first thread; the processing unit 1401 is further configured to start a second thread, and write thread state data in the file list to be written into a data file of the disk.
In one example, the database system further includes an idle linked list, where the idle linked list is loaded with a sub-memory slot of the memory, and the processing unit 1401 is specifically configured to: under the condition that the thread state data of the first thread is stored in the sub-memory slot of the idle linked list download mount, the sub-memory slot of the idle linked list download mount is mounted to a file linked list to be written; wherein a sub-memory slot is used to store thread state data of a first thread.
In one example, the database system further includes a temporary linked list, and the processing unit 1401 is specifically configured to: the second thread mounts the sub-memory slot to the temporary linked list under the condition that the to-be-written file linked list is monitored to mount the sub-memory slot; and the second thread writes the thread state data in the child memory slot downloaded by the temporary linked list into a data file of the disk.
In one example, the processing unit 1401 is further configured to reload the child memory slot to the idle linked list.
In one example, the thread state data includes one or more of a data throughput of the first thread, a start time of the first thread, an end time of the first thread, a number of calls of the first thread, a run time of the first thread.
In one example, the first thread is multiple, the file linked list to be written includes a synchronization lock, and the first thread that acquires the synchronization lock has the right to access the file linked list to be written; the processing unit 1401 is specifically configured to: and under the condition that one first thread acquires the synchronous lock, the first thread records the thread state data of the first thread to a file linked list to be written.
In one example, the second thread is asynchronous with the first thread.
In one example, the processing unit 1401 is specifically configured to start the second thread at a first time interval, and access a file linked list to be written; if the sub memory slots exist in the file linked list to be written or the number of the sub memory slots is larger than a first threshold value within the adjacent two access time intervals, after the thread state data in the sub memory slots to be downloaded and mounted in the temporary linked list are written into the data file of the magnetic disk, the first time interval is adjusted to be a second time interval; the second time interval is less than the first time interval; if no sub-memory slots exist in the file linked list to be written or the number of the sub-memory slots is smaller than a second threshold value within the adjacent two access time intervals, after the thread state data in the sub-memory slots to be downloaded and mounted in the temporary linked list are written into the data file of the magnetic disk, the first time interval is adjusted to be a third time interval; wherein the third time interval is greater than the first time interval; the first threshold is greater than the second threshold.
In one example, the processing unit 1401 is further configured to read a data file of the disk based on the manner of surface loading, and obtain thread state data of the first thread; based on the thread state data of the first thread, search conditions are set, and the search conditions are used for troubleshooting.
In one example, the first thread includes one or more of a pre-written log WAL write thread, a WAL send thread, a WAL receive thread, and a dirty page write thread.
In one example, the storage unit 1402 is configured to store computer-executable instructions, and the processing unit in the computing device may perform corresponding actions according to the computer-executable instructions stored in the storage unit 1402.
For a specific description of the above alternative modes, reference may be made to the foregoing method embodiments, and details are not repeated here. In addition, any explanation and description of the beneficial effects of the computing device 140 provided above may refer to the corresponding method embodiments described above, and will not be repeated.
The embodiment of the application also provides a computing device, which is combined with the hardware structure schematic diagram shown in fig. 4, wherein the computing device comprises a processor and a memory, and the processor and the memory are electrically connected; the processor is used for starting the first thread, and recording thread state data of the first thread to a file linked list to be written in the running process of the first thread, wherein a sub-memory slot of a memory is mounted in the file linked list to be written, and one sub-memory slot is used for storing the thread state data of one first thread; and the processor is also used for starting a second thread and writing the thread state data in the file linked list to be written into the data file of the disk.
For the explanation and description of the beneficial effects of the related content in the computing device provided above, reference may be made to the corresponding embodiments described above, and details are not repeated here.
Embodiments of the present application also provide a computer-readable storage medium having stored thereon a computer program which, when run on a computer, causes the computer to perform the method performed by any one of the computing devices provided above.
For the explanation of the relevant content and the description of the beneficial effects in any of the above-mentioned computer-readable storage media, reference may be made to the above-mentioned corresponding embodiments, and the description thereof will not be repeated here.
The embodiment of the application also provides a chip. The chip has integrated therein control circuitry and one or more ports for implementing the functions of the computing device described above. Optionally, the functions supported by the chip may be referred to above, and will not be described herein. Those of ordinary skill in the art will appreciate that all or a portion of the steps implementing the above-described embodiments may be implemented by a program to instruct associated hardware. The program may be stored in a computer readable storage medium. The above-mentioned storage medium may be a read-only memory, a random access memory, or the like. The processing unit or processor may be a central processing unit, a general purpose processor, an application specific integrated circuit (application specific integrated circuit, ASIC), a microprocessor (digital signal processor, DSP), a field programmable gate array (field programmable gate array, FPGA) or other programmable logic device, transistor logic device, hardware components, or any combination thereof.
Embodiments of the present application also provide a computer program product comprising instructions which, when run on a computer, cause the computer to perform any of the methods of the above embodiments. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions in accordance with embodiments of the present application are produced in whole or in part. The computer may be a general purpose computer, a special purpose computer, a computer network, or other programmable apparatus. The computer instructions may be stored in or transmitted from one computer-readable storage medium to another, for example, a website, computer, server, or data center via a wired (e.g., coaxial cable, fiber optic, digital subscriber line (digital subscriber line, DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. Computer readable storage media can be any available media that can be accessed by a computer or data storage devices including one or more servers, data centers, etc. that can be integrated with the media. The usable medium may be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., SSD), etc.
It should be noted that the above-mentioned devices for storing computer instructions or computer programs, such as, but not limited to, the above-mentioned memories, computer-readable storage media, communication chips, and the like, provided in the embodiments of the present application all have non-volatility (non-transparency).
In the above embodiments, it may be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using a software program, it may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions in accordance with embodiments of the present application are produced in whole or in part. The computer may be a general purpose computer, a special purpose computer, a computer network, or other programmable apparatus. The computer instructions may be stored in or transmitted from one computer-readable storage medium to another, for example, a website, computer, server, or data center via a wired (e.g., coaxial cable, fiber optic, digital subscriber line (digital subscriber line, DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. Computer readable storage media can be any available media that can be accessed by a computer or data storage devices including one or more servers, data centers, etc. that can be integrated with the media. The usable medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a magnetic tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a Solid State Disk (SSD)), or the like.
Although the present application has been described herein in connection with various embodiments, other variations to the disclosed embodiments can be understood and effected by those skilled in the art in practicing the claimed application, from a review of the figures, the disclosure, and the appended claims. In the claims, the word "comprising" does not exclude other elements or steps, and the "a" or "an" does not exclude a plurality. A single processor or other unit may fulfill the functions of several items recited in the claims. The mere fact that certain measures are recited in mutually different dependent claims does not indicate that a combination of these measures cannot be used to advantage.
Although the present application has been described in connection with specific features and embodiments thereof, it will be apparent that various modifications and combinations can be made without departing from the spirit and scope of the application. Accordingly, the specification and drawings are merely exemplary illustrations of the present application as defined in the appended claims and are considered to cover any and all modifications, variations, combinations, or equivalents that fall within the scope of the present application. It will be apparent to those skilled in the art that various modifications and variations can be made in the present application without departing from the spirit or scope of the application. Thus, if such modifications and variations of the present application fall within the scope of the claims and the equivalents thereof, the present application is intended to cover such modifications and variations.

Claims (10)

1. A method for recording thread state, the method being applied to a database system, the database system comprising a first thread, a second thread and a file linked list to be written, the method comprising:
in the running process of the first thread, the first thread records the thread state data of the first thread to the file linked list to be written, and a sub-memory slot of a memory is mounted in the file linked list to be written, wherein one sub-memory slot is used for storing the thread state data of the first thread;
and the second thread writes the thread state data in the file linked list to be written into a data file of a magnetic disk.
2. The method of claim 1, wherein the database system further comprises a free linked list, the free linked list having a sub-memory slot of the memory mounted thereon, the recording the state information of the first thread to the file linked list to be written comprising:
under the condition that the thread state data of the first thread is stored in the sub-memory slot downloaded and mounted in the idle linked list, the sub-memory slot downloaded and mounted in the idle linked list is mounted to a file linked list to be written; wherein, one of the sub-memory slots is used for storing thread state data of one of the first threads.
3. The method of claim 1 or 2, wherein the database system further comprises a temporary linked list, wherein the second thread writing the thread state data in the file linked list to be written to a data file of a disk, comprising:
the second thread mounts the sub-memory slot to the temporary linked list under the condition that the file linked list to be written is monitored to mount the sub-memory slot;
and the second thread writes the thread state data in the sub-memory slot downloaded by the temporary linked list into a data file of a disk.
4. The method of claim 3, wherein after the second thread writes the thread state data in the temporary linked list download child memory slot to a data file of a disk, the method further comprises:
and re-mounting the sub memory slot to the idle linked list.
5. The method of any of claims 1-4, wherein the thread state data comprises one or more of a data throughput of the first thread, a start time of the first thread, an end time of the first thread, a number of calls of the first thread, a run length of the first thread.
6. The method of claim 1, wherein the first thread is a plurality of, the linked list of files to be written includes a synchronization lock, and the first thread that acquired the synchronization lock has access to the linked list of files to be written;
in the running process of the first thread, the first thread records the thread state data of the first thread to the file linked list to be written, and the method comprises the following steps:
and under the condition that one first thread acquires the synchronous lock, the first thread records the thread state data of the first thread to the file linked list to be written.
7. The method of any of claims 1-6, wherein the second thread is asynchronous with the first thread.
8. The method of claim 3 or 4, wherein the second thread accesses the linked list of files to be written at a first time interval;
if the sub memory slots exist in the file linked list to be written or the number of the sub memory slots is larger than a first threshold value within the adjacent two access time intervals, after the thread state data in the sub memory slots downloaded by the temporary linked list are written into the data file of the disk, the first time interval is adjusted to be a second time interval; the second time interval is less than the first time interval;
If the sub memory slots do not exist in the file linked list to be written in the adjacent two access time intervals, or the number of the sub memory slots is smaller than a second threshold, after the thread state data in the sub memory slots to be temporarily linked list download are written in the data file of the disk, the first time interval is adjusted to be a third time interval; wherein the third time interval is greater than the first time interval; the first threshold is greater than the second threshold.
9. The method according to any one of claims 1-5, further comprising:
reading a data file of the disk based on a surface loading mode, and acquiring thread state data of the first thread;
and setting search conditions based on the thread state data of the first thread, wherein the search conditions are used for troubleshooting.
10. A computing device, the computing device comprising a memory and a processor; the memory is used for storing program codes; the processor is configured to invoke the program code to perform the method of any of claims 1-9.
CN202311177704.1A 2023-09-11 2023-09-11 Thread state recording method and computing device Pending CN117370129A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311177704.1A CN117370129A (en) 2023-09-11 2023-09-11 Thread state recording method and computing device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311177704.1A CN117370129A (en) 2023-09-11 2023-09-11 Thread state recording method and computing device

Publications (1)

Publication Number Publication Date
CN117370129A true CN117370129A (en) 2024-01-09

Family

ID=89404968

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311177704.1A Pending CN117370129A (en) 2023-09-11 2023-09-11 Thread state recording method and computing device

Country Status (1)

Country Link
CN (1) CN117370129A (en)

Similar Documents

Publication Publication Date Title
US11099937B2 (en) Implementing clone snapshots in a distributed storage system
US7328213B2 (en) Transaction processing method, transaction control apparatus and program thereof
CN108509462B (en) Method and device for synchronizing activity transaction table
CN110807062B (en) Data synchronization method and device and database host
CN114064414A (en) High-availability cluster state monitoring method and system
CN109885642B (en) Hierarchical storage method and device for full-text retrieval
CN114528255A (en) Metadata management method, electronic device and computer program product
CN109697112B (en) Distributed intensive one-stop operating system and implementation method
CN113438275B (en) Data migration method and device, storage medium and data migration equipment
CN113342554B (en) IO multiplexing method, medium, device and operating system
CN111488323A (en) Data processing method and device and electronic equipment
CN110888769B (en) Data processing method and computer equipment
US20070174836A1 (en) System for controlling computer and method therefor
CN110413689B (en) Multi-node data synchronization method and device for memory database
JPH11143779A (en) Paging processing system for virtual storage device
CN117370129A (en) Thread state recording method and computing device
CN113342511A (en) Distributed task management system and method
CN113986981A (en) Data synchronization method and device
CN112711606A (en) Database access method and device, computer equipment and storage medium
CN114116790A (en) Data processing method and device
US10474532B1 (en) Automatic fault tolerance in a computing system providing concurrent access to shared computing resource objects
CN115576969B (en) Method, device, medium and equipment for executing database tasks in parallel
US20210406067A1 (en) Distributed storage method, electronic apparatus and non-transitory computer-readable storage medium
CN113342853B (en) Streaming data processing method and system
CN115017128B (en) Lightweight log service design method and system based on CORBA middleware

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination