Datasource binging in VCAP_SERVICES result in multiple DataSources
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 38/100
Research direction
Start by inspecting the stack-trace locations in CfJdbcUrlCreator.java and CfJdbcEnv.java, then reproduce the issue with the VCAP_SERVICES example containing the oracle-mysql label and vmaasBrokerMySql name. Done means the binding no longer produces duplicate database services and the resulting datasource selection is covered by a regression test.
Written by the indexing model from the issue text.
Description
So far we are using the Spring Cloud Connector with a datasource in VCAP_SERVICES like this:
"oracle-mysql": [
{
"label": "oracle-mysql",
"provider": null,
"plan": "production",
"name": "vmaasBrokerMySql",
"tags": [
"database",
"mysql"
],
"instance_name": "vmaasBrokerMySql",
"binding_name": null,
"credentials": {
"hostname": "xx.xx.xx.xx",
"password": "password",
"readonly": false,
"port": 38010,
"dbschema-name": "db_name",
"uri": "mysql://username:[email protected]:38010/db_name?connectTimeout=20000&useSSL=true&verifyServerCertificate=false",
"username": "username"
},
"syslog_drain_url": null,
"volume_mounts": []
}
]
With Spring Cloud Connector this has worked the way that one DataSource was returned by the CloudConfig. When we try to switch to java-cfenv this doesn't work any more as the datasource binding end up with two datasources, one based on the label and one based on the name. At the end we receive an exception as below:
2020-10-21T14:35:51.564+02:00 [APP/PROC/WEB/0] [OUT] Caused by: java.lang.IllegalArgumentException: No unique database service found. Found database service names [vmaasBrokerMySql, vmaasBrokerMySql]
2020-10-21T14:35:51.564+02:00 [APP/PROC/WEB/0] [OUT] at io.pivotal.cfenv.jdbc.CfJdbcUrlCreator.throwExceptionIfMultipleMatches(CfJdbcUrlCreator.java:97)
2020-10-21T14:35:51.564+02:00 [APP/PROC/WEB/0] [OUT] at io.pivotal.cfenv.jdbc.CfJdbcUrlCreator.findJdbcService(CfJdbcUrlCreator.java:87)
2020-10-21T14:35:51.564+02:00 [APP/PROC/WEB/0] [OUT] at io.pivotal.cfenv.jdbc.CfJdbcEnv.findJdbcService(CfJdbcEnv.java:46)
From my perspective either the first datasource created should be returned (then it would need a order which defines the preference) or the decision is not made based on name/labels, but the URI itself, as this would clearly distinguish between Oracle and MySQL.
- Dominant language
- Java
- Stars
- 97
- Forks
- 64
- Avg merge
- 6h 36m
- Merged PRs (30d)
- 6
Getting set up
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from pivotal-cf/java-cfenv
-
enhancement
Difficulty 4/5 3-5 days Newbie friendliness 45/100
pivotal-cf/java-cfenv#354 · 1 reaction ·
-
enhancement
Difficulty 3/5 1-2 days Newbie friendliness 48/100
pivotal-cf/java-cfenv#296 · 3 reactions ·
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 35/100
pivotal-cf/java-cfenv#292 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
pivotal-cf/java-cfenv#255 · 2 comments ·
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 35/100
pivotal-cf/java-cfenv#249 · 2 comments ·
All issues in pivotal-cf/java-cfenv
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
oracle/javavscode#652 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
OpenAPITools/openapi-generator#25014 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
AloisSeckar/demos-java#380 ·