Created
October 27, 2020 10:39
-
-
Save saswata-dutta/debca447bf1b66a7207833f1ea2389a2 to your computer and use it in GitHub Desktop.
log postgres serverside pid for debugging
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void logServerPID(Connection connection) throws SQLException { | |
if (connection.isWrapperFor(PGConnection.class)) { | |
// WARNING this PGConnection will have some mem leak, but cant close it, so only use it for debugging | |
PGConnection pgConnection = connection.unwrap(PGConnection.class); | |
log.info("Server PID {}", pgConnection.getBackendPID()); | |
} else { | |
log.warn("Connection instance is not of pg instance type"); | |
} | |
} | |
@Transactional(rollbackOn = Exception.class) | |
public <T> void run() { | |
EntityManager entityManager = entityManagerProvider.get(); | |
Session session = entityManager.unwrap(Session.class); | |
session.doWork(this::logServerPID); | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment