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

Investigate Postgres Out of Memory Errors in Production #3667

Open
rajadain opened this issue Jan 24, 2025 · 1 comment
Open

Investigate Postgres Out of Memory Errors in Production #3667

rajadain opened this issue Jan 24, 2025 · 1 comment

Comments

@rajadain
Copy link
Member

On occasion, we will see very high memory usage in RDS in production, which will crash the database and require it to be rebooted (which happens automatically, but likely risks data loss)

Image

Looking at queries executing around then, the highest pressure seems to come from Global RWD delineation. Perhaps the shapes being delineated are too large?

Image

These are SQL snippets from the above recording:

WITH target AS ( SELECT * FROM tdxbasins WHERE ST_Intersects(geom, ST_SetSRID(ST_Point( -80.9637451171875, 42.216313604344776), 4326)) ) SELECT json_build_object( 'type', 'Feature', 'properties', '{}'::json, 'geometry', ST_AsGeoJSON(ST_Union(geom))::json ) FROM tdxbasins WHERE root_id = (SELECT root_id FROM target) AND discover_time >= (SELECT discover
WITH target AS ( SELECT * FROM tdxbasins WHERE ST_Intersects(geom, ST_SetSRID(ST_Point( -73.92193794250488, 42.10395389957932), 4326)) ) SELECT json_build_object( 'type', 'Feature', 'properties', '{}'::json, 'geometry', ST_AsGeoJSON(ST_Union(geom))::json ) FROM tdxbasins WHERE root_id = (SELECT root_id FROM target) AND discover_time >= (SELECT discover

Investigate if these queries cause high RAM usage in Postgres, and devise an appropriate mediation strategy. This could be query optimization, query limitation, or increased resource allocation to RDS.

@aufdenkampe
Copy link
Member

@rajadain, this result makes sense for large watersheds, and is almost certainly due to dissolving the basin polygons into a custom watershed boundary.

Fortunately, @ptomasula and I anticipated this. I just created the following issue that describes our solution and its benefits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants