You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/03/02 07:09:35 UTC
[GitHub] [shardingsphere] sandynz opened a new issue #15752: CuratorZookeeperRepository.get might return old value from cache after `watch` is called in unit test
sandynz opened a new issue #15752:
URL: https://github.com/apache/shardingsphere/issues/15752
## Bug Report
### Which version of ShardingSphere did you use?
master branch, commit 54758fe13ef2d9e8255710e015abcbcaf13eb01e and a69541e29a3f0f7cc8b0c95ab9479ac0bcd46818
### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
In unit test.
### Expected behavior
`CuratorZookeeperRepository.get` return correct value, so `GovernanceRepositoryAPIImplTest.assertRenewJobStatus` could pass.
### Actual behavior
If `GovernanceRepositoryAPIImplTest.assertWatch` is enabled, then `GovernanceRepositoryAPIImplTest.assertRenewJobStatus` failed. Unit test output:
```
java.lang.AssertionError:
Expected: is <FINISHED>
but: was <RUNNING>
Expected :is <FINISHED>
Actual :<RUNNING>
<Click to see difference>
at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
at org.junit.Assert.assertThat(Assert.java:956)
at org.junit.Assert.assertThat(Assert.java:923)
at org.apache.shardingsphere.data.pipeline.api.impl.GovernanceRepositoryAPIImplTest.assertRenewJobStatus(GovernanceRepositoryAPIImplTest.java:139)
```
### Reason analyze (If you can)
`CuratorZookeeperRepository.watch` will enable `CuratorCache`, seems `CuratorZookeeperRepository.persist` doesn't update curator cache, when `CuratorZookeeperRepository.get` it get value from curator cache and get old value.
In commit 54758fe13ef2d9e8255710e015abcbcaf13eb01e
It try to persist status `FINISHED` and no exception thrown:
<img width="1356" alt="WX20220302-123511@2x" src="https://user-images.githubusercontent.com/42492540/156306042-e17a2291-4968-429d-8c65-e7626e28e91e.png">
But when get value from `CuratorZookeeperRepository`, it get old value from cache:
<img width="1329" alt="WX20220302-123859@2x" src="https://user-images.githubusercontent.com/42492540/156306170-000e6f12-dd6e-41d1-a66c-8ecc9e91981e.png">
In commit a69541e29a3f0f7cc8b0c95ab9479ac0bcd46818, `CuratorZookeeperRepository` has been refactored in 8f012fe4adff996fd796feec038d3837d4a704cc, but `CuratorZookeeperRepository.get` still return wrong value and `assertRenewJobStatus` couldn't pass.
<img width="1210" alt="WX20220302-142610@2x" src="https://user-images.githubusercontent.com/42492540/156308437-d671e18b-4d87-4cdd-8960-1449304ddd6d.png">
Seems `CuratorZookeeperRepository.persist` will update cache but with some delay. I couldn't get the `CuratorZookeeperRepository.get` screenshot anymore, but I could print log to verify it:
```
CuratorZookeeperRepository - get, key=/scaling/1198244117912739/offset/0, value=
incremental:
ds_0:
delay:
lastEventTimestamps: 0
latestActiveTimeMillis: 0
position: ''
inventory:
unfinished:
ds_0.t_order#0: ''
sourceDatabaseType: H2
status: RUNNING
java.lang.AssertionError:
Expected: is <FINISHED>
but: was <RUNNING>
Expected :is <FINISHED>
Actual :<RUNNING>
<Click to see difference>
```
### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
Enable `GovernanceRepositoryAPIImplTest.assertWatch` (it's commented for now), run unit tests of `GovernanceRepositoryAPIImplTest` in IDE. If `assertRenewJobStatus` run after `assertWatch`, then it could be reproduced.
### Example codes for reproduce this issue (such as a github link).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] sandynz commented on issue #15752: CuratorZookeeperRepository.get might return old value from cache after `watch` is called in unit test
Posted by GitBox <gi...@apache.org>.
sandynz commented on issue #15752:
URL: https://github.com/apache/shardingsphere/issues/15752#issuecomment-1056426327
Currently, I've sumbmitted PR #15739 as workaround for `assertRenewJobStatus`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] menghaoranss closed issue #15752: CuratorZookeeperRepository.get might return old value from cache after `watch` is called in unit test
Posted by GitBox <gi...@apache.org>.
menghaoranss closed issue #15752:
URL: https://github.com/apache/shardingsphere/issues/15752
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] menghaoranss commented on issue #15752: CuratorZookeeperRepository.get might return old value from cache after `watch` is called in unit test
Posted by GitBox <gi...@apache.org>.
menghaoranss commented on issue #15752:
URL: https://github.com/apache/shardingsphere/issues/15752#issuecomment-1065224939
fixes by #15986
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org