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

feat: Add permanently delete #1207

Merged
merged 4 commits into from
Dec 25, 2024
Merged

Conversation

sy-records
Copy link
Member

close #1205

@LinkinStars LinkinStars self-requested a review December 19, 2024 02:44
@LinkinStars
Copy link
Member

Thanks for your contributions.

This feat we need more time to test. For example, I tried permanently deleting users, without deleting content. It can lead to some unpredictable panic.

ERROR   runtime/panic.go:785    http: panic serving 127.0.0.1:60872: runtime error: invalid memory address or nil pointer dereference

/incubator-answer/internal/service/question_common/question.go:451 +0xb88
github.com/apache/incubator-answer/internal/service/content.(*QuestionService).GetQuestionPage(0x14004ebdb00, {0x1066f3af0, 0x14008140a00}, 0x14007003698)

It turns out that some Operator and Revision queries may need to add some checks for permanently deleted users.

@sy-records sy-records marked this pull request as draft December 19, 2024 09:41
@sy-records sy-records force-pushed the feat/delete_permanently branch from cf6b991 to 543ea7e Compare December 19, 2024 10:38
@sy-records
Copy link
Member Author

@LinkinStars I have now added delete content after deleting users.

Do we still need to delete Operator and Revision?

@LinkinStars
Copy link
Member

@LinkinStars I have now added delete content after deleting users.

Do we still need to delete Operator and Revision?

image

If an administrator deletes a user by checking the box to also delete the content, then the related questions and answers should be deleted. If the administrator does not check this option, the related content will be retained.

@sy-records sy-records force-pushed the feat/delete_permanently branch from 543ea7e to 37aa075 Compare December 19, 2024 11:08
@sy-records sy-records force-pushed the feat/delete_permanently branch from 764e1c9 to 4aa27d5 Compare December 20, 2024 03:05
@sy-records sy-records marked this pull request as ready for review December 20, 2024 03:07
@LinkinStars LinkinStars self-assigned this Dec 24, 2024
@LinkinStars
Copy link
Member

We are almost done. We have tested various scenarios of what might happen. So far, only the following two locations are potentially problematic.

Add default Operator

image

 runtime/panic.go:785    http: panic serving 127.0.0.1:57957: runtime error: invalid memory address or nil pointer dereference
goroutine 39 [running]:
net/http.(*conn).serve.func1()
        go/pkg/mod/golang.org/[email protected]/src/net/http/server.go:1947 +0x118
panic({0x107a03860?, 0x108dd5e50?})
        go/pkg/mod/golang.org/[email protected]/src/runtime/panic.go:785 +0xf0
github.com/apache/incubator-answer/internal/service/question_common.(*QuestionCommon).FormatQuestionsPage

We can try to add a default operator to solve it.

Operator:         &schema.QuestionPageRespOperator{ID: questionInfo.UserID},

Checking the ActivityUser

http: panic serving 127.0.0.1:58701: runtime error: invalid memory address or nil pointer dereference
goroutine 777 [running]:
net/http.(*conn).serve.func1()
        go/pkg/mod/golang.org/[email protected]/src/net/http/server.go:1947 +0xb0
panic({0x102990920?, 0x103d85cb0?})
        go/pkg/mod/golang.org/[email protected]/src/runtime/panic.go:785 +0x124
github.com/apache/incubator-answer/internal/repo/activity.(*VoteRepo).setActivityRankToZeroIfUserReachLimit(
incubator-answer/internal/repo/activity/vote_repo.go:256 

for _, activity := range op.Activities {

Maybe we can add a checking here, such like

for _, activity := range op.Activities {
		if userInfoMapping[activity.ActivityUserID] == nil {
			continue
		}

@sy-records
Copy link
Member Author

@LinkinStars Thank you for testing! ❤️

@shuashuai shuashuai merged commit 8183291 into apache:dev Dec 25, 2024
@sy-records sy-records deleted the feat/delete_permanently branch December 25, 2024 07:57
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.

3 participants