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

bug(expr): lpad never returns #8949

Closed
xiangjinwu opened this issue Apr 3, 2023 · 3 comments · Fixed by #8970
Closed

bug(expr): lpad never returns #8949

xiangjinwu opened this issue Apr 3, 2023 · 3 comments · Fixed by #8970
Labels
type/bug Something isn't working
Milestone

Comments

@xiangjinwu
Copy link
Contributor

xiangjinwu commented Apr 3, 2023

Describe the bug

No response

To Reproduce

SELECT lpad('hi', 5, '');

Expected behavior

In PostgreSQL:

test=# SELECT lpad('hi', 5, '');
 lpad 
------
 hi
(1 row)

test=# SELECT length(lpad('hi', 5, ''));
 length 
--------
      2
(1 row)

Additional context

found by regress test

@xiangjinwu xiangjinwu added the type/bug Something isn't working label Apr 3, 2023
@github-actions github-actions bot added this to the release-0.19 milestone Apr 3, 2023
@TennyZhuang
Copy link
Contributor

#8767
GPT wrote an infinite loop bug and passed our review 😨

@BugenZhao
Copy link
Member

More severely, constant-folding this expression causes the frontend unable to establish new connections for further requests, since tokio tends to move the IO scheduler to the same worker thread with this session, and an infinite loop starves the IO scheduler so that the main thread listening to the connection cannot be woken again! 😨

Although we should definitely fix this issue, it's also possible that the optimizer becomes more complicated and CPU-intensive. This might be relieved by using a separate runtime for frontend sessions (like #4756), but the stuck is inevitable when worker threads are exhausted (note that CPU-intensive tasks cannot be canceled). Or, we need spawn_blocking or block_in_place in every possible blocking code.

cc @liurenjie1024 @wangrunji0408

@wangrunji0408
Copy link
Contributor

GPT wrote an infinite loop bug and passed our review 😨

This case is not documented so it's not surprising that GPT was not aware of it. 🥲

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants