Solution (source code)

= Solution

For $q>1$, decreasing the second parameter by one gives another valid <beta distribution> density and
$$
\frac{f_{p,q}(x)}{1-x}
=\frac{p+q-1}{q-1}f_{p,q-1}(x).
$$
Normalization therefore gives
$$
\boxed{\mathbb E\!\left[\frac1{1-X}\right]=\frac{p+q-1}{q-1}.}
$$
The restriction $q>1$ is essential for this finite <expected value>; when $q=1$, the singularity near $1$ instead makes the expectation infinite.