Skip to content

Conversation

@thiagotnunes
Copy link
Contributor

The DatabaseClientImpl#singleUseBoundAsync is sometimes getting stuck during the execution. This is simple to reproduce by executing the test class multiple times.
This is due to the static single threaded executor that is shared among all the test cases.
In this fix, we create an executor in the setup method, avoiding the sharing of the same among different tests.

The DatabaseClientImpl#singleUseBoundAsync is sometimes getting stuck
during the execution. This is simple to reproduce by executing the test
class multiple times.
This is due to the static single threaded executor that is shared
among all the test cases.
In this fix, we create an executor in the setup method, avoiding the
sharing of the same amongt different tests.
@thiagotnunes thiagotnunes requested a review from a team as a code owner January 14, 2021 06:38
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Jan 14, 2021
@product-auto-label product-auto-label bot added the api: spanner Issues related to the googleapis/java-spanner API. label Jan 14, 2021
@thiagotnunes
Copy link
Contributor Author

@olavloite could you let me know if this makes sense or was the intent of the test to exercise a single shared executor among all the test cases?

@codecov
Copy link

codecov bot commented Jan 14, 2021

Codecov Report

Merging #798 (3094164) into master (1a71e50) will increase coverage by 0.06%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #798      +/-   ##
============================================
+ Coverage     85.01%   85.08%   +0.06%     
+ Complexity     2562     2561       -1     
============================================
  Files           143      143              
  Lines         14015    14043      +28     
  Branches       1341     1341              
============================================
+ Hits          11915    11948      +33     
+ Misses         1537     1533       -4     
+ Partials        563      562       -1     
Impacted Files Coverage Δ Complexity Δ
.../google/cloud/spanner/AbstractLazyInitializer.java 92.85% <0.00%> (-7.15%) 4.00% <0.00%> (-1.00%)
...ain/java/com/google/cloud/spanner/SessionImpl.java 85.38% <0.00%> (-0.51%) 30.00% <0.00%> (ø%)
.../com/google/cloud/spanner/AbstractReadContext.java 87.07% <0.00%> (ø) 48.00% <0.00%> (ø%)
...va/com/google/cloud/spanner/AbstractResultSet.java 83.30% <0.00%> (+0.03%) 28.00% <0.00%> (ø%)
...ain/java/com/google/cloud/spanner/SessionPool.java 89.15% <0.00%> (+0.32%) 71.00% <0.00%> (ø%)
...om/google/cloud/spanner/TransactionRunnerImpl.java 85.74% <0.00%> (+0.87%) 9.00% <0.00%> (ø%)
...m/google/cloud/spanner/connection/SpannerPool.java 86.11% <0.00%> (+1.66%) 31.00% <0.00%> (ø%)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1a71e50...3094164. Read the comment docs.

@olavloite
Copy link
Collaborator

@olavloite could you let me know if this makes sense or was the intent of the test to exercise a single shared executor among all the test cases?

There's no specific reason that the test was using a single shared executor, but at the same time I also don't see any specific reason that it should be necessary to create a new executor for each test, which makes me worry that this fix is actually just covering some other underlying problem.

@olavloite
Copy link
Collaborator

@thiagotnunes How are you running the test when it gets stuck? I am not able to reproduce it locally, both when running it through Maven (mvn test -Dtest=DatabaseClientImplTest) and when running it in Eclipse. I changed it to a parameterized test to make it easier to run it several times, but even after several hundred executions I have not been able to get it stuck.

@thiagotnunes
Copy link
Contributor Author

@olavloite that is interesting. I am running it through Intellij by changing the runner to repeat the test execution until Failure (it does not actually fail, but it gets stuck).

I can consistently reproduce this, on the second execution of the test. I will see if I have the time to do some more investigation on what's going on.

Copy link
Collaborator

@olavloite olavloite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried it out in the test runner in IntelliJ in the way that you suggested, and I can also reproduce it there. The problem seems to be that IntelliJ in that case will never unload the class, which again means that the executor is only initialized during the first run and then shutdown at the end. So the problem is not some underlying bug, and this fix is safe.

I would however suggest that we consider changing it in a slightly different way: Keep the executor static (but not final) and initialize it in the startStaticServer() method. Then we can also keep the executor.shutdown() in the stopServer() method.

@thiagotnunes
Copy link
Contributor Author

@olavloite good suggestion, this way we cover if the thread could be hanging somewhere in between tests

@thiagotnunes thiagotnunes merged commit 3640bb1 into googleapis:master Jan 17, 2021
@thiagotnunes thiagotnunes deleted the stuck-tests branch January 17, 2021 23:26
thiagotnunes added a commit that referenced this pull request May 6, 2021
* test: fixes DatabaseClientImpl stuck test

The DatabaseClientImpl#singleUseBoundAsync is sometimes getting stuck
during the execution. This is simple to reproduce by executing the test
class multiple times.
This is due to the static single threaded executor that is shared
among all the test cases.
In this fix, we create an executor in the setup method, avoiding the
sharing of the same amongt different tests.

* test: executor as static in test
ansh0l pushed a commit to ansh0l/java-spanner that referenced this pull request Nov 10, 2022
This is an auto-generated regeneration of the .pb.go files by
cloud.google.com/go/internal/gapicgen. Once this PR is submitted, genbot will
update the corresponding PR to depend on the newer version of go-genproto, and
assign reviewers. Whilst this or any regen PR is open in go-genproto, genbot
will not create any more regeneration PRs. If all regen PRs are closed,
gapicgen will create a new set of regeneration PRs once per night.

If you have been assigned to review this PR, please:

- Ensure that CI is passing. If it's failing, it requires your manual attention.
- Approve and submit this PR if you believe it's ready to ship. That will prompt
genbot to assign reviewers to the google-cloud-go PR.

Corresponding google-cloud-go PR: googleapis/google-cloud-go#5924

Changes:

fix(compute): revert proto3_optional, required removal on parent_id (googleapis#714)

  Source-Link: googleapis/googleapis@6b3fdce

build(servicemanagement): fix broken links
  PiperOrigin-RevId: 443188324
  Source-Link: googleapis/googleapis@775267e
rajatbhatta pushed a commit to rajatbhatta/java-spanner that referenced this pull request Nov 17, 2022
…cies to v2.10.0 (googleapis#798)

[![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [com.google.cloud:google-cloud-shared-dependencies](https://togithub.com/googleapis/java-shared-dependencies) | `2.9.0` -> `2.10.0` | [![age](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-shared-dependencies/2.10.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-shared-dependencies/2.10.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-shared-dependencies/2.10.0/compatibility-slim/2.9.0)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-shared-dependencies/2.10.0/confidence-slim/2.9.0)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>googleapis/java-shared-dependencies</summary>

### [`v2.10.0`](https://togithub.com/googleapis/java-shared-dependencies/blob/HEAD/CHANGELOG.md#&#8203;2100-httpsgithubcomgoogleapisjava-shared-dependenciescomparev290v2100-2022-04-15)

[Compare Source](https://togithub.com/googleapis/java-shared-dependencies/compare/v2.9.0...v2.10.0)

##### Dependencies

-   google-cloud-core 2.6.0 ([#&#8203;668](https://togithub.com/googleapis/java-shared-dependencies/issues/668)) ([22f4d18](https://togithub.com/googleapis/java-shared-dependencies/commit/22f4d1809cbb9848174b3569ab527e4bef00d443))
-   reverting protobuf to 3.19.4 ([#&#8203;657](https://togithub.com/googleapis/java-shared-dependencies/issues/657)) ([8501e6d](https://togithub.com/googleapis/java-shared-dependencies/commit/8501e6d842c10d2370bbd5d5246070134336bddd))
-   update dependency com.fasterxml.jackson:jackson-bom to v2.13.2.20220328 ([#&#8203;646](https://togithub.com/googleapis/java-shared-dependencies/issues/646)) ([7bfd6d7](https://togithub.com/googleapis/java-shared-dependencies/commit/7bfd6d7073859d1955b91b368c6713a72ffa14b6))
-   update dependency com.google.api-client:google-api-client-bom to v1.34.0 ([#&#8203;662](https://togithub.com/googleapis/java-shared-dependencies/issues/662)) ([1b8e378](https://togithub.com/googleapis/java-shared-dependencies/commit/1b8e378fe0ccf2a28c759868caaf5ba593a95728))
-   update dependency com.google.errorprone:error_prone_annotations to v2.12.1 ([#&#8203;652](https://togithub.com/googleapis/java-shared-dependencies/issues/652)) ([1cc80ee](https://togithub.com/googleapis/java-shared-dependencies/commit/1cc80ee984ebcad9bc2a95e2f28c0a49fe924b37))
-   update dependency com.google.errorprone:error_prone_annotations to v2.13.0 ([#&#8203;669](https://togithub.com/googleapis/java-shared-dependencies/issues/669)) ([61b7834](https://togithub.com/googleapis/java-shared-dependencies/commit/61b78341b34a251722be4805a6bdd895cd64836c))
-   update dependency com.google.http-client:google-http-client-bom to v1.41.6 ([#&#8203;654](https://togithub.com/googleapis/java-shared-dependencies/issues/654)) ([140ef40](https://togithub.com/googleapis/java-shared-dependencies/commit/140ef405bc17ed83f5ce177df59affca14fbe49c))
-   update dependency com.google.http-client:google-http-client-bom to v1.41.7 ([#&#8203;658](https://togithub.com/googleapis/java-shared-dependencies/issues/658)) ([f6f93e5](https://togithub.com/googleapis/java-shared-dependencies/commit/f6f93e5b9172c9684623c4c148e4a8fe2fae1e94))
-   update dependency com.google.oauth-client:google-oauth-client-bom to v1.33.2 ([#&#8203;655](https://togithub.com/googleapis/java-shared-dependencies/issues/655)) ([20cd9ed](https://togithub.com/googleapis/java-shared-dependencies/commit/20cd9eda112c96836a5ab7485a4247ed2bc0edb8))
-   update dependency com.google.oauth-client:google-oauth-client-bom to v1.33.3 ([#&#8203;663](https://togithub.com/googleapis/java-shared-dependencies/issues/663)) ([f011a46](https://togithub.com/googleapis/java-shared-dependencies/commit/f011a46c551dba16851b4f8c919c40452fc5d5c3))
-   update dependency com.google.protobuf:protobuf-bom to v3.20.0 ([#&#8203;651](https://togithub.com/googleapis/java-shared-dependencies/issues/651)) ([ad2ff73](https://togithub.com/googleapis/java-shared-dependencies/commit/ad2ff73207dd6493321c77d8eca0022baf13b4ce))
-   update dependency io.grpc:grpc-bom to v1.45.1 ([#&#8203;647](https://togithub.com/googleapis/java-shared-dependencies/issues/647)) ([38e46fc](https://togithub.com/googleapis/java-shared-dependencies/commit/38e46fc4f03af0a02f30ce4a2fa222c71797ae15))
-   update dependency org.checkerframework:checker-qual to v3.21.4 ([#&#8203;650](https://togithub.com/googleapis/java-shared-dependencies/issues/650)) ([125e80a](https://togithub.com/googleapis/java-shared-dependencies/commit/125e80ab2c3225a00c03f5ff5de94872ebb94303))
-   update gax.version to v2.15.0 ([#&#8203;649](https://togithub.com/googleapis/java-shared-dependencies/issues/649)) ([c7f32a6](https://togithub.com/googleapis/java-shared-dependencies/commit/c7f32a68b14520104432282ac9598643700162eb))
-   update gax.version to v2.16.0 ([#&#8203;664](https://togithub.com/googleapis/java-shared-dependencies/issues/664)) ([caaf941](https://togithub.com/googleapis/java-shared-dependencies/commit/caaf941643af04295f5527a0144587d7bf040862))
-   update google.common-protos.version to v2.8.1 ([#&#8203;656](https://togithub.com/googleapis/java-shared-dependencies/issues/656)) ([df4a4a2](https://togithub.com/googleapis/java-shared-dependencies/commit/df4a4a2130a3cdb2965ea42962d1ea6a85506ba7))
-   update google.common-protos.version to v2.8.2 ([#&#8203;659](https://togithub.com/googleapis/java-shared-dependencies/issues/659)) ([b499e2b](https://togithub.com/googleapis/java-shared-dependencies/commit/b499e2bc99506d48d26e35bf6e68c09409ce8b11))
-   update google.common-protos.version to v2.8.3 ([#&#8203;660](https://togithub.com/googleapis/java-shared-dependencies/issues/660)) ([461081c](https://togithub.com/googleapis/java-shared-dependencies/commit/461081c0cf73057c1f6e07fc573453ad467a60ae))
-   update iam.version to v1.3.0 ([#&#8203;648](https://togithub.com/googleapis/java-shared-dependencies/issues/648)) ([6670c4f](https://togithub.com/googleapis/java-shared-dependencies/commit/6670c4f61fcf075c543bfd148eea49796e0662ce))
-   update iam.version to v1.3.1 ([#&#8203;661](https://togithub.com/googleapis/java-shared-dependencies/issues/661)) ([cc8fbe6](https://togithub.com/googleapis/java-shared-dependencies/commit/cc8fbe6eae03341c2ece7d3356febc843a74a812))

</details>

---

### Configuration

📅 **Schedule**: At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox.

---

This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/java-spanner-jdbc).
rajatbhatta pushed a commit to rajatbhatta/java-spanner that referenced this pull request Nov 17, 2022
🤖 I have created a release *beep* *boop*
---


### [2.6.4](googleapis/java-spanner-jdbc@v2.6.3...v2.6.4) (2022-04-21)


### Dependencies

* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.10.0 ([googleapis#798](googleapis/java-spanner-jdbc#798)) ([a77024c](googleapis/java-spanner-jdbc@a77024c))

---
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: spanner Issues related to the googleapis/java-spanner API. cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants