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

If the FlatMode is disabled, the reply will be hidden in the GET /comments #891

Closed
syhily opened this issue May 26, 2024 · 7 comments
Closed

Comments

@syhily
Copy link

syhily commented May 26, 2024

I think the commit introduced this bug.

After commenting the line, everything works as expected.

As I debugging further into the code. I found that when I was using the Postgres or MySQL with Artalk, the RootID will be NULL by default. This will make findNestedChildren method buggy.

@syhily
Copy link
Author

syhily commented May 26, 2024

Ok, I was trying to generate the root_id by enabling the ATK_DB_MIGRATOR_FUNC_MIGRATE_ROOT_ID=1.

@syhily
Copy link
Author

syhily commented May 26, 2024

Ok, I think the force generated Root ID solved my problems.

@syhily syhily closed this as completed May 26, 2024
@qwqcode
Copy link
Member

qwqcode commented May 26, 2024

这个可能是 root_id 没有正确生成导致的问题(相关:#848 #846 #833),可以检查 comments 表中 root_id 列是否全为 0,如果 root_id 不正确可以尝试在 artalk 启动前增加环境变量 ATK_DB_MIGRATOR_FUNC_MIGRATE_ROOT_ID=1 重新生成 root_id。

root_id 是用于缓存评论树叶子节点往上的最顶层根节点 ID,缓存递归查询结果提高性能


This issue may be caused by the incorrect generation of root_id (related: #848 #846 #833). You can check if the root_id column in the comments table is all set to 0. If root_id is incorrect, you can try adding the environment variable ATK_DB_MIGRATOR_FUNC_MIGRATE_ROOT_ID=1 before starting artalk to regenerate root_id.

root_id is used to cache the ID of the top-level root node upwards from the leaf nodes of the comment tree, caching recursive query results to improve performance.

@qwqcode
Copy link
Member

qwqcode commented May 26, 2024

Ok, I think the force generate the Root ID solved my problems.

Alright, I got it. You've solved it already! :)

@syhily
Copy link
Author

syhily commented May 26, 2024

@qwqcode Yep, you are right. After reading your code and debugging locally. I found that it was caused by the missing root id. But I didn't meet the comments loading issue until you have migrated the query logic to root_id in the latest Artalk release.

Given that I can't find any documentation that describes the ATK_DB_MIGRATOR_FUNC_MIGRATE_ROOT_ID and you are working on code refactoring with heavily changed database schema. I sincerely ask if you can add a troubleshooting document to mention these potential regressions.

@qwqcode
Copy link
Member

qwqcode commented May 26, 2024

I'm sorry, you're right. I should have added some documentation to address this issue, but I've been too busy lately. I missed some pre-release testing in v2.8.5 and overlooked the fact that some older databases don't support SQL recursive CTE and not providing a fallback solution. This resulted in root_id not being generated correctly for some users upgrading to v2.8.5. However, this issue should have been fixed in v2.8.6. My intention was to make these changes to the data structure and upgrades seamless and automatic.

@syhily
Copy link
Author

syhily commented May 26, 2024

Haha, I see. I'm not mean to complain. BTW, this regression didn't get resolved in 2.8.6 release if the root_id has been created with NULL. And the start up hangs for a long time for migrating to the new root_id. I think we have better to use a go routine to generate the root_id.

Thanks your great works.

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

No branches or pull requests

2 participants