-
Notifications
You must be signed in to change notification settings - Fork 98
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 for cache reference leak warning #3161
base: BABEL_4_X_DEV
Are you sure you want to change the base?
Fix for cache reference leak warning #3161
Conversation
Signed-off-by: Pranav Jain <[email protected]>
Pull Request Test Coverage Report for Build 13101407937Details
💛 - Coveralls |
Signed-off-by: Pranav Jain <[email protected]>
Signed-off-by: Pranav Jain <[email protected]>
Signed-off-by: Pranav Jain <[email protected]>
Signed-off-by: Pranav Jain <[email protected]>
Signed-off-by: Pranav Jain <[email protected]>
Signed-off-by: pranav jain <[email protected]>
Signed-off-by: pranav jain <[email protected]>
Signed-off-by: pranav jain <[email protected]>
Signed-off-by: pranav jain <[email protected]>
Signed-off-by: pranav jain <[email protected]>
Signed-off-by: pranav jain <[email protected]>
Signed-off-by: pranav jain <[email protected]>
Signed-off-by: pranav jain <[email protected]>
Signed-off-by: pranav jain <[email protected]>
Signed-off-by: pranav jain <[email protected]>
if(get_bbf_function_tuple_from_proctuple(SearchSysCache1(PROCOID, ObjectIdGetDatum(oldoid))) == NULL) | ||
proctup = SearchSysCache1(PROCOID, ObjectIdGetDatum(oldoid)); | ||
|
||
if (proctup == NULL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should use HeapTupleIsValid
& curly braces can be removed in next line.
if (get_bbf_function_tuple_from_proctuple(proctup) == NULL) | ||
{ | ||
/* Release the tuple before reporting the error */ | ||
ReleaseSysCache(proctup); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case of error we do not need to release syscache
Signed-off-by: pranav jain <[email protected]>
Signed-off-by: pranav jain <[email protected]>
Signed-off-by: pranav jain <[email protected]>
…arning file Signed-off-by: pranav jain <[email protected]>
Signed-off-by: pranav jain <[email protected]>
Signed-off-by: pranav jain <[email protected]>
Signed-off-by: pranav jain <[email protected]>
Signed-off-by: pranav jain <[email protected]>
Signed-off-by: pranav jain <[email protected]>
.github/workflows/jdbc-tests.yml
Outdated
EXPECTED_WARNINGS_FILE=~/work/babelfish_extensions/babelfish_extensions/test/JDBC/expected/expected-warnings.out | ||
|
||
# Collect all leak warnings from log files, extracting only the warning type | ||
grep -i "WARNING:.*leak" ~/psql/data/logfile | sed -E 's/^.*WARNING:\s*([^:]+(\s+reference\s+leak|connection leak)[^:]*):.*/WARNING: \1/' | sort > actual-leak-warnings.out |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some warnings do not contain the word leak but are still important for us & need to be resolved.
For example elog(WARNING, "snapshot %p still active", active);
Will this check be able to catch this WARNING if it comes up in future ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To grep the warnings which do not contains leak, we need to either grep only "WARNING" or we need to grep the whole line containing "WARNING" keyword.
If we only grep WARNING in the expected-file then while debugging it might be difficult to tell that which type of new warning we are getting.
If we grep whole line containing "WARNING" then there are some reference tuple which might be dynamically allocated during test run, so we cannot compare the expected and actual files.
Open to suggestions!
Signed-off-by: pranav jain <[email protected]>
Signed-off-by: pranav jain <[email protected]>
Signed-off-by: pranav jain <[email protected]>
Signed-off-by: pranav jain <[email protected]>
Signed-off-by: pranav jain <[email protected]>
Signed-off-by: pranav jain <[email protected]>
Signed-off-by: pranav jain <[email protected]>
Signed-off-by: pranav jain <[email protected]>
Signed-off-by: pranav jain <[email protected]>
Signed-off-by: pranav jain <[email protected]>
Signed-off-by: pranav jain <[email protected]>
Signed-off-by: pranav jain <[email protected]>
@@ -537,7 +537,10 @@ tsql_get_functiondef(PG_FUNCTION_ARGS) | |||
(void) tsql_print_function_arguments(&buf, proctup, false, true, &typmod_arr, &has_tvp); | |||
/* TODO: In case of Table Valued Functions, return NULL. */ | |||
if (has_tvp) | |||
{ | |||
ReleaseSysCache(proctup); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is one more PG_RETURN_NULL() at line 528, we need to release sys cache there as well.
.github/workflows/jdbc-tests.yml
Outdated
if: always() | ||
id: check-warnings | ||
run: | | ||
LOG_FILE=~/psql/data/logfile |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets have bash script for this check and you can invoke that script directly.
.github/workflows/jdbc-tests.yml
Outdated
if [[ "$LEAK_COUNT" -ne 380 ]]; then | ||
echo "Error: Expected 380 leak warnings, but found $LEAK_COUNT" | ||
ERROR_FOUND=true | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this mean that for any new testfile which will generate warnings that are expected will increase this count and everytime developer needs to update this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes if that generates the LEAK or SNAPSHOT warning then only this count will change, for that case developer should check why the warning is generated
If there is some other warning, which is expected we are ignoring them. For a new kind of warning we are saying other unexpected warning
…leasesyscache Signed-off-by: pranav jain <[email protected]>
Signed-off-by: pranav jain <[email protected]>
Signed-off-by: pranav jain <[email protected]>
Description
Problem: Cache Reference Leaks
Fix:
a. To do sys-cache search via tuple and releasing it after the sys-cache search.
b. Also we are generating the logfile but the path that we were giving it github action workflow was not correct, updated
that too.
c. Added a step in jdbc-test workflow which will compare the warnings in logfile with expected warnings
Issues Resolved
[BABEL-5551]
Check List
By submitting this pull request, I confirm that my contribution is under the terms of the Apache 2.0 and PostgreSQL licenses, and grant any person obtaining a copy of the contribution permission to relicense all or a portion of my contribution to the PostgreSQL License solely to contribute all or a portion of my contribution to the PostgreSQL open source project.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.