Method, device and equipment for generating diagnostic report based on multi-node session and medium
Patent Information
- Application Number
- CN202611121055.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-27
- Publication Date
- 2026-10-30
AI Technical Summary
[0005]本发明的主要目的在于提供一种基于多节点会话的诊断报告生成方法、装置、设备及存储介质,旨在解决现有技术难以将分散于多个分布式节点且持续变化的活跃会话数据形成完整、连续的集群级诊断结果的技术问题
[0010]有益效果:本发明涉及分布式数据库运行监控技术领域,公开了一种基于多节点会话的诊断报告生成方法、装置、设备及介质,包括:在多个分布式节点中分别建立内存缓存区,对活跃会话进行采样并存储活跃会话采样数据;当内存缓存区满足预设持久化触发条件时,将活跃会话采样数据写入会话持久化文件;接收报告生成请求,确定数据提取参数、诊断处理参数和报告生成参数,生成报告任务数据;基于数据提取参数提取并聚合活跃会话采样数据,生成聚合会话数据;基于诊断处理参数生成会话诊断统计数据,并基于报告生成参数生成可视化诊断报告。本发明通过对多个分布式节点中的活跃会话进行采样和分层留存,并对多节点活跃会话采样数据进行聚合、诊断和可视化处理,使分散的节点级会话数据形成集群级诊断结果,从而提高分布式数据库会话异常定位的完整性和处理效率。
Smart Images

Figure CN123011988A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of distributed database operation monitoring technology, and in particular to a method, apparatus, device and medium for generating diagnostic reports based on multi-node sessions. Background Technology
[0002] In the production and operation of distributed databases, compute nodes and data nodes are typically deployed in a distributed manner, with each node handling different connection requests, transaction tasks, and statement execution tasks. Information such as the execution status, waiting status, execution events, and blocking relationships of active sessions continuously changes as the database operates and is stored in the corresponding nodes. Existing database monitoring methods primarily rely on single-node queries or basic operational metric monitoring, making it difficult to continuously obtain active session information from multiple distributed nodes within a unified timeframe.
[0003] Because active session data is scattered across different nodes, and some session states only exist for a short period of time, data that is not saved in a timely manner is easily lost as session states change. Existing technologies lack a unified session data retention mechanism for multiple distributed nodes, making it difficult to uniformly extract and aggregate short-term session data within a node with historical session data that has already been retained. This results in active session records generated by different nodes at different times failing to form continuous and complete cluster-level session data.
[0004] When statement execution exceptions, session blocking, or database load changes occur, operations and maintenance personnel typically need to query multiple nodes separately and manually organize the session records across different nodes. Due to the lack of complete cross-node active session data, existing technologies struggle to provide a unified diagnosis of session activity and generate intuitive diagnostic results, making it difficult to promptly identify session anomalies in the distributed database and their corresponding causes. Summary of the Invention
[0005] The main objective of this invention is to provide a method, apparatus, device, and storage medium for generating diagnostic reports based on multi-node sessions, aiming to solve the technical problem that existing technologies struggle to form complete and continuous cluster-level diagnostic results from active session data that is scattered across multiple distributed nodes and is constantly changing.
[0006] To achieve the above objectives, the present invention provides a diagnostic report generation method based on multi-node sessions, comprising: Memory caches are established in multiple distributed nodes, active sessions in each distributed node are sampled to generate active session sampling data, and the active session sampling data is stored in the corresponding memory cache. When the memory cache meets the preset persistence trigger condition, the active session sampling data in the memory cache is written to the corresponding session persistence file; Receive a report generation request, determine data extraction parameters, diagnostic processing parameters, and report generation parameters based on the report generation request, and generate report task data including the data extraction parameters, the diagnostic processing parameters, and the report generation parameters; Based on the data extraction parameters in the report task data, active session sampling data is extracted and aggregated from the memory cache and the session persistence file to generate aggregated session data. Based on the diagnostic processing parameters in the report task data, multi-dimensional diagnostic processing is performed on the aggregated session data to generate session diagnostic statistics. A visual diagnostic report is generated based on the report generation parameters in the report task data and the session diagnostic statistics.
[0007] Furthermore, to achieve the above objectives, the present invention provides a diagnostic report generation apparatus based on multi-node sessions, comprising: The session sampling cache module is used to establish memory caches in multiple distributed nodes, sample active sessions in each distributed node, generate active session sampling data, and store the active session sampling data in the corresponding memory cache. The session data persistence module is used to write the active session sampling data in the memory cache to the corresponding session persistence file when the memory cache meets the preset persistence trigger conditions. The report task generation module is used to receive a report generation request, determine data extraction parameters, diagnostic processing parameters, and report generation parameters based on the report generation request, and generate report task data including the data extraction parameters, the diagnostic processing parameters, and the report generation parameters; The session data aggregation module is used to extract and aggregate active session sampling data from the memory cache and the session persistence file based on the data extraction parameters in the report task data, and generate aggregated session data. The session diagnosis processing module is used to perform multi-dimensional diagnostic processing on the aggregated session data based on the diagnostic processing parameters in the report task data, and generate session diagnosis statistics. The diagnostic report generation module is used to generate a visual diagnostic report based on the report generation parameters in the report task data and the session diagnostic statistics.
[0008] Furthermore, to achieve the above objectives, the present invention also provides a computer device, the computer device including a memory, a processor, and a diagnostic report generation program based on a multi-node session stored in the memory and executable on the processor, wherein when the diagnostic report generation program based on a multi-node session is executed by the processor, it implements the steps of the diagnostic report generation method based on a multi-node session as described above.
[0009] Furthermore, to achieve the above objectives, the present invention also provides a computer-readable storage medium storing a diagnostic report generation program based on a multi-node session, wherein when the diagnostic report generation program based on a multi-node session is executed by a processor, it implements the steps of the diagnostic report generation method based on a multi-node session as described above.
[0010] Beneficial Effects: This invention relates to the field of distributed database operation monitoring technology, and discloses a method, apparatus, device, and medium for generating diagnostic reports based on multi-node sessions. The method includes: establishing memory caches in multiple distributed nodes, sampling active sessions, and storing active session sampling data; when the memory caches meet preset persistence trigger conditions, writing the active session sampling data into a session persistence file; receiving a report generation request, determining data extraction parameters, diagnostic processing parameters, and report generation parameters, and generating report task data; extracting and aggregating active session sampling data based on the data extraction parameters to generate aggregated session data; generating session diagnostic statistics based on the diagnostic processing parameters, and generating a visualized diagnostic report based on the report generation parameters. This invention improves the completeness and processing efficiency of distributed database session anomaly localization by sampling and hierarchically retaining active sessions in multiple distributed nodes, and by aggregating, diagnosing, and visualizing multi-node active session sampling data, enabling dispersed node-level session data to form cluster-level diagnostic results. Attached Figure Description
[0011] The present invention will be further described below with reference to the accompanying drawings and embodiments. In the accompanying drawings: Figure 1 This is a schematic diagram of an application environment for a diagnostic report generation method based on multi-node sessions according to an embodiment of the present invention; Figure 2 This is a flowchart illustrating an embodiment of the diagnostic report generation method based on multi-node sessions of the present invention. Figure 3 This is a schematic diagram of the functional modules of a preferred embodiment of the diagnostic report generation device based on multi-node sessions of the present invention; Figure 4 This is a schematic diagram of the structure of a computer device according to an embodiment of the present invention; Figure 5 This is another structural schematic diagram of a computer device according to one embodiment of the present invention. Detailed Implementation
[0012] It should be understood that the specific embodiments described herein are for illustrative purposes only and are not intended to limit the scope of the invention.
[0013] The diagnostic report generation method based on multi-node sessions provided in this invention can be applied to, for example... Figure 1 In this application environment, the client communicates with the server via a network. The server can establish memory caches on multiple distributed nodes through the client, sample active sessions, and store the active session sampling data. When the memory cache meets the preset persistence trigger conditions, the active session sampling data is written to the session persistence file. The server receives report generation requests, determines data extraction parameters, diagnostic processing parameters, and report generation parameters, and generates report task data. Based on the data extraction parameters, it extracts and aggregates active session sampling data to generate aggregated session data. Based on the diagnostic processing parameters, it generates session diagnostic statistics, and based on the report generation parameters, it generates a visualized diagnostic report. This invention samples and retains active sessions in multiple distributed nodes, and aggregates, diagnoses, and visualizes the active session sampling data from multiple nodes, enabling dispersed node-level session data to form cluster-level diagnostic results, thereby improving the completeness and efficiency of distributed database session anomaly localization. The client can be, but is not limited to, various personal computers, laptops, smartphones, tablets, and portable wearable devices. The server can be implemented using a standalone server or a server cluster composed of multiple servers. The invention is described in detail below through specific embodiments.
[0014] Please see Figure 2 , Figure 2 This is a flowchart illustrating an embodiment of the diagnostic report generation method based on multi-node sessions provided by the present invention. It should be noted that although a logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than that shown here.
[0015] like Figure 2 As shown, the diagnostic report generation method based on multi-node sessions proposed in this invention includes the following steps: S10, establish memory caches in multiple distributed nodes, sample active sessions in each distributed node, generate active session sampling data, and store the active session sampling data in the corresponding memory cache. In this embodiment, each distributed node establishes an independent memory cache based on its node identifier, and records the correspondence between the node identifier, cache address, cache capacity, and current write position, so that data generated by different nodes is written to their respective local spaces. The memory cache can be a contiguous memory area, a circular queue, or a segmented queue, and the cache capacity can be configured based on the node's available memory, the number of active sessions, and the sampling frequency.
[0016] Sampling can be triggered by a fixed period or a session state change event. After each trigger, sessions in the execution or waiting state are filtered from the session state records maintained by the node, excluding sessions that have ended or are idle. For the filtering results, the node identifier, session identifier, sampling time, and current session state are recorded. Statement summaries, execution events, or execution stages can also be recorded and combined into active session sampling data according to a unified field structure.
[0017] When writing active session sample data, the corresponding memory cache is located based on the node identifier, and the data is written in the order of sampling time. The current write position and cache data volume are then updated. When using a circular queue, the write position moves sequentially along the queue; when using a segmented queue, data from the same sampling batch is written to the same cache segment, thus maintaining consistency in node affiliation and time order.
[0018] When the number of node sessions does not change significantly, a fixed sampling period and a circular buffer are used for data collection. Each node is pre-allocated a circular buffer of fixed capacity. The sampling thread reads the session status according to the set period, combines sessions in the running or waiting state into active session sampling data, and writes them into the circular buffer sequentially according to the sampling time.
[0019] When node load fluctuates significantly, a dynamic sampling period and segmented buffers are used for data collection. The sampling period is shortened and the writable capacity of the current buffer segment is increased when the number of active sessions increases; the sampling period is extended when the number of active sessions decreases. Each sampling batch is written to its corresponding time segment to reduce data write waiting during periods of high concurrency.
[0020] In a database cluster comprising two compute nodes and four data nodes, each node establishes its own local circular buffer. A sampling thread reads the node session state at a set interval, identifying sessions in statement execution or resource waiting states as active sessions and recording their node identifier, session identifier, sampling time, and current state. The resulting active session sampling data is written to the corresponding node's circular buffer according to the sampling time, ensuring that the session states of the six nodes within the same sampling period are preserved.
[0021] This embodiment establishes independent memory caches with clear node correspondences in each distributed node, and records active session states according to sampling trigger conditions. This allows continuously changing session information that is scattered across different nodes to be saved in an orderly manner according to the node and sampling time, thereby reducing the omission of active session states and the mixing of data from different nodes.
[0022] S20, when the memory cache meets the preset persistence trigger condition, the active session sampling data in the memory cache is written to the corresponding session persistence file; In this embodiment, a preset persistence trigger condition is used to determine whether active session sampling data in the memory cache needs to be transferred to non-volatile storage. The trigger condition can be set based on cache occupancy, data dwell time, or the number of sampling records, or it can be triggered when any one of the multiple conditions is met. During the determination process, the current occupancy status of the memory cache, the earliest sampling time, or the number of cached records is read and compared with a pre-configured threshold to avoid continuous growth of the cache space or sampling data being stored in memory for a long time.
[0023] A node-to-node mapping is established between the session persistence file and the memory cache, ensuring that active session sampling data generated by different distributed nodes is written to their respective files. Files can be partitioned based on node identifier, sampling date, or sampling time range, and their paths, writable status, and current write positions are recorded. Before writing, cached data can be organized according to sampling time to form continuous data batches; during the writing process, data batches are appended to the corresponding files, and the write completion position is recorded. Only after a file is successfully written can the corresponding data in the cache be marked as persistent, preventing data loss due to write anomalies.
[0024] When there are many node sessions and the cache is growing rapidly, a cache capacity threshold is used to trigger file writing. Once the cache usage reaches a set percentage, the currently cached active session sampling data is organized into a write batch and written to the corresponding session persistent file based on the node identifier. After writing is complete, the file location and cache status are updated to restore writable space in the cache area.
[0025] In scenarios where the number of node sessions is small but continuous time records need to be retained, a cache duration threshold is used to trigger file writing. The data retention time is determined based on the time difference between the current time and the earliest sampling time in the cache. Once the set duration is reached, the active session sampling data within the corresponding time range is written to a session persistence file divided by date or time period.
[0026] In a database cluster containing multiple compute nodes and data nodes, each node maintains its own local memory cache and session persistence file. When the cache usage of a compute node reaches a preset threshold, the active session sampling data in the cache is organized according to the sampling time and written to the file corresponding to that compute node. When the cache usage of a data node is low but the earliest sampled data has reached the preset dwell time, the data within the corresponding time range is written to the file corresponding to that data node, thereby continuously retaining session sampling records generated by different nodes.
[0027] This embodiment controls the writing of active session sampling data from the memory cache to the session persistence file by setting persistence trigger conditions, and determines the writing location according to the node correspondence. This can limit cache space occupation, extend the storage time of session sampling data, and reduce data loss caused by cache release or node abnormality.
[0028] S30, Receive a report generation request, determine data extraction parameters, diagnostic processing parameters and report generation parameters based on the report generation request, and generate report task data including the data extraction parameters, the diagnostic processing parameters and the report generation parameters; In this embodiment, the report generation request can be submitted through the management interface, a API call, or a preset trigger entry. The receiving end reads the request payload, verifies the field completeness, data type, and value range, and converts different expression formats into a unified data format. If the request lacks necessary content or the field value is invalid, the verification result is returned and the report generation task data is stopped to prevent incomplete requests from continuing to flow.
[0029] Data extraction parameters define the node range, time range, and data source of the data to be processed; diagnostic processing parameters define the diagnostic dimensions, statistical definitions, filtering conditions, and sorting requirements; and report generation parameters define the report structure, content, and output format. These three types of parameters can be directly read from the report generation request or mapped using preset configurations, such as determining the corresponding diagnostic dimensions and report template based on the report type carried in the request. After each type of parameter is determined, the field names and data types are standardized to ensure that the parameter content can be accurately identified.
[0030] The report task data uses structured records to encapsulate data extraction parameters, diagnostic processing parameters, and report generation parameters, and establishes a relationship between these three types of parameters and the same report generation request. Structured records can be key-value objects, serialized data, or task table records, and are written to the task storage area or task queue to ensure consistency in the data range, diagnostic requirements, and report output requirements for the same request.
[0031] When the number of report requests is small and immediate feedback is required, a synchronous parsing method is used to receive report generation requests. After the receiving end completes format validation, it directly reads the request content and determines three types of parameters based on the configuration data. These three types of parameters are then encapsulated into a single report task data entry, and the task generation result is returned.
[0032] In scenarios where report requests are submitted in a concentrated manner, a request queue and asynchronous parsing approach are used to reduce concurrent write conflicts. The receiving end writes the validated requests into the request queue, and the parsing process determines the three types of parameters according to the queue order, and writes the generated report task data into the task storage area respectively, so that the parameter content corresponding to each request is isolated from each other.
[0033] In distributed database operation and maintenance scenarios, the management interface submits a report generation request that includes the target node range, target time range, diagnostic requirements, and report output requirements. After the receiving end completes the request verification, it converts the data range into data extraction parameters, the diagnostic requirements into diagnostic processing parameters, and the output requirements into report generation parameters. The three types of parameters are then combined into the same report task data so that the report request maintains complete parameter associations when switching pages or submitting requests in a batch.
[0034] This embodiment verifies and standardizes the report generation request, and encapsulates the data extraction parameters, diagnostic processing parameters, and report generation parameters into report task data after determining them separately. This ensures that the data range, diagnostic requirements, and output requirements are consistent, reducing task generation failures caused by missing parameters, format differences, or association errors.
[0035] S40, based on the data extraction parameters in the report task data, extract and aggregate active session sampling data from the memory cache and the session persistence file to generate aggregated session data; In this embodiment, data extraction parameters are read from the report task data, and the node range, time range, and reading boundaries of the active session sampling data are limited based on these parameters. Data reading requests are established for each target node, ensuring that each node only returns data that meets the defined range, thus avoiding the inclusion of sampling records from irrelevant nodes or irrelevant time periods in the aggregation scope.
[0036] The memory cache stores active session sampling data that has not yet been transferred to a file, while the session persistence file stores data that has been persisted. For the same target node, both the memory cache and the session persistence file are accessed separately. Records that meet the data extraction parameters are filtered based on the sampling time, and both types of data are converted into a unified field structure. For time ranges spanning both cached and file data, both storage locations are read simultaneously to maintain the temporal continuity of the sampled records.
[0037] The aggregation process organizes the extracted results according to node identifiers and sampling times, merges data from different nodes, and identifies duplicate records based on node identifiers, session identifiers, and sampling times. Duplicate records are retained in one copy, records with inconsistent field formats are converted to a unified format, and sampling times with time zone differences are converted to a unified time base. After merging, deduplication, and time processing, aggregated session data containing active session sampling records from multiple nodes is generated.
[0038] When the query time range is close to the current time, a cache-first reading approach is adopted to reduce the number of file accesses. The memory cache of each target node is accessed based on the data extraction parameters. When the cache covers the entire query time range, active session sampling data in the cache is directly aggregated; when the cache only covers a portion of the query time range, data for the missing time period is supplemented from the session persistence file.
[0039] When querying data over a long timeframe and involving multiple nodes, a parallel segmented reading approach is adopted to shorten data aggregation time. Reading tasks are split according to nodes and time intervals, and corresponding records are read from the memory cache and session persistent files respectively. After the fields of each read result are unified, they are merged according to the sampling time, and duplicate records generated at the intersection of storage locations are deleted.
[0040] In a database cluster containing multiple compute and data nodes, the reporting task data is limited to all nodes within a recent time period. Data for certain time ranges is still stored in the memory caches of each node, while earlier data has been written to the session persistence file. Data is read from each node according to the node range, and sampled records are filtered from two types of storage locations based on the time range. The data returned by each node is converted into a unified structure, arranged according to the sampling time, and duplicate records between cached data and file data are removed, forming aggregated session data covering the target time range and all target nodes.
[0041] This embodiment reads both the memory cache and the session persistence file simultaneously based on data extraction parameters, enabling data that has not yet been persisted to be aggregated with data that has been persisted within the same scope. Through cross-node merging, format unification, and duplicate record deletion, the scattered active session sampling data is transformed into continuous and consistent aggregated session data, thereby reducing data loss or duplication caused by node dispersion and differences in storage location.
[0042] S50, based on the diagnostic processing parameters in the report task data, perform multi-dimensional diagnostic processing on the aggregated session data to generate session diagnostic statistics. In this embodiment, diagnostic processing parameters are read from the report task data, and the data fields, diagnostic dimensions, grouping granularity, time granularity, and result filtering range for analysis are determined based on these parameters. Diagnostic dimensions can be set around session status, execution events, statement activity, node load, time distribution, and session blocking relationships, enabling the same batch of aggregated session data to be statistically analyzed from different attribute perspectives.
[0043] When performing multi-dimensional diagnostic processing on aggregated session data, select the corresponding fields according to each diagnostic dimension, and merge session records with the same field values or with related relationships. For status and event data, the number of sampled records corresponding to each status or event can be counted; for time-based data, the number of sessions and status changes can be summarized according to time intervals; for related data, the waiting or blocking relationships between sessions can be organized according to the correspondence between session identifiers.
[0044] Data from each diagnostic dimension is combined according to a unified structure, retaining the diagnostic dimension identifier, statistical object, statistical value, and time range to generate session diagnostic statistics. When only some dimensions are specified in the diagnostic processing parameters, only data for the corresponding dimensions is generated; when multiple dimensions are specified, the processing results for each dimension are recorded separately to avoid mixing different statistical standards.
[0045] In situations requiring rapid identification of key session activities, a grouped statistical approach is used to diagnose aggregated session data. Sampled records are grouped according to session state, execution event, or statement identifier. The number of records contained in each group is counted, and groups with a larger number of records are retained based on diagnostic processing parameters to form session diagnostic statistics reflecting key session activities.
[0046] When it is necessary to analyze changes in session status over time, a time-segmented approach is used to diagnose aggregated session data. Multiple time intervals are divided according to a set time granularity. The number of active sessions, status distribution, and event distribution within each time interval are statistically analyzed, and then the statistical results for each time interval are arranged chronologically.
[0047] In situations where it is necessary to identify the mutual influence of sessions, a correlation-based approach is used to diagnose aggregated session data. Session correspondences are established based on session identifiers, waiting objects, and blocking sources. Session records with direct or continuous associations are grouped into the same relation set, and the duration and number of sessions involved in each relation set are recorded.
[0048] This embodiment controls the diagnostic dimensions and statistical standards uniformly through diagnostic processing parameters, and groups, divides, and correlates aggregated session data, transforming scattered session records into well-structured session diagnostic statistics. This reduces the workload of manually comparing session records one by one and improves the accuracy of session anomaly identification.
[0049] S60, Generate a visual diagnostic report based on the report generation parameters in the report task data and the session diagnostic statistics.
[0050] In this embodiment, report generation parameters are read from the report task data, and the report format, content sections, data display format, and output format are determined based on these parameters. The report format is used to configure the title, summary information, and the arrangement of each diagnostic section. The data display format is used to determine whether the session diagnostic statistics are displayed in a table, bar chart, line chart, or relationship diagram.
[0051] The system identifies the statistical objects, values, time ranges, and diagnostic dimensions in the session diagnostic statistics, and assigns data from different diagnostic dimensions to corresponding content segments. Quantitative distribution data is converted into ranking tables or bar charts, time-varying data into time-series graphs, and blocking relationship data into hierarchical relationship graphs. After segment population, the system standardizes page size, field names, and display precision according to report generation parameters, and renders each content segment to generate a visual diagnostic report.
[0052] In scenarios where diagnostic results need to be viewed through a browser, a webpage template is used to display session diagnostic statistics. Tables and graphs are generated based on the diagnostic dimensions, these components are written into the corresponding page sections, and the page is rendered according to the webpage output format.
[0053] When a fixed-format document is required, a pagination template is used to organize session diagnostic statistics. The number of table rows, graph size, and pagination positions are adjusted based on the data volume, and time-varying data and statistical ranking data are written to their respective pages to generate a visual diagnostic report with a fixed page structure.
[0054] In scenarios where session waiting increases in a database cluster, event statistics are converted into a ranking table, the number of active sessions in each time interval is converted into a line chart, and the blocking relationships between sessions are converted into a hierarchical relationship diagram. All of these are arranged on the same report page according to the report generation parameters, allowing operations and maintenance personnel to view diagnostic results by combining the quantity distribution, time changes, and blocking relationships.
[0055] This embodiment controls the content organization and display format of session diagnostic statistics through report generation parameters, and converts different diagnostic dimensions into corresponding tables or graphs, so that scattered statistical results can be presented intuitively according to a unified structure, thereby reducing the difficulty of recognizing session diagnostic results.
[0056] In one embodiment, step S10 includes: S101, Obtain node sampling configuration data, the node sampling configuration data including the node identifier, sampling interval and cache capacity of each distributed node; S102, based on the node identifier and the cache capacity, establish a memory cache area in each distributed node, and establish a node cache correspondence between the node identifier and the memory cache area; S103, Based on the sampling interval, determine the sampling trigger time corresponding to each distributed node. When the sampling trigger time is reached, select active sessions in the execution state or waiting state from the session state records of each distributed node to generate an active session set. S104, extract the session identifier, statement digest, execution event, execution stage and blocked session identifier from the active session set, obtain the sampling time, and combine the node identifier, the sampling time, the session identifier, the statement digest, the execution event, the execution stage and the blocked session identifier to generate active session sampling data; S105, based on the node cache correspondence, the active session sampling data is stored in the corresponding memory cache according to the sampling time.
[0057] In this embodiment, node sampling configuration data is used to determine the sampling object, sampling frequency, and cache space for each distributed node. Node sampling configuration data can be read from cluster configuration records, node registration records, or a pre-established sampling configuration table, and the affiliation between configuration items is established according to the node identifier. The node identifier is used to distinguish different distributed nodes and can be a node number, node name, or a combination of information that uniquely identifies the node. The sampling interval is used to limit the time length between two adjacent samples, and the cache capacity is used to limit the amount of data that the corresponding memory cache area can hold, which can be represented by the number of bytes, the number of records, or the number of cache segments.
[0058] Based on node identifiers, independent memory caches are created on each distributed node, and writable space is allocated according to the cache capacity. Memory caches can employ contiguous memory structures, circular queue structures, or segmented queue structures, and record the cache start position, current write position, occupied space, and remaining space. A node cache mapping record records the mapping between node identifiers and memory caches, ensuring that active session sampling data generated by a node is written to the cache space matching the node, preventing data from different nodes from being mixed up.
[0059] A continuous sampling trigger time is generated for each distributed node based on the sampling interval. The sampling trigger time can be determined by the previous sampling time and the sampling interval, or it can be triggered separately by a unified timer according to the node's sampling configuration data. After the sampling trigger time is reached, the session state record maintained by the corresponding distributed node is read. The session state record can include the current session state, statement execution state, waiting state, and session persistence state. Sessions in the execution state or waiting state are filtered based on the state field, and sessions that have ended or are not participating in the current process are excluded, generating a set of active sessions.
[0060] Extract session identifier, statement summary, execution event, execution stage, and blocked session identifier from each active session in the active session set. The session identifier distinguishes different sessions within the same node; the statement summary represents the statement content currently being processed by the session; the execution event indicates the operation the session is currently performing or waiting for; the execution stage indicates the current stage of statement processing; and the blocked session identifier indicates other sessions causing the current session to wait. The sampling time records the time position at which each field was collected, and can be generated using the node's local time or a unified time base.
[0061] The node identifier, sampling time, session identifier, statement summary, execution event, execution stage, and blocked session identifier are combined according to a unified field structure, so that each active session sampling data simultaneously contains node affiliation, time location, session object, and running status information. For sessions without blocking relationships, the blocked session identifier can be set to null; for fields that are temporarily unreadable, the missing status can be recorded, and the remaining valid fields are retained to avoid discarding the entire sampling record due to the missing of a single field.
[0062] Based on the node cache mapping, locate the memory cache area corresponding to the node to which the active session sampling data belongs, and write it according to the sampling time. When using a contiguous memory structure, data can be appended sequentially according to the sampling time; when using a circular queue structure, data can be stored cyclically according to the write position; when using a segmented queue structure, data generated at the same sampling trigger time can be written to the same cache segment. After writing is complete, update the current write position, occupied space, and number of cache records to ensure that the cache state is consistent with the actual stored data.
[0063] This embodiment establishes a memory cache with a clear node correspondence for each distributed node according to the node sampling configuration data, and filters active sessions in the execution or waiting state according to the sampling interval. It can continuously record the session running information of different nodes at each sampling time. By combining the node identifier, sampling time and session status fields into a unified structure and writing them into the corresponding memory cache, it can reduce the mixing of node data and the omission of session status, and make the scattered active session information stored in an orderly manner according to the node and time.
[0064] In one embodiment, step S20 above includes: S201, Obtain persistent configuration data, the persistent configuration data including cache capacity and cache duration threshold; S202, for each memory cache area, determine the current cache usage, and read the earliest sampling time from the active session sampling data in the memory cache area, and determine the cache duration based on the current time and the earliest sampling time; S203, when the current cache usage reaches the cache capacity, or the cache duration reaches the cache duration threshold, it is determined that the memory cache area meets the preset persistence trigger condition; S204, sort the active session sampling data in the memory cache that meets the preset persistence triggering conditions according to the sampling time, generate a set of data to be persisted, and determine the sampling time range according to the earliest sampling time and the latest sampling time in the set of data to be persisted. S205, determine the corresponding session persistence file based on the distributed node corresponding to the memory cache and the sampling time range, and write the set of data to be persisted into the session persistence file; S206, after the data set to be persisted is written, delete the active session sampling data corresponding to the data set to be persisted from the memory cache, and redetermine the current cache usage.
[0065] In this embodiment, persistent configuration data is used to determine the data transfer boundaries of the memory cache. The cache capacity and current cache usage use the same data measurement method, and can be configured according to the number of bytes occupied, the number of stored records, or the number of cache segments. The cache duration threshold is used to limit the maximum time that active session sampling data can remain in memory. Each memory cache can read the same set of persistent configuration data, or it can be configured separately according to the memory resources and data growth rate of the distributed nodes.
[0066] The current cache usage is determined by reading the used space, valid records, or occupied cache segments in the memory cache. The earliest sampling time is read from the active session sample data with the earliest sampling time in the memory cache, and the current time uses the same time base as the sampling time. The cache duration is determined based on the time difference between the current time and the earliest sampling time, so that the cache space usage status and data residence time become the basis for persistence judgment.
[0067] The memory cache is deemed to meet the preset persistence trigger condition when either the current cache usage reaches the cache capacity or the cache duration reaches the cache duration threshold. The capacity condition is suitable for situations where sampled data grows rapidly, while the duration condition is suitable for situations where sampled data grows slowly but has been stored in memory for a long time. This avoids insufficient cache space or long-term data retention due to relying on a single condition.
[0068] Active session sampling data that meets the preset persistence trigger conditions are sorted according to sampling time, so that the data in the same batch has a clear time order, and the sorting results are combined into a set of data to be persisted. The earliest and latest sampling times in the set of data to be persisted are used as time boundaries, and the sampling time range is determined by the two time boundaries. The sampling time range is used to identify the time interval covered by the data written this time.
[0069] The file ownership is determined based on the distributed nodes corresponding to the memory cache, and the session persistence file is determined by combining the sampling time range. Session persistence files can be created separately according to node identifiers and time intervals, or data segments can be set within the node's corresponding file according to the time interval. During the writing process, data is written continuously according to the sorted order of the data set to be persisted, and the write position, the number of records written, and the write completion status are recorded.
[0070] After the persistent data set has been written successfully and the write result is valid, the corresponding active session sampling data is deleted from the memory cache. The deletion range is determined based on the record identifier or sampling time range in the data set to be persisted, avoiding the deletion of data that has not been persisted. After deletion, the remaining data in the memory cache is reread, and the current cache usage is updated to ensure that the cache state is consistent with the actual stored content.
[0071] This embodiment controls the timing of transferring active session sampling data by using both cache capacity and cache duration thresholds, thus balancing cache space usage and data dwell time. By organizing the set of data to be persisted according to the sampling time and determining the session persistence file based on the distributed nodes and sampling time range, the sampling data can be saved in an orderly manner according to nodes and time. By deleting the corresponding cache data and updating the current cache usage after writing is completed, the continuous memory usage can be reduced, and the possibility of missing sampling data due to write anomalies can be lowered.
[0072] In one embodiment, step S30 above includes: S301, Receive a report generation request, and extract the task name, time range, node range, sorting quantity parameter and report type parameter from the report generation request; S302, Generate data extraction parameters based on the time range and the node range; S303, obtain diagnostic configuration data, extract the set of diagnostic dimension identifiers corresponding to the report type parameter from the diagnostic configuration data, and generate diagnostic processing parameters based on the set of diagnostic dimension identifiers and the sorting quantity parameter; S304, Obtain report configuration data, extract the report template identifier and report output format corresponding to the report type parameter from the report configuration data, and generate report generation parameters based on the report type parameter, the report template identifier and the report output format; S305, generate a report task identifier and an initial task status, and combine the task name, the report task identifier, the initial task status, the data extraction parameters, the diagnostic processing parameters, and the report generation parameters to generate report task data.
[0073] In this embodiment, the report generation request can be submitted via an interactive page, API call, or preset trigger entry point, and the request content is carried by structured fields. Upon receiving the request, the system reads the field names, field types, and field values, and validates missing fields, invalid time ranges, invalid node identifiers, and parameters that do not meet the value requirements. The system also converts the date format, node identifier format, and quantity format into a unified form to avoid using different data formats for the same meaning.
[0074] The task name is used to distinguish different report tasks and can be filled in by the requester or generated based on the report type and request time. The time range consists of a start time and an end time, used to limit the time interval covered by the data to be analyzed; the node range consists of one or more node identifiers, used to limit the distributed nodes to be included in the report task; the sorting quantity parameter limits the number of entries retained in the diagnostic statistics; the report type parameter determines the diagnostic content and report structure. All of the above parameters are read from the report generation request and maintain a correlation with the same request.
[0075] Data extraction parameters are formed by combining time range and node range. Structured objects can be used to record time boundaries, node identifier sets, and parameter validity states. During generation, it is verified that the start time is earlier than the end time, and that the node identifiers within the node range match the node information records, thus ensuring that the data extraction parameters have a clearly defined data range.
[0076] Diagnostic configuration data can be stored in configuration tables, configuration files, or configuration storage areas, recording the correspondence between report type parameters and diagnostic dimension identifier sets. Based on the report type parameters, matching configuration items are found, the corresponding diagnostic dimension identifier set is read, and then the diagnostic dimension identifier set is combined with the sorting quantity parameter to form the diagnostic processing parameters. The diagnostic dimension identifier set records the diagnostic categories to be generated, and the sorting quantity parameter records the required number of results for each diagnostic category.
[0077] The report configuration data stores the correspondence between report type parameters, report template identifiers, and report output formats. It searches for matching report configuration items based on the report type parameters, reads the report template identifier and report output format, and combines them with the report type parameters to form the report generation parameters. The report template identifier is used to distinguish different report page structures, and the report output format records the file format or page format used in the generated result.
[0078] The report task identifier is used to uniquely identify this report task. It can be generated by combining a global sequence, time information, and request sequence, or it can be generated using a random identifier. The initial task status records the status after the report task data is generated, and can be set to "created" or "pending execution." The task name, report task identifier, initial task status, data extraction parameters, diagnostic processing parameters, and report generation parameters are written into the same structured record to form the report task data, ensuring a one-to-one correspondence between the data range, diagnostic requirements, and report requirements.
[0079] This embodiment verifies and unifies the time range, node range, sorting quantity parameters, and report type parameters in the report generation request, and generates data extraction parameters, diagnostic processing parameters, and report generation parameters respectively. These parameters are then combined with the task name, report task identifier, and initial task status to form the report task data. This reduces task anomalies caused by missing request fields, inconsistent parameter formats, and incorrect configuration relationships, ensuring that the data range, diagnostic content, and output requirements of the same report task remain accurately correlated.
[0080] In one embodiment, step S40 above includes: S401, Read data extraction parameters from the report task data, and read the time range and node range from the data extraction parameters; S402, determine the target distributed node set from multiple distributed nodes according to the node range, and generate a node data extraction task for each target distributed node in the target distributed node set; S403, For each node data extraction task, active session sampling data is extracted from the memory cache of the corresponding target distributed node and the session persistence file according to the time range, and node session data is generated; S404, Read the node identifier, session identifier and sampling time from the node session data, combine the node identifier, session identifier and sampling time to generate a record identifier, and perform duplicate record deletion processing on the node session data according to the record identifier to generate deduplicated node session data; S405, sort the deduplication node session data according to the sampling time, and merge the deduplication node session data corresponding to different node identifiers to generate aggregated session data.
[0081] In this embodiment, data extraction parameters are read from the report task data, and the time range and node range are parsed. The time range includes the start and end time boundaries of the sampled data, used to limit the active session sampled data to be read; the node range includes one or more node identifiers, used to limit the distributed nodes participating in data aggregation. The time range adopts a time base consistent with the sampling time, and the node range is converted into a set of node identifiers to locate the nodes where the data is located.
[0082] Based on the node identifier set, query the node information of multiple distributed nodes, and add the distributed nodes that match the node range and are accessible to the target distributed node set. For each target distributed node, generate a node data extraction task. The node data extraction task records the node identifier, time range, memory cache access location, and session persistence file access location of the target distributed node, so that the data reading process of different nodes is independent of each other.
[0083] When performing node data extraction tasks, the system reads data from the target distributed node's memory cache and session persistence file according to time ranges. Active session sampling data in the memory cache is filtered based on sampling time, while the session persistence file determines the files to be read based on the sampling time range of the records, and then filters records within that time range. Data obtained from both storage locations retains fields such as node identifier, session identifier, sampling time, statement summary, execution event, execution stage, and blocked session identifier, and is combined into node session data.
[0084] When the query time range covers both the memory cache and the session persistence file, both storage locations may contain the same active session sampling data. Node identifiers are used to distinguish different target distributed nodes, session identifiers are used to distinguish different sessions within the same node, and sampling time is used to distinguish records formed by the same session at different sampling times. Combining node identifiers, session identifiers, and sampling time into a record identifier allows for the identification of records that share the same node affiliation, session object, and sampling time.
[0085] The node session data is traversed based on the record identifier. When multiple records have the same record identifier, one of them is retained, and the remaining duplicate records are deleted to generate deduplicated node session data. The retention of duplicate records can be determined based on the reading order, the completeness of fields, or the validity of data. However, the retained records continue to carry the original node identifier and session status fields to avoid node attribution or session content loss due to the deletion of duplicate records.
[0086] The deduplication node session data is sorted according to the sampling time, restoring the data obtained from different storage locations to a continuous temporal order. When the sampling times are the same, the record order can be determined according to the node identifier and session identifier. After sorting, the deduplication node session data corresponding to different node identifiers are merged into a unified dataset, while retaining the node identifier carried by each record, generating aggregated session data covering the target node range and target time range.
[0087] This embodiment limits the node range and time range by extracting data parameters, and reads the memory cache and session persistence file for each target distributed node. It can aggregate active session sampling data from different nodes and storage locations. By forming record identifiers with node identifiers, session identifiers and sampling time and deleting duplicate records, and then sorting and merging across nodes according to sampling time, it can reduce data duplication caused by overlapping storage ranges and make the aggregated session data maintain clear node affiliation and continuous time order.
[0088] In one embodiment, step S50 above includes: S501, Read diagnostic processing parameters from the report task data, and read diagnostic dimension identifier set and sorting quantity parameter from the diagnostic processing parameters. The diagnostic dimension identifier set includes waiting event dimension identifier, load overview dimension identifier, statement dimension identifier, session dimension identifier, time sequence dimension identifier and blocking relationship dimension identifier. S502, Based on the diagnostic dimension identifier set, extract execution events, statement summaries, session identifiers, execution stages, sampling times, and blocking session identifiers from the aggregated session data to generate a diagnostic field data set; S503, merge the diagnostic field data set according to the execution event, the statement summary and the session identifier respectively, record the number of sampled records corresponding to each merged item, and generate waiting event statistics, statement statistics and session statistics; S504, the diagnostic field data set is divided into multiple time segments according to the sampling time, and the number of active sessions, the distribution of execution events and the distribution of execution stages are counted for each time segment to generate load overview data and time-series activity data; S505, Based on the session identifier and the blocked session identifier, establish blocking relationship data, trace the source session identifier that is not blocked by other sessions along the blocking relationship data, and generate blocking relationship tracing data; S506, sort the waiting event statistics, statement statistics, and session statistics according to the number of sampling records, and truncate them according to the sorting quantity parameter. Combine the truncated waiting event statistics, statement statistics, and session statistics with the load overview data, the timing activity data, and the blocking relationship tracing data to generate session diagnostic statistics.
[0089] In this embodiment, diagnostic processing parameters are read from the report task data, the diagnostic dimension identifier set is parsed into the data statistical categories to be executed, and the sorting quantity parameter is read as the retention quantity of the statistical results. The wait event dimension identifier is used to select the execution event field, the load overview dimension identifier is used to select the sampling time, execution event, and execution stage fields, the statement dimension identifier is used to select the statement summary field, the session dimension identifier is used to select the session identifier field, the time sequence dimension identifier is used to select the sampling time field, and the blocking relationship dimension identifier is used to select the session identifier and blocked session identifier fields.
[0090] Based on the diagnostic dimension identifier set, execution events, statement summaries, session identifiers, execution phases, sampling times, and blocked session identifiers are read from each sampled record of the aggregated session data, and then formed into a diagnostic field data set according to a unified field order. Execution events record the operations that the session is performing or waiting for at the sampling time; when in a waiting state, it can indicate a specific waiting event. Statement summaries are used to merge statements with identical content. Session identifiers are used to distinguish different sessions. Execution phases indicate the current processing phase of a statement. Sampling times are used to determine the time position of the record. Blocked session identifiers indicate the session that caused the current session to wait.
[0091] The diagnostic field data set is merged according to execution events, grouping sampled records with the same execution event into the same merge item, and counting the number of sampled records contained in each merge item to form wait event statistics. Merging is also performed according to statement summaries, counting the number of sampled records for each statement summary appearing within the target time range to form statement statistics. Finally, merging is performed according to session identifiers, counting the number of records for each session appearing at different sampling times to form session statistics. With a consistent sampling interval, the number of sampled records can reflect the degree to which execution events, statements, or sessions persist.
[0092] The diagnostic field data set is divided into multiple time segments based on sampling time. Time segments can use equal-length intervals, with each sampled record falling into the corresponding interval based on its sampling time. For each time segment, duplicate session identifiers appearing repeatedly at the same sampling time are deduplicated to determine the number of active sessions. Sampled records are then merged according to execution events and execution phases to determine the distribution of execution events and execution phases. The number and distribution results of active sessions in each time segment are combined to form load profile data, which is then arranged chronologically to form time-series activity data.
[0093] For sampled records containing blocking session identifiers, the session identifier is treated as the blocked session, and the blocking session identifier is treated as the session causing the blocking, establishing a directed blocking relationship between them. When the same session pair appears repeatedly at multiple sampling times, they can be merged into the same blocking relationship, retaining the occurrence count and sampling time. The upstream session is searched level by level along the blocking session identifier until a session identifier not blocked by other sessions is found, and the corresponding session identifier is determined as the source session identifier. During the tracing process, the already accessed session identifiers are recorded; the search stops when a duplicate session identifier is found to avoid repeated tracing caused by cyclic blocking relationships. The blocking relationships, tracing order, and source session identifiers are combined to form the blocking relationship tracing data.
[0094] Waiting event statistics, statement statistics, and session statistics are sorted from most to least by the number of sampled records, and a specified number of merged items are retained according to the sorting quantity parameter. The sorting quantity parameter applies to each of the three types of statistics to avoid different diagnostic dimensions sharing the same retention quota. The truncated waiting event statistics, statement statistics, and session statistics are combined with load overview data, time-series activity data, and blocking relationship tracing data according to the diagnostic dimension identifier to form session diagnostic statistics, retaining the statistical objects, number of sampled records, time range, and relationship information for each type of data.
[0095] This embodiment selects diagnostic fields from aggregated session data by identifying a set of diagnostic dimensions, and performs merging statistics from directions such as execution events, statements, sessions, time distribution, and blocking relationships. This can convert discrete sampled records into data with clear statistical objects and time ranges. By sorting the number of sampled records, performing time segment statistics, and tracing blocking relationships, it can identify continuously occurring waiting events, statements, and sessions, present changes in session activity, and determine the source of blocking, thereby improving the diagnostic completeness and anomaly localization efficiency of multi-node session data.
[0096] In one embodiment, step S60 above includes: S601, Read the report generation parameters from the report task data, and read the report type parameter, report template identifier and report output format from the report generation parameters; S602, retrieve target report template data from the report template library based on the report template identifier, and determine the target report segment set from the target report template data based on the report type parameter; S603, read the task name, report task identifier and data extraction parameters from the report task data, read the time range and node range from the data extraction parameters, and generate basic report data based on the task name, the report task identifier, the time range and the node range; S604, Read the waiting event statistics, load overview data, statement statistics, session statistics, timing activity data and blocking relationship tracing data from the session diagnostic statistics; S605, based on the target report segment set, determine the target report segments corresponding to the waiting event statistics, the load overview data, the statement statistics, the session statistics, the timing activity data, and the blocking relationship tracing data, and write each type of data into the corresponding target report segment to generate report content data; S606, Write the basic report data and the report content data into the target report template data to generate report data to be rendered, and render the report data to be rendered according to the report output format to generate a visual diagnostic report.
[0097] In this embodiment, the report type parameter, report template identifier, and report output format are read from the report generation parameters, and the correspondence between the three is verified. The report type parameter is used to determine the category of diagnostic content that the report needs to include, the report template identifier is used to locate the page structure record in the report template library, and the report output format is used to determine the data organization form after page rendering. The three types of parameters can be stored using structured fields and maintain association with the data of the same report task.
[0098] The report template library is retrieved based on the report template identifier, and the matching target report template data is read. The target report template data may include page layout, section identifiers, section arrangement positions, field placeholder information, and display style information. Based on the report type parameters, sections that need to participate in the generation of this report are selected from the target report template data, forming a set of target report sections. Each target report section is distinguished by a section identifier, and the types of data it can receive and its page position are recorded.
[0099] The task name, report task identifier, and data extraction parameters are read from the report task data. Then, the time range and node range are read from the data extraction parameters. The task name displays the identification information of the report task, the report task identifier distinguishes different report generation tasks, the time range indicates the time interval covered by the diagnostic data, and the node range indicates the distributed nodes involved in the diagnostic data. This information is combined according to the basic report field structure to generate the basic report data.
[0100] The system reads wait event statistics, load overview data, statement statistics, session statistics, time-series activity data, and blocking relationship tracing data from the session diagnostic statistics. Each type of data retains its corresponding statistical object, statistical value, time information, or relationship information, allowing it to be converted into tabular data, sequence data, or relational data according to different display requirements.
[0101] Based on the data categories recorded in the target report segment set, wait event statistics are written to the wait event segment, load overview data to the load overview segment, statement statistics to the statement segment, session statistics to the session segment, time series activity data to the time series segment, and blocking relationship tracing data to the blocking relationship segment. During the writing process, field names, field order, and display precision are organized according to segment field placeholder information, and data exceeding the segment capacity is paginated or partitioned to generate report content data.
[0102] The basic data of the report is filled into the basic information positions in the target report template data, and the report content data is filled into the corresponding target report sections, combining them to form the report data to be rendered. Page rendering reads the page layout, section content and display style according to the report output format, converts the statistical results into displayable page elements, and completes the section arrangement, page pagination and content output to generate a visual diagnostic report.
[0103] This embodiment controls the report content, page structure, and output format through report type parameters, report template identifiers, and report output formats. It writes six types of session diagnostic statistics data into the matching target report sections, which can reduce the correspondence error between statistical data and display positions. By uniformly writing the basic report data and report content data into the target report template data and rendering the page, data from different diagnostic dimensions can be presented in a unified structure, improving the readability and recognition efficiency of diagnostic results.
[0104] In one embodiment, multiple CNs (compute nodes) and DNs (data nodes) are deployed in a GoldenDB (distributed database) cluster. Each node establishes a local ASH (Active Session History) memory cache based on its node identifier, sampling interval, and cache capacity, and establishes a correspondence between the node identifier and the memory cache. Each node determines the sampling trigger time according to the sampling interval. Upon reaching the sampling trigger time, it filters active sessions in the execution or waiting state from the session state record, records the session identifier, SQL (Structured Query Language) summary, execution event, execution stage, sampling time, and blocked session identifier, forming active session sampling data, and writes it into the memory cache of the corresponding node according to the sampling time.
[0105] Each node determines whether the memory cache meets the persistence trigger conditions based on the cache capacity and cache duration threshold. When the cache usage reaches the cache capacity, or the cache duration reaches the cache duration threshold, the active session sampling data in the cache is sorted by sampling time to form a set of data to be persisted, and the sampling time range is determined based on the earliest and latest sampling times. The corresponding session persistence file is determined according to the node identifier and the sampling time range, and the set of data to be persisted is written to the session persistence file. After writing is complete, the corresponding data in the memory cache is deleted, and the cache usage is re-determined.
[0106] When the database experiences session blocking, lock waits, long sessions, or SQL execution exceptions, the DBA (Database Administrator) submits a report generation request through the ASH entry point of Insight (the management platform), configuring the task name, time range, node range, Top N (first few items), and report type. Insight extracts the task name, time range, node range, sorting quantity parameters, and report type parameters from the report generation request. It generates data extraction parameters based on the time range and node range, diagnostic processing parameters based on the report type and sorting quantity parameters, and report generation parameters based on the report type, report template, and report output format. Insight generates a report task identifier and initial task status, combining the task name, report task identifier, initial task status, and the three types of parameters into the report task data.
[0107] Insight determines the target CN and DN based on the node range and generates node data extraction tasks for each target node. For each node data extraction task, active session sampling data within the target time range is extracted from the corresponding node's memory cache and session persistence file via an SQL interface, forming node session data. For records that exist in both the memory cache and session persistence file, the node identifier, session identifier, and sampling time are combined into a record identifier, and duplicate records are deleted based on the record identifier. The deduplicated node session data for each node is sorted by sampling time and then merged to form aggregated session data covering both the target node range and the target time range.
[0108] Insight extracts execution events, statement summaries, session identifiers, execution stages, sampling times, and blocked session identifiers from aggregated session data based on diagnostic processing parameters. It then merges these data according to execution events, statement summaries, and session identifiers, counting the number of sampled records for each merged item to generate wait event statistics, statement statistics, and session statistics. The diagnostic data is divided into multiple time segments based on sampling time, and the number of active sessions, execution event distribution, and execution stage distribution for each time segment are counted to generate load overview data and time-series activity data. A blocking relationship is established based on session identifiers and blocked session identifiers, tracing the source sessions that are not blocked by other sessions along the blocking relationship. The wait event statistics, statement statistics, and session statistics are sorted by the number of sampled records, and the Top N data are truncated and combined with the load overview data, time-series activity data, and blocking relationship tracing data to form session diagnostic statistics.
[0109] Insight reads the target report template based on the report template identifier and determines the report sections according to the report type, including Top Events, Load Profile, Top SQL, Top Sessions, Activity Over Time, and Blocking Relationships. The task name, report task identifier, time range, and node range constitute the basic report data. Various session diagnostic statistics are written into their corresponding report sections to form the report content data. After the basic report data and report content data are written into the target report template, the page is rendered in HTML (Hypertext Markup Language) output format to generate a visually appealing diagnostic report that can be viewed online.
[0110] DBAs can combine lock wait percentages from Top Events, high-frequency statement summaries from Top SQL, long-running active sessions from TopSessions, load changes from Activity Over Time, and source session identifiers from blocking relationships to pinpoint the source sessions and corresponding statements causing lock waits, long sessions, or slow SQL. In centralized Lite architectures or single-DN environments, the node scope is adjusted to the corresponding node, while the remaining sampling, persistence, task generation, data aggregation, diagnostic statistics, and report generation processes remain consistent.
[0111] In one embodiment, a diagnostic report generation apparatus based on multi-node sessions is provided, which corresponds one-to-one with the diagnostic report generation method based on multi-node sessions described in the above embodiments. (Refer to...) Figure 3 , Figure 3 This is a schematic diagram of the functional modules of a preferred embodiment of the diagnostic report generation device based on multi-node sessions of the present invention. The modules include a session sampling cache module 10, a session data persistence module 20, a report task generation module 30, a session data aggregation module 40, a session diagnostic processing module 50, and a diagnostic report generation module 60. Detailed descriptions of each functional module are as follows: The session sampling cache module 10 is used to establish memory cache areas in multiple distributed nodes, sample active sessions in each distributed node, generate active session sampling data, and store the active session sampling data in the corresponding memory cache area. The session data persistence module 20 is used to write the active session sampling data in the memory cache to the corresponding session persistence file when the memory cache meets the preset persistence trigger conditions; The report task generation module 30 is used to receive a report generation request, determine data extraction parameters, diagnostic processing parameters and report generation parameters based on the report generation request, and generate report task data including the data extraction parameters, the diagnostic processing parameters and the report generation parameters; The session data aggregation module 40 is used to extract and aggregate active session sampling data from the memory cache and the session persistence file based on the data extraction parameters in the report task data, and generate aggregated session data. The session diagnosis processing module 50 is used to perform multi-dimensional diagnosis processing on the aggregated session data based on the diagnosis processing parameters in the report task data, and generate session diagnosis statistics. The diagnostic report generation module 60 is used to generate a visual diagnostic report based on the report generation parameters in the report task data and the session diagnostic statistics.
[0112] Specific limitations regarding the diagnostic report generation device based on multi-node sessions can be found in the foregoing limitations on the diagnostic report generation method based on multi-node sessions, and will not be repeated here. Each module in the aforementioned diagnostic report generation device based on multi-node sessions can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device in hardware form, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0113] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 4 As shown, the computer device includes a processor, memory, network interface, and database connected via a system bus. The processor provides determination and control capabilities. The memory includes non-volatile and / or volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The network interface is used to communicate with external clients via a network connection. When the computer program is executed by the processor, it implements the functions or steps of a server-side diagnostic report generation method based on multi-node sessions.
[0114] In one embodiment, a computer device is provided, which may be a client, and its internal structure diagram may be as follows: Figure 5 As shown, the computer device includes a processor, memory, network interface, display screen, and input devices connected via a system bus. The processor provides determination and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The network interface is used to communicate with an external server via a network connection. When executed by the processor, the computer program implements client-side functions or steps of a multi-node session-based diagnostic report generation method.
[0115] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to perform the following steps: Memory caches are established in multiple distributed nodes, active sessions in each distributed node are sampled to generate active session sampling data, and the active session sampling data is stored in the corresponding memory cache. When the memory cache meets the preset persistence trigger condition, the active session sampling data in the memory cache is written to the corresponding session persistence file; Receive a report generation request, determine data extraction parameters, diagnostic processing parameters, and report generation parameters based on the report generation request, and generate report task data including the data extraction parameters, the diagnostic processing parameters, and the report generation parameters; Based on the data extraction parameters in the report task data, active session sampling data is extracted and aggregated from the memory cache and the session persistence file to generate aggregated session data. Based on the diagnostic processing parameters in the report task data, multi-dimensional diagnostic processing is performed on the aggregated session data to generate session diagnostic statistics. A visual diagnostic report is generated based on the report generation parameters in the report task data and the session diagnostic statistics.
[0116] In one embodiment, a computer-readable storage medium is provided, which may be non-volatile or volatile, and a computer program is stored thereon, which, when executed by a processor, performs the following steps: Memory caches are established in multiple distributed nodes, active sessions in each distributed node are sampled to generate active session sampling data, and the active session sampling data is stored in the corresponding memory cache. When the memory cache meets the preset persistence trigger condition, the active session sampling data in the memory cache is written to the corresponding session persistence file; Receive a report generation request, determine data extraction parameters, diagnostic processing parameters, and report generation parameters based on the report generation request, and generate report task data including the data extraction parameters, the diagnostic processing parameters, and the report generation parameters; Based on the data extraction parameters in the report task data, active session sampling data is extracted and aggregated from the memory cache and the session persistence file to generate aggregated session data. Based on the diagnostic processing parameters in the report task data, multi-dimensional diagnostic processing is performed on the aggregated session data to generate session diagnostic statistics. A visual diagnostic report is generated based on the report generation parameters in the report task data and the session diagnostic statistics.
[0117] It should be noted that the functions or steps that can be implemented by the computer-readable storage medium or computer device described above can be referred to the relevant descriptions on the server side and client side in the foregoing method embodiments. To avoid repetition, they will not be described one by one here.
[0118] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), Rambus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0119] It should be noted that if any software tools or components not belonging to this company appear in the embodiments of this application, they are merely illustrative examples and do not represent actual use. The embodiments described above are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included within the protection scope of the present invention.
Claims
1. A method for generating diagnostic reports based on multi-node sessions, characterized in that, Includes the following steps: Memory caches are established in multiple distributed nodes, active sessions in each distributed node are sampled to generate active session sampling data, and the active session sampling data is stored in the corresponding memory cache. When the memory cache meets the preset persistence trigger condition, the active session sampling data in the memory cache is written to the corresponding session persistence file; Receive a report generation request, determine data extraction parameters, diagnostic processing parameters, and report generation parameters based on the report generation request, and generate report task data including the data extraction parameters, the diagnostic processing parameters, and the report generation parameters; Based on the data extraction parameters in the report task data, active session sampling data is extracted and aggregated from the memory cache and the session persistence file to generate aggregated session data. Based on the diagnostic processing parameters in the report task data, multi-dimensional diagnostic processing is performed on the aggregated session data to generate session diagnostic statistics. A visual diagnostic report is generated based on the report generation parameters in the report task data and the session diagnostic statistics.
2. The diagnostic report generation method based on multi-node sessions as described in claim 1, characterized in that, A memory cache is established in multiple distributed nodes, active sessions in each distributed node are sampled to generate active session sampling data, and the active session sampling data is stored in the corresponding memory cache, including: Obtain node sampling configuration data, which includes the node identifier, sampling interval, and cache capacity of each distributed node; Based on the node identifier and the cache capacity, a memory cache area is established in each distributed node, and a node cache correspondence relationship is established between the node identifier and the memory cache area; Based on the sampling interval, the sampling trigger time corresponding to each distributed node is determined. When the sampling trigger time is reached, active sessions in the execution state or waiting state are selected from the session state records of each distributed node to generate an active session set. Extract session identifier, statement digest, execution event, execution stage, and blocked session identifier from the active session set, obtain the sampling time, and combine the node identifier, the sampling time, the session identifier, the statement digest, the execution event, the execution stage, and the blocked session identifier to generate active session sampling data; Based on the node cache correspondence, the active session sampling data is stored in the corresponding memory cache according to the sampling time.
3. The diagnostic report generation method based on multi-node sessions as described in claim 1, characterized in that, When the memory cache meets the preset persistence trigger condition, the active session sampling data in the memory cache is written to the corresponding session persistence file, including: Obtain persistent configuration data, which includes cache capacity and cache duration threshold; For each memory cache area, determine the current cache usage and read the earliest sampling time from the active session sampling data in the memory cache area. Determine the cache duration based on the current time and the earliest sampling time. When the current cache usage reaches the cache capacity, or the cache duration reaches the cache duration threshold, it is determined that the memory cache area meets the preset persistence trigger condition; The active session sampling data in the memory cache that meets the preset persistence trigger conditions are sorted according to the sampling time to generate a set of data to be persisted, and the sampling time range is determined according to the earliest and latest sampling times in the set of data to be persisted. The corresponding session persistence file is determined based on the distributed node corresponding to the memory cache and the sampling time range, and the set of data to be persisted is written into the session persistence file; After the data set to be persisted is written, the active session sampling data corresponding to the data set to be persisted is deleted from the memory cache, and the current cache usage is re-determined.
4. The diagnostic report generation method based on multi-node sessions as described in claim 1, characterized in that, Receive a report generation request, determine data extraction parameters, diagnostic processing parameters, and report generation parameters based on the report generation request, and generate report task data including the data extraction parameters, the diagnostic processing parameters, and the report generation parameters, including: Receive a report generation request, and extract the task name, time range, node range, sorting quantity parameter, and report type parameter from the report generation request; Data extraction parameters are generated based on the time range and the node range; Obtain diagnostic configuration data, extract the set of diagnostic dimension identifiers corresponding to the report type parameter from the diagnostic configuration data, and generate diagnostic processing parameters based on the set of diagnostic dimension identifiers and the sorting quantity parameter; Obtain report configuration data, extract the report template identifier and report output format corresponding to the report type parameter from the report configuration data, and generate report generation parameters based on the report type parameter, the report template identifier and the report output format; Generate a report task identifier and an initial task status, and combine the task name, the report task identifier, the initial task status, the data extraction parameters, the diagnostic processing parameters, and the report generation parameters to generate report task data.
5. The diagnostic report generation method based on multi-node sessions as described in claim 1, characterized in that, Based on the data extraction parameters in the report task data, active session sampling data is extracted and aggregated from the memory cache and the session persistence file to generate aggregated session data, including: Read data extraction parameters from the report task data, and read the time range and node range from the data extraction parameters; Based on the node range, a target distributed node set is determined from multiple distributed nodes, and a node data extraction task is generated for each target distributed node in the target distributed node set; For each node data extraction task, active session sampling data is extracted from the memory cache of the corresponding target distributed node and the session persistence file according to the time range, and node session data is generated. Read the node identifier, session identifier, and sampling time from the node session data, and combine the node identifier, session identifier, and sampling time to generate a record identifier. Based on the record identifier, perform duplicate record deletion processing on the node session data to generate deduplicated node session data. The deduplication node session data is sorted according to the sampling time, and the deduplication node session data corresponding to different node identifiers are merged to generate aggregated session data.
6. The diagnostic report generation method based on multi-node sessions as described in claim 1, characterized in that, Based on the diagnostic processing parameters in the reported task data, multi-dimensional diagnostic processing is performed on the aggregated session data to generate session diagnostic statistics, including: Read diagnostic processing parameters from the report task data, and read the diagnostic dimension identifier set and sorting quantity parameter from the diagnostic processing parameters. The diagnostic dimension identifier set includes wait event dimension identifier, load overview dimension identifier, statement dimension identifier, session dimension identifier, time sequence dimension identifier and blocking relationship dimension identifier. Based on the diagnostic dimension identifier set, execution events, statement summaries, session identifiers, execution stages, sampling times, and blocking session identifiers are extracted from the aggregated session data to generate a diagnostic field data set; The diagnostic field data set is merged according to the execution event, the statement summary and the session identifier, and the number of sampled records corresponding to each merged item is recorded to generate wait event statistics, statement statistics and session statistics. The diagnostic field data set is divided into multiple time segments according to the sampling time. For each time segment, the number of active sessions, the distribution of execution events, and the distribution of execution stages are counted to generate load overview data and time-series activity data. Based on the session identifier and the blocked session identifier, establish blocking relationship data, trace the source session identifier that is not blocked by other sessions along the blocking relationship data, and generate blocking relationship tracing data; The waiting event statistics, statement statistics, and session statistics are sorted according to the number of sampled records, and then truncated according to the sorting quantity parameter. The truncated waiting event statistics, statement statistics, and session statistics are combined with the load overview data, the timing activity data, and the blocking relationship tracing data to generate session diagnostic statistics.
7. The diagnostic report generation method based on multi-node sessions as described in claim 1, characterized in that, A visual diagnostic report is generated based on the report generation parameters in the report task data and the session diagnostic statistics, including: Read the report generation parameters from the report task data, and read the report type parameter, report template identifier, and report output format from the report generation parameters; The target report template data is obtained from the report template library based on the report template identifier, and the target report segment set is determined from the target report template data based on the report type parameter; The task name, report task identifier, and data extraction parameters are read from the report task data. The time range and node range are read from the data extraction parameters. The basic report data is generated based on the task name, the report task identifier, the time range, and the node range. Read wait event statistics, load overview data, statement statistics, session statistics, timing activity data, and blocking relationship tracing data from the session diagnostic statistics. Based on the set of target report segments, the target report segments corresponding to the waiting event statistics, the load overview data, the statement statistics, the session statistics, the timing activity data, and the blocking relationship tracing data are determined respectively, and each type of data is written into the corresponding target report segment to generate report content data; The basic report data and the report content data are written into the target report template data to generate report data to be rendered. The report data to be rendered is then rendered according to the report output format to generate a visual diagnostic report.
8. A diagnostic report generation device based on multi-node sessions, characterized in that, The diagnostic report generation device based on multi-node sessions includes: The session sampling cache module is used to establish memory caches in multiple distributed nodes, sample active sessions in each distributed node, generate active session sampling data, and store the active session sampling data in the corresponding memory cache. The session data persistence module is used to write the active session sampling data in the memory cache to the corresponding session persistence file when the memory cache meets the preset persistence trigger conditions. The report task generation module is used to receive a report generation request, determine data extraction parameters, diagnostic processing parameters, and report generation parameters based on the report generation request, and generate report task data including the data extraction parameters, the diagnostic processing parameters, and the report generation parameters; The session data aggregation module is used to extract and aggregate active session sampling data from the memory cache and the session persistence file based on the data extraction parameters in the report task data, and generate aggregated session data. The session diagnosis processing module is used to perform multi-dimensional diagnostic processing on the aggregated session data based on the diagnostic processing parameters in the report task data, and generate session diagnosis statistics. The diagnostic report generation module is used to generate a visual diagnostic report based on the report generation parameters in the report task data and the session diagnostic statistics.
9. A computer device, characterized in that, The computer device includes a memory, a processor, and a multi-node session-based diagnostic report generation program stored in the memory and executable on the processor. When executed by the processor, the multi-node session-based diagnostic report generation program implements the steps of the multi-node session-based diagnostic report generation method as described in any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, The storage medium stores a diagnostic report generation program based on multi-node sessions, which, when executed by a processor, implements the steps of the diagnostic report generation method based on multi-node sessions as described in any one of claims 1-7.
