Skip to content

add some logging and fix a small bug - #22639

Merged
XuPeng-SH merged 6 commits into
matrixorigin:3.0-devfrom
XuPeng-SH:update-for-misc
Oct 20, 2025
Merged

XuPeng-SH merged 6 commits into
matrixorigin:3.0-devfrom
XuPeng-SH:update-for-misc

Conversation

@XuPeng-SH

@XuPeng-SH XuPeng-SH commented Oct 20, 2025 •

Copy link
Copy Markdown
Contributor

User description

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

issue #22638

What this PR does / why we need it:

add some logging and fix a small bug


PR Type

Bug fix, Enhancement


Description

  • Improved logging in stopReceiver with time-based intervals

  • Fixed typo: histroyRetention to historyRetention

  • Corrected error type: NewNotFoundNoCtx() to NewTxnNotFoundNoCtx()

  • Enhanced DB open process with detailed phase logging

  • Added error handling in prepareAObjSortedData to prevent resource leaks

  • Removed unused variables and debug code


Diagram Walkthrough

flowchart LR
  A["Bug Fixes"] --> B["Typo corrections"]
  A --> C["Error type fix"]
  A --> D["Resource leak prevention"]
  E["Logging Enhancements"] --> F["Time-based log intervals"]
  E --> G["Phase-based DB open logging"]
  H["Code Cleanup"] --> I["Remove unused variables"]
  H --> J["Remove debug code"]
Loading

File Walkthrough

Relevant files
Enhancement
controller.go
Improve logging and remove unused variables                           

pkg/vm/engine/tae/db/controller.go

  • Improved logging in stopReceiver with time-based intervals instead of
    modulo-based
  • Changed sleep duration from 1ms to 20ms for better performance
  • Simplified log message formatting
  • Removed unused errMsg variable from AssembleDB function
+5/-9     
open.go
Add comprehensive phase logging to DB open                             

pkg/vm/engine/tae/db/open.go

  • Added detailed phase-based logging for DB open process (start, WAL
    open, catalog open, end)
  • Simplified final log output by removing redundant fields
  • Removed TODO comment and debug code
  • Added error logging during catalog open phase
+10/-9   
Bug fix
db.go
Fix typos and improve variable naming                                       

pkg/vm/engine/tae/db/db.go

  • Fixed typo: histroyRetention to historyRetention in parameter and
    usage
  • Renamed variable forceICKPDuration to forceFlushDuration for clarity
  • Updated log field name to match corrected variable name
+6/-6     
replay.go
Fix error handling order in replay                                             

pkg/vm/engine/tae/db/replay.go

  • Moved error check before type assertion to prevent panic on nil
  • Added TODO comment explaining onSuccess behavior with errors
+4/-2     
flushTableTail.go
Add resource cleanup on error                                                       

pkg/vm/engine/tae/tables/jobs/flushTableTail.go

  • Added defer block to close batch and prevent resource leaks on error
  • Ensures proper cleanup of containers.Batch when error occurs
+7/-0     
Code cleanup
scheduler.go
Remove commented-out code                                                               

pkg/vm/engine/tae/db/scheduler.go

  • Removed commented-out code for GCTask condition
+0/-1     

@qodo-code-review

qodo-code-review Bot commented Oct 20, 2025 •

Copy link
Copy Markdown

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
🟢
No security concerns identified No security vulnerabilities detected by AI analysis. Human verification advised for critical code.
Ticket Compliance
⚪
🎫 No ticket provided
- [ ] Create ticket/issue <!-- /create_ticket --create_ticket=true -->

</details></td></tr>
Codebase Duplication Compliance
⚪
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
⚪
No custom compliance provided

Follow the guide to enable custom compliance check.

  • Update
Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

@mergify mergify Bot added the kind/bug Something isn't working label Oct 20, 2025
@qodo-code-review

qodo-code-review Bot commented Oct 20, 2025 •

Copy link
Copy Markdown

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Add panic handling for resource cleanup

In prepareAObjSortedData, add a recover block to the deferred function to ensure
the bat resource is closed even if a panic occurs, preventing a potential
resource leak.

pkg/vm/engine/tae/tables/jobs/flushTableTail.go [480-489]

 // prepareAObjSortedData read the data from appendable blocks, sort them if sort key exists
 func (task *flushTableTailTask) prepareAObjSortedData(
 	ctx context.Context, objIdx int, idxs []int, sortKeyPos int, isTombstone bool,
 ) (bat *containers.Batch, empty bool, err error) {
 	defer func() {
+		if r := recover(); r != nil {
+			if bat != nil {
+				bat.Close()
+			}
+			panic(r)
+		}
 		if err != nil && bat != nil {
 			bat.Close()
 			bat = nil
 		}
 	}()

[To ensure code accuracy, apply this suggestion manually]

Suggestion importance[1-10]: 6

__

Why: The suggestion correctly identifies a potential resource leak if a panic occurs and provides a robust solution using recover to ensure the resource is always cleaned up.

Low
  • Update

@XuPeng-SH
XuPeng-SH merged commit 4fc605c into matrixorigin:3.0-dev Oct 20, 2025
XuPeng-SH added a commit to XuPeng-SH/matrixone that referenced this pull request Oct 20, 2025
### **User description**
## What type of PR is this?

- [ ] API-change
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

issue matrixorigin#22638 

## What this PR does / why we need it:

add some logging and fix a small bug


___

### **PR Type**
Bug fix, Enhancement


___

### **Description**
- Improved logging in stopReceiver with time-based intervals

- Fixed typo: `histroyRetention` to `historyRetention`

- Corrected error type: `NewNotFoundNoCtx()` to `NewTxnNotFoundNoCtx()`

- Enhanced DB open process with detailed phase logging

- Added error handling in prepareAObjSortedData to prevent resource
leaks

- Removed unused variables and debug code


___

### Diagram Walkthrough


```mermaid
flowchart LR
  A["Bug Fixes"] --> B["Typo corrections"]
  A --> C["Error type fix"]
  A --> D["Resource leak prevention"]
  E["Logging Enhancements"] --> F["Time-based log intervals"]
  E --> G["Phase-based DB open logging"]
  H["Code Cleanup"] --> I["Remove unused variables"]
  H --> J["Remove debug code"]
```



<details> <summary><h3> File Walkthrough</h3></summary>

<table><thead><tr><th></th><th align="left">Relevant
files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>controller.go</strong><dd><code>Improve logging and
remove unused variables</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

pkg/vm/engine/tae/db/controller.go

<ul><li>Improved logging in <code>stopReceiver</code> with time-based
intervals instead of <br>modulo-based<br> <li> Changed sleep duration
from 1ms to 20ms for better performance<br> <li> Simplified log message
formatting<br> <li> Removed unused <code>errMsg</code> variable from
<code>AssembleDB</code> function</ul>


</details>


  </td>
<td><a
href="https://github.com/matrixorigin/matrixone/pull/22639/files#diff-d628bae620ca91ce3a3f310a6245d7064c8b53a86d1ee5d183a273358b023719">+5/-9</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
  <td>
    <details>
<summary><strong>open.go</strong><dd><code>Add comprehensive phase
logging to DB open</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
</dd></summary>
<hr>

pkg/vm/engine/tae/db/open.go

<ul><li>Added detailed phase-based logging for DB open process (start,
WAL <br>open, catalog open, end)<br> <li> Simplified final log output by
removing redundant fields<br> <li> Removed TODO comment and debug
code<br> <li> Added error logging during catalog open phase</ul>


</details>


  </td>
<td><a
href="https://github.com/matrixorigin/matrixone/pull/22639/files#diff-70f750e6241afa9a68b84ae68293c78c247640ee87b5225c5d3b7265ca531797">+10/-9</a>&nbsp;
&nbsp; </td>

</tr>
</table></td></tr><tr><td><strong>Bug fix</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>db.go</strong><dd><code>Fix typos and improve variable
naming</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; </dd></summary>
<hr>

pkg/vm/engine/tae/db/db.go

<ul><li>Fixed typo: <code>histroyRetention</code> to
<code>historyRetention</code> in parameter and <br>usage<br> <li>
Renamed variable <code>forceICKPDuration</code> to
<code>forceFlushDuration</code> for clarity<br> <li> Updated log field
name to match corrected variable name</ul>


</details>


  </td>
<td><a
href="https://github.com/matrixorigin/matrixone/pull/22639/files#diff-dc613bd920e611e7549691db0f4ea362f198d8e79f02892e1b48519b924c73cb">+6/-6</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
  <td>
    <details>
<summary><strong>replay.go</strong><dd><code>Fix error handling order in
replay</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

pkg/vm/engine/tae/db/replay.go

<ul><li>Moved error check before type assertion to prevent panic on
nil<br> <li> Added TODO comment explaining onSuccess behavior with
errors</ul>


</details>


  </td>
<td><a
href="https://github.com/matrixorigin/matrixone/pull/22639/files#diff-1b624eda15c6fe088d89177b50c04263f846872b22e1c8bcd9a82958b3e5d578">+4/-2</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
  <td>
    <details>
<summary><strong>flushTableTail.go</strong><dd><code>Add resource
cleanup on error</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; </dd></summary>
<hr>

pkg/vm/engine/tae/tables/jobs/flushTableTail.go

<ul><li>Added defer block to close batch and prevent resource leaks on
error<br> <li> Ensures proper cleanup of containers.Batch when error
occurs</ul>


</details>


  </td>
<td><a
href="https://github.com/matrixorigin/matrixone/pull/22639/files#diff-0b958d0044e734c5cb32254c0e45c0beaf0e4fdc1f4c846c0bde0fd917da63b0">+7/-0</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>
</table></td></tr><tr><td><strong>Code cleanup</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>scheduler.go</strong><dd><code>Remove commented-out
code</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

pkg/vm/engine/tae/db/scheduler.go

- Removed commented-out code for GCTask condition


</details>


  </td>
<td><a
href="https://github.com/matrixorigin/matrixone/pull/22639/files#diff-5685ec4e51b108a55b7c30b854835395c7b23eeb26a3c51bd9cedd8ce0631da5">+0/-1</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>
</table></td></tr></tr></tbody></table>

</details>

___
@XuPeng-SH
XuPeng-SH deleted the update-for-misc branch July 4, 2026 19:49

This branch was previously deployed

1 inactive deployment
ci — 7e3f9c29 Deployed Oct 20, 2025 by XuPeng-SH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working Review effort 2/5 size/S Denotes a PR that changes [10,99] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants