Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: deletion script will not OOM #1679

Merged
merged 6 commits into from
Oct 9, 2024

Conversation

PeterChen13579
Copy link
Collaborator

fixes #1676 and #1678

@PeterChen13579 PeterChen13579 marked this pull request as draft October 2, 2024 15:45
Copy link

codecov bot commented Oct 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 70.36%. Comparing base (0282504) to head (4ebd219).
Report is 11 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1679      +/-   ##
===========================================
+ Coverage    69.92%   70.36%   +0.44%     
===========================================
  Files          260      266       +6     
  Lines         9976    10182     +206     
  Branches      5500     5618     +118     
===========================================
+ Hits          6976     7165     +189     
+ Misses        1586     1542      -44     
- Partials      1414     1475      +61     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@PeterChen13579 PeterChen13579 marked this pull request as ready for review October 6, 2024 22:05
Copy link
Collaborator

@cindyyan317 cindyyan317 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic looks good to me.
But the bookmark can be put into a class.
The workerCount seems incorrec. If I understand correctly, the number of goroutine running concurrently is workerCount*workerCount now.

@cindyyan317
Copy link
Collaborator

Maybe we can pack the continue.txt logic all in one class like:

type Marker struct {
	cmd  string
	file *os.File
}

func NewMarker(cmd string) *Marker {
	return &Marker{cmd: cmd}
}

func CloseMarker(m *Marker) {
	if m.file != nil {
		m.file.Close()
	}
	os.Remove("continue.txt")
}

func (m *Marker) EnterTable(table string) error {
	// Create the file
	file, err := os.OpenFile("continue.txt", os.O_WRONLY|os.O_TRUNC, 0644)
	m.file = file
	if err != nil {
		return fmt.Errorf("failed to create file: %w", err)
	}
	fmt.Fprintf(m.file, "%s\n", m.cmd)
	m.file.WriteString(fmt.Sprintf("%s\n", table))
	return nil
}

func (m *Marker) MarkProgress(x int64, y int64) {
	fmt.Fprintf(m.file, "%d, %d \n", x, y)
}

func (m *Marker) ExitTable() {
	m.file.Close()
	m.file = nil
}

Copy link
Collaborator

@cindyyan317 cindyyan317 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks ~ LGTM

@PeterChen13579 PeterChen13579 merged commit 11192c3 into XRPLF:develop Oct 9, 2024
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix Deletion Script OOM
3 participants