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]: Segfault after second ANALYZE with PG 14.5/TimescaleDB 2.8.1 #4857
Comments
@kyrias you can try to log all commands executed from your SQLx tool by setting the |
|
@kyrias thanks for all the information. I know what's happening based on your info and stacktrace but I can't reproduce it yet. Can u share a |
The same thing happens with an entirely empty database with only the extension created. I can reproduce it with the following:
|
@fabriziomello Where you able to reproduce it with the above instructions? |
Looks like you are using extended query protocol which psql doesnt support atm |
Hi @kyrias
I enabled log_statement and see this logs:
With timescaledb extension installed i can see a crash, when i run cargo more than once
Thanks for reproducible steps. I will analyse more and try to find out what is the issue. |
Here is the stack trace from core file:
|
Hi @kyrias I would like to understand more about main.rs program. If so can we try synchronous version of the same program ? |
There is no visible parallelism in this program. The database library used is an async library which allows for tasks to run concurrently, but there is also no concurrency in the main function of this program. It connects to the database, executes one query and waits for the result, and then executes another query and waits for the result. |
Ok. Unfortunately i could not reproduce on psql utility which is of much help for me to debug and find the root causes. |
Which is mentioned in the issue description. And as svenklemm mentioned it appears to be due to psql not supporting the extended query protocol.
You can add |
Here is a very simple testcase which can be used to reproduce the issue via psql:
SQL statements in plpgsql have an implicit prepared statement created which i guess used extended query protocol. |
Issue occurs in extended query protocol mode only where every query goes through PREPARE and EXECUTE phase. First time ANALYZE is executed, a list of relations to be vaccumed is extracted and saved in a list. This list is referenced in parsetree node. Once execution of ANALYZE is complete, this list is cleaned up, however reference to the same is not cleaned up in parsetree node. When second time ANALYZE is executed, segfault happens as we access an invalid memory location. Fixed the issue by restoring the actual value in parsetree node once ANALYZE completes its execution. Fixes timescale#4857
Issue occurs in extended query protocol mode only where every query goes through PREPARE and EXECUTE phase. First time ANALYZE is executed, a list of relations to be vaccumed is extracted and saved in a list. This list is referenced in parsetree node. Once execution of ANALYZE is complete, this list is cleaned up, however reference to the same is not cleaned up in parsetree node. When second time ANALYZE is executed, segfault happens as we access an invalid memory location. Fixed the issue by restoring the actual value in parsetree node once ANALYZE completes its execution. Fixes timescale#4857
Issue occurs in extended query protocol mode only where every query goes through PREPARE and EXECUTE phase. First time ANALYZE is executed, a list of relations to be vaccumed is extracted and saved in a list. This list is referenced in parsetree node. Once execution of ANALYZE is complete, this list is cleaned up, however reference to the same is not cleaned up in parsetree node. When second time ANALYZE is executed, segfault happens as we access an invalid memory location. Fixed the issue by restoring the actual value in parsetree node once ANALYZE completes its execution. Fixes timescale#4857
Issue occurs in extended query protocol mode only where every query goes through PREPARE and EXECUTE phase. First time ANALYZE is executed, a list of relations to be vaccumed is extracted and saved in a list. This list is referenced in parsetree node. Once execution of ANALYZE is complete, this list is cleaned up, however reference to the same is not cleaned up in parsetree node. When second time ANALYZE is executed, segfault happens as we access an invalid memory location. Fixed the issue by restoring the actual value in parsetree node once ANALYZE completes its execution. Fixes timescale#4857
Issue occurs in extended query protocol mode only where every query goes through PREPARE and EXECUTE phase. First time ANALYZE is executed, a list of relations to be vaccumed is extracted and saved in a list. This list is referenced in parsetree node. Once execution of ANALYZE is complete, this list is cleaned up, however reference to the same is not cleaned up in parsetree node. When second time ANALYZE is executed, segfault happens as we access an invalid memory location. Fixed the issue by restoring the actual value in parsetree node once ANALYZE completes its execution. Fixes timescale#4857
Issue occurs in extended query protocol mode only where every query goes through PREPARE and EXECUTE phase. First time ANALYZE is executed, a list of relations to be vaccumed is extracted and saved in a list. This list is referenced in parsetree node. Once execution of ANALYZE is complete, this list is cleaned up, however reference to the same is not cleaned up in parsetree node. When second time ANALYZE is executed, segfault happens as we access an invalid memory location. Fixed the issue by restoring the actual value in parsetree node once ANALYZE completes its execution. Fixes timescale#4857
Issue occurs in extended query protocol mode only where every query goes through PREPARE and EXECUTE phase. First time ANALYZE is executed, a list of relations to be vaccumed is extracted and saved in a list. This list is referenced in parsetree node. Once execution of ANALYZE is complete, this list is cleaned up, however reference to the same is not cleaned up in parsetree node. When second time ANALYZE is executed, segfault happens as we access an invalid memory location. Fixed the issue by restoring the actual value in parsetree node once ANALYZE completes its execution. Fixes #4857
Issue occurs in extended query protocol mode only where every query goes through PREPARE and EXECUTE phase. First time ANALYZE is executed, a list of relations to be vaccumed is extracted and saved in a list. This list is referenced in parsetree node. Once execution of ANALYZE is complete, this list is cleaned up, however reference to the same is not cleaned up in parsetree node. When second time ANALYZE is executed, segfault happens as we access an invalid memory location. Fixed the issue by restoring the actual value in parsetree node once ANALYZE completes its execution. Fixes #4857
What type of bug is this?
Crash
What subsystems and features are affected?
Other
What happened?
When I execute
ANALYZE
twice from my application using SQLx the second execution consistently leads to the worker process segfaulting.Strangely it does not happen when repeatedly executing
ANALYZE
inpsql
.TimescaleDB version affected
2.8.1
PostgreSQL version used
14.5
What operating system did you use?
Arch Linux x86_64
What installation method did you use?
Other
What platform did you run on?
Other
Relevant log output and stack trace
How can we reproduce the bug?
The text was updated successfully, but these errors were encountered: