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
"Something unusual has occurred to cause the driver to fail. Please report this exception." with liquibase #883
Comments
Hi @tiny-dancer, thanks for opening this issue! I'll take a look soon and keep you updated. Does connecting work with previous releases? Like if you were to use the jar for v1.5.0, does it work? |
@shubha-rajan thanks for the quick response. I attempted with 1.5.0 and encountered the same error. Also tried both with-dependences and with-driver-and-dependencies and same error. Is there a way to enable debug logs or something with in cloud sql socket factory? Flying a little blind. attempted to set the below with no luck for additional insight: with logging.properties:
|
Note: it did work from local laptop. Have not been able to successfully do it from gcp vm though. EDIT: after typing that, I attempted to use personal creds over the vm service account creds as application default in vm - no luck. |
@tiny-dancer Glad to hear you got this to work on your laptop. The error message isn't very helpful, though, is it? I'll try to reproduce on a GCE VM and report back on what I find. My first impression is that this is a credential problem that doesn't result in a good error. |
So I reproduced the problem on a VM that had only the "Default Access" scopes configured. When I updated the scopes to include "Cloud SQL", the error went away. There are some more details here: https://cloud.google.com/compute/docs/access/service-accounts#accesscopesiam Would you like to try updating the access scopes and trying again? |
Feel free to re-open if that doesn't work. |
@enocom thanks for the response. was unable to resolve the issue with the Consider this reopened (don't believe i can actually do that) |
@shubha-rajan Mind taking a look? |
Hi @tiny-dancer, just to confirm, you tried enabling the Cloud SQL API on your compute engine VM? |
I think that there is some underlying issue preventing the connection from being created, but is is being buried in the Liquibase stack trace. Is it possible to get a more complete stack trace? |
We need more information about the exact problem to try to resolve this issue. The exception provided is not detailed enough due to deficiencies in Liquibase's error handling. The nested cause from Liquibase is here JdbcConnection.java:91, which eats the caused by exception. Based on the message, "Something unusual occurred...", the exception that Liquibase ate is a PSQLException thrown from here message happens when org.postgresql.Driver catches an Exception while trying to evaluate connection properties and connect for the first time. So it seems the root cause is somewhere in com.google.cloud.sql.postgres.SocketFactory. However it is not clear from the errors whether this is related to changes in the dependencies for socket factory 1.61, permissions, or something else. I submitted a PR to Liquibase to try to get more of the stack trace in the log. I was able to reproduce this error from liquibase on a GCP Ubuntu VM when the VM's service account does not have permission to access the cloud sql api. I corrected this with the following steps:
However, as I said above, I'm not sure if you having this exact problem or a different one that produces the same kind of error. We need your help to gather more data before we can go further. If you are able, please try running this simple Java program to see exactly what kind of socket connection error is being thrown Copy this into a file named Main.java and edit the value of DB_URL, USER, and PASS as appropriate for your database. import java.sql.*;
public class Main {
static final String DB_URL = "jdbc:postgresql:///db?cloudSqlInstance=<INSTANCE_CONN>&socketFactory=com.google.cloud.sql.postgres.SocketFactory";
static final String USER = "guest";
static final String PASS = "guest123";
static final String QUERY = "SELECT 1";
public static void main(String[] args) {
// Open a connection
try(Connection conn = DriverManager.getConnection(DB_URL, USER, PASS);
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(QUERY);) {
// Extract data from result set
while (rs.next()) {
// Retrieve by column name
System.out.print("ID: " + rs.getInt(1));
}
} catch (SQLException e) {
e.printStackTrace();
}
}
} Then run this script:
If this fails to connect, it will print out the exception that Liquibase has hidden. If you are feeling ambitious, try using my forked version of liquibase which hopefully will print out a better error message in the debug logs. |
Closing this issue since it has been inactive for a few months. Please reopen if you have any further questions. |
Bug Description
"Something unusual has occurred to cause the driver to fail. Please report this exception." When attempting to use com.google.cloud.sql.postgres.SocketFactory with liquibase.
Installed with this JAR https://storage.googleapis.com/cloud-sql-java-connector/v1.6.1/postgres-socket-factory-1.6.1-jar-with-driver-and-dependencies.jar.
Confirmed
Example code (or command)
Stacktrace
How to reproduce
./liquibase/liquibase --changelog-file=changelog.sql generate-changelog --defaultsFile=liquibase.staging.properties --log-level debug
Environment
Liquibase Community 4.11.0 by Liquibase
gcloud auth application-default print-access-token
returns an access tokenThe text was updated successfully, but these errors were encountered: