Memory Logs
Memory logs record memory context statistics generated when the dynamic memory usage of a database process exceeds the specified threshold, the dynamic memory fluctuation exceeds the specified threshold, or the statistical period reaches the specified value. The GUC parameter memory_trace_level determines whether to record memory logs. By default, level-1 logs are recorded. The GUC parameter memory_log_config is used to set more functions, such as the dynamic memory usage percentage threshold, memory fluctuation percentage threshold, statistical period, number of top memory contexts, and number of top SQL statements.
- An anti-oscillation mechanism is provided for generating memory logs. When the dynamic memory usage exceeds the threshold (specified by the first part of the memory_log_config parameter), the dynamic memory used for generating memory logs is recorded as the trigger memory. If the dynamic memory usage is continuously greater than the trigger memory minus 5% of dynamic memory upper limit, no memory log is generated because the dynamic memory usage exceeds the threshold. This prevents repeated log generation when the dynamic memory usage fluctuates slightly around the threshold.
- The memory context snapshot generation based on the memory fluctuation percentage (set in part 2 of the memory_log_config parameter) is based on a 3-second detection period. If the snapshot generation conditions are met within the 3-second detection period, no memory context snapshot is generated.
- Memory threshold triggering, memory fluctuation triggering, and periodic triggering cannot be performed together.
- Only the memory contexts in the format of {Module name}_{Number} can be combined by module name. If the memory contexts do not meet the requirement, they are not combined. For example, pooler_memory_context, pooler_core_context, and pooler_agent_context are three different memory contexts and are not combined.
Log Storage Directory
The memory logs of the database node are stored in the $GAUSSLOG/mem_log directory.
Log Naming Rules
The name format of database node memory logs is: mem_log-creation time.log
Log Content Description
Detailed usage statistics of the global memory context, session-level memory context, and thread-level memory context of the database process, including the top 20 session-level and thread-level memory usage, corresponding client types, and SQL statements. If parallel logical decoding tasks are running, the log also contains the memory usage information of parallel logical decoding.
Top n memory contexts of each type, top n memory contexts of each query (specified by the fourth part of the memory_log_config parameter), and top n queries (specified by the fifth part of the memory_log_config parameter) are displayed based on the memory usage.
| Column | Description |
|---|---|
| Max_dynamic_memory | Maximum dynamic memory that can be used by the database process. |
| Dynamic_used_memory | Size of the dynamic memory used by the current process. |
| Dynamic_peak_memory | Historical maximum dynamic memory usage of the current process. |
| Dynamic_thread_cxt_used_memory | Size of the memory used by the thread-level memory context of the current process. |
| Dynamic_session_cxt_used_memory | Size of the memory used by the session-level memory context of the current process. This parameter is displayed only when the thread pool is enabled. |
| Dynamic_used_shrctx | Size of the memory occupied by the global memory context of the current process. |
| Dynamic_peak_shrctx | Historical maximum size of the memory occupied by the global memory context of the current process. |
| Max_backend_memory | Maximum memory size requested by the session connected to the HA port. |
| Backend_used_memory | Size of the memory that is being occupied by the session connected to the HA port. |
| other_used_memory | Size of other memory that is not applied for in the memory context. |
| unit | Unit of the memory size at the same level. |
| Context type | Memory context type, including Shared Memory Context, Thread Memory Context, and Session Memory Context. |
| Context | Name of the memory context. Memory contexts with the same name and module name (in the format of {Module name}_{Number}) are displayed together. Only the module name is displayed. |
| freeSize | Size of the idle memory cached in the memory context. |
| totalSize | Total size of the memory requested by the memory context. |
| File | File name of the code where the memory allocation is located. It is recorded only when memory_trace_level is set to level2. |
| Line | File line number of the code where the memory allocation is located. It is recorded only when memory_trace_level is set to level2. |
| Size | Accumulated size of the memory allocated for in a line of a file. It is recorded only when memory_trace_level is set to level2. |
| count | Number of memory contexts with the same name and module name. |
| query | Executed statement. |
| unique query id | Unique ID of a statement. |
| debug query id | Debugging ID of a statement. |
| session id | Session ID. |
| thread id | Thread ID. |
| mem size | Size of the memory allocated by a statement. |
| application name | Application name. |
Log Examples
- When memory_trace_level is set to level1, the following logs are recorded:
{ "Global Memory Statistics": { "Max_dynamic_memory": 34012, "Dynamic_used_memory": 3645, "Dynamic_peak_memory": 3664, "Dynamic_thread_cxt_used_memory": 383, "Dynamic_session_cxt_used_memory": 2582, "Dynamic_used_shrctx": 401, "Dynamic_peak_shrctx": 401, "Max_backend_memory": 648, "Backend_used_memory": 1, "other_used_memory": 0, "unit": "MB" }, "Memory Context Info": { "Memory Context Detail": { "Context Type": "Shared Memory Context", "Memory Context": { "context": "IncreCheckPointContext", "freeSize": 2864, "totalSize": 263066352, "unit": "Byte", "count": 1 }, ... }, "Memory Context Detail": { "Context Type": "Session Memory Context", "Memory Context": { "context": "CachedPlan", "freeSize": 68041368, "totalSize": 235937792, "unit": "Byte", "count": 1 }, ... }, "Memory Context Detail": { "Context Type": "Thread Memory Context", "Memory Context": { "context": "LocalSysCacheShareMemoryContext", "freeSize": 60431360, "totalSize": 644141760, "unit": "Byte", "count": 1 }, ... } "Query Info": { "Query Context": { "query": "select distinct a from t3 order by a;", "unique query id": "2286703632", "debug query id": "1407374883554034", "session id": "2", "thread id": "140188551411456", "mem size": 1, "unit": "MB", "application name": "gsql", "Memory Context Detail": { "Context Type": "Session Memory Context", "Memory Context": { "context": "SessionTopMemoryContext", "freeSize": 97048, "totalSize": 460520, "unit": "Byte", "count": 1 }, ... }, "Query Context": { "query": "WLM fetch collect info from data nodes", "unique query id": "0", "debug query id": "0", "session id": "140186948200192", "thread id": "140186948200192", "mem size": 1, "unit": "MB", "application name": "workload", "Memory Context Detail": { "Context Type": "Thread Memory Context", "Memory Context": { "context": "LocalSysCacheShareMemoryContext", "freeSize": 150720, "totalSize": 1872096, "unit": "Byte", "count": 1 }, ... }, ... }, "parallel logical decode Info": [{ "slot name": "slot1", "memory info": "memory usage: reader toast memory size: 0, sender out buf memory size: 0, [xid, first_lsn, memory, entry num] : NULL" }] } - When memory_trace_level is set to level2, the following logs are recorded:
{ "Global Memory Statistics": { "Max_dynamic_memory": 34012, "Dynamic_used_memory": 3645, "Dynamic_peak_memory": 3664, "Dynamic_thread_cxt_used_memory": 383, "Dynamic_session_cxt_used_memory": 2582, "Dynamic_used_shrctx": 401, "Dynamic_peak_shrctx": 401, "Max_backend_memory": 648, "Backend_used_memory": 1, "other_used_memory": 0, "unit": "MB" }, "Memory Context Info": { "Memory Context Detail": { "Context Type": "Shared Memory Context", "Memory Context": { "context": "IncreCheckPointContext", "freeSize": 2864, "totalSize": 263066352, "unit": "Byte", "count": 1, "MemoryDetail": { "file":"xxx.cpp", "line":411, "size":211131, } ... }, ... }, "Memory Context Detail": { "Context Type": "Session Memory Context", "Memory Context": { "context": "CachedPlan", "freeSize": 68041368, "totalSize": 235937792, "unit": "Byte", "count": 1, "MemoryDetail": { "file":"xxx.cpp", "line":411, "size":211131, } ... }, ... }, "Memory Context Detail": { "Context Type": "Thread Memory Context", "Memory Context": { "context": "LocalSysCacheShareMemoryContext", "freeSize": 60431360, "totalSize": 644141760, "unit": "Byte", "count": 1, "MemoryDetail": { "file":"xxx.cpp", "line":411, "size":211131, } ... }, ... } "Query Info": { "Query Context": { "query": "select distinct a from t3 order by a;", "unique query id": "2286703632", "debug query id": "1407374883554034", "session id": "2", "thread id": "140188551411456", "mem size": 1, "unit": "MB", "application name": "gsql", "Memory Context Detail": { "Context Type": "Session Memory Context", "Memory Context": { "context": "SessionTopMemoryContext", "freeSize": 97048, "totalSize": 460520, "unit": "Byte", "count": 1, "MemoryDetail": { "file": "xxx.cpp", "line": 461, "size": 62976 }, ... }, ... }, "Query Context": { "query": "WLM fetch collect info from data nodes", "unique query id": "0", "debug query id": "0", "session id": "140186948200192", "thread id": "140186948200192", "mem size": 1, "unit": "MB", "application name": "workload", "Memory Context Detail": { "Context Type": "Thread Memory Context", "Memory Context": { "context": "LocalSysCacheShareMemoryContext", "freeSize": 150720, "totalSize": 1872096, "unit": "Byte", "count": 1, "MemoryDetail": { "file": "xxx.cpp", "line": 352, "size": 40153344 }, ... }, ... }, ... }, "parallel logical decode Info": [{ "slot name": "slot1", "memory info": "memory usage: reader toast memory size: 0, sender out buf memory size: 0, [xid, first_lsn, memory, entry num] : NULL" }] }
Graphical Memory Information (HTML File)
When a .log file in JSON format is generated, a .gz package of the HTML file with the same name is generated in the same directory. Decompress the package, export the HTML file and the echarts.min.js file in the same directory, and use a browser to open the HTML file. You can view the graphical memory information.
The memory information corresponds to the memory log in JSON format and consists of the following parts:
- Global Memory Statistics: displays the ring chart of the proportion of dynamic memory of each category to the maximum dynamic memory.
- Shared Memory Context: displays the memory bar chart of the shared memory context. If the fourth part of the GUC parameter memory_log_config is set to 0, it is not displayed.
- Session Memory Context: displays the memory bar chart of the session memory context. If the fourth part of the GUC parameter memory_log_config is set to 0, or the GUC parameter enable_thread_pool is set to off, it is not displayed.
- Thread Memory Context: displays the memory bar chart of the thread memory context. If the fourth part of the GUC parameter memory_log_config is set to 0, it is not displayed.
- SQL Details: displays the memory information of the executed statement or thread. If the fifth part of the GUC parameter memory_log_config is set to 0, it is not displayed. If there are memory contexts, you can click each statement to display the memory bar chart of the top n memory contexts.
Compared with level1, when the GUC parameter memory_trace_level is set to level2, the memory location and size information about the memory context is displayed. You can click the bar chart of each memory context to display the memory location and size.
The following table describes the columns of the information displayed in each part.
| Column | Description |
|---|---|
| Dynamic used share ctx memory | Size of the dynamic memory used by the current process. |
| Dynamic thread cxt used memory | Size of the memory used by the thread-level memory context of the current process. |
| Dynamic session cxt used memory | Size of the memory used by the session-level memory context of the current process. This parameter is displayed only when the thread pool is enabled. |
| Dynamic unused memory | Size of the memory not used by the current process. |
| Context type | Memory context type, including Shared Memory Context, Thread Memory Context, and Session Memory Context. |
| Context | Name of the memory context. Memory contexts with the same name and module name (in the format of {Module name}_{Number}) are displayed together. Only the module name is displayed. |
| totalSize | Total size of the memory requested by the memory context. |
| File | File name of the code where the memory allocation is located. It is recorded only when memory_trace_level is set to level2. |
| Line | File line number of the code where the memory allocation is located. It is recorded only when memory_trace_level is set to level2. |
| Size | Accumulated size of the memory allocated for in a line of a file. It is recorded only when memory_trace_level is set to level2. |
| query | Executed statement. |
| unique query id | Unique ID of a statement. |
| debug query id | Debugging ID of a statement. |
| session id | Session ID. |
| thread id | Thread ID. |
| mem size | Size of the memory allocated by a statement. |
| application name | Application name. |
What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot