0

I'm trying to detect a bad postgres PL/proxy shard connection through an exception in a plpgsql function. This works exactly as expected when the function is called directly (trying to access a bad shard throws an exception). However, the existing codebase calls the function indirectly through a plproxy function in the RUN ON statement, and in this case an exception gets thrown accessing any shard, good or bad. Has anyone else seen this and/or have a solution or workaround?

Here's a trimmed example of the problem:

A) FunctionA is a plproxy function, which has the line: RUN ON functionB($1, NULL);

B) functionB is a plpgsql function, which has the line: SELECT db_index FROM functionC();

C) functionC is also a plpgsql function, which has the code checking the connection: FOR db_id IN () LOOP BEGIN PERFORM check_shard(db_id); --This just calls a function that runs on the shard EXCEPTION WHEN internal_error THEN RAISE NOTICE 'CAUGHT EXCEPTION FOR ID %', db_id; END; END LOOP;

When functionB or functionC is called directly from in a SELECT, the good shards do NOT throw an exception. But when plproxy functionA is called with the function call in the RUN ON statement, all shards throw the exception. So it seems there's something going on with the plproxy function or the RUN ON statement that's causing this issue.

Any help would be greatly appreciated!

1 Answer 1

0

This sounds like a bug in pl/proxy. My recommendation is that you take this up with the skytools maintainers. I can't for the life of me see any logical reason why this would be desired behavior or even might happen. Maybe something is blocking somewhere?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.