/postgres-large-files-prototype

Test postgres LFS transactions under load and bad conditions from Node.js

Primary LanguageTypeScriptMIT LicenseMIT

postgres-large-files-prototype

Why?

This code will test various scenarios of uploading and downloading files from Postgres Large File Storage. In production we have seen that poor network conditions can interrupt an upload or download leaving transactions open which eventually will queue and lock any further transactions.

We want battle hardened Node.js code that will clean up transactions so that the server can survive these conditions!

Useful SQL Queries for Postgres

Find open transaction locks

SELECT * FROM pg_locks pl
LEFT JOIN pg_stat_activity psa
ON pl.pid = psa.pid
WHERE application_name != 'pgAdmin III - Query Tool';

Kill a transaction

select pg_terminate_backend(18234);

Download a file

$ psql --host localhost -U postgres -d media -p 5444 -c "\lo_export 17531 '~/Desktop/download.test' "

List large objects

$ psql --host localhost -U postgres -d media -p 5444 -c "\lo_list"