bitflicker64 opened a new pull request, #3383:
URL: https://github.com/apache/hugegraph/pull/3383

   ## Purpose of the PR
   
   - part of #3235; no issue of its own
   
   `KvServiceGrpcImpl.get` and `scanPrefix` answer from the leader's local 
store. A leader elected a
   moment ago may not have applied every committed write yet, so a client can 
read a value older than
   one it already saw committed: a Server that caches schema from a KV read 
would keep a stale copy
   past a revision it acknowledged. #3368 put a ReadIndex barrier before PD 
reads an id counter; this
   PR puts the same barrier, with the same deadline, before the two KV reads.
   
   It was part of #3376 and was reviewed there; it does not depend on that PR 
and stands on its own.
   Step 2 of the schema cache sync (the record watch with ACK and retry) needs 
both merged.
   
   This PR is limited to the ReadIndex barrier before the two KV reads; a bug 
that already exists on
   master in code this PR did not write is tracked as an issue, not fixed here.
   
   ## Main Changes
   
   One commit, three files, 8 production, 205 test and 1 doc lines.
   
   - `KvServiceGrpcImpl.get` and `scanPrefix` call `RaftEngine.waitReadIndex()` 
before they read the
     store. When the leader cannot confirm and apply a ReadIndex within 
`raft.rpc-timeout`, the read
     fails with the error in the response header and no value, instead of a 
stored value that may be
     stale. A follower redirects to the leader as before.
   - `hugegraph-pd/docs/configuration.md`: the `raft.rpc-timeout` row says the 
deadline also bounds
     the KV `get` and `scanPrefix`.
   
   ## Verifying these changes
   
   - [ ] Trivial rework / code cleanup without any test coverage. (No Need)
   - [ ] Already covered by existing tests, such as *(please modify tests 
here)*.
   - [x] Need tests and can be verified as follows:
       - `KvServiceGrpcImplTest` (new, `hg-pd-service`; it runs with every PD 
suite, since `-am`
         builds the module): `testGetAndScanReadAfterTheReadIndex` (the 
ReadIndex runs before each
         read, which then returns the stored value) and 
`testFailedReadIndexReturnsNoStoredValue` (a
         ReadIndex that times out, as on a leader without a quorum, is answered 
with an error and no
         value, and the store is not read at all). The raft node is a proxy 
that answers each
         ReadIndex as jraft does, by setting the result and running the closure.
       - Suites on Pune101 (JDK 17, 2026-10-20, under the shared lock) at 
9cb4e5582: package and
         `editorconfig:check` clean, pd-common 83/0/0/0, pd-core 190/0/0/2, 
pd-client 83/0/0/0
         against a packaged PD (tests, failures, errors, skipped); the 
`hg-pd-service` module ran
         29 tests in each suite, master's 27 plus these two.
   
   ## Does this PR potentially affect the following parts?
   
   - [ ]  Dependencies ([add/update 
license](https://hugegraph.apache.org/docs/contribution-guidelines/contribute/#321-check-licenses)
 info & 
[regenerate_known_dependencies.sh](../install-dist/scripts/dependency/regenerate_known_dependencies.sh))
   - [ ]  Modify configurations
   - [ ]  The public API
   - [x]  Other affects (typed here): a KV `get` or `scanPrefix` on a leader 
that cannot confirm a
     ReadIndex within `raft.rpc-timeout` (10 s by default) now fails instead of 
answering from its
     local store; a client retries as it does for any PD error. Each read waits 
one ReadIndex round
     trip on a healthy leader.
   - [ ]  Nope
   
   ## Documentation Status
   
   Select one option and provide the documentation location when applicable.
   
   - [ ] `Doc - TODO`: required documentation is pending; complete it before 
merging.
   - [x] `Doc - Done`: documentation is included here or linked below.
   - [ ] `Doc - No Need`: no user-visible documentation is affected.
   
   Documentation files in this PR or paired hugegraph-doc PR:
   `hugegraph-pd/docs/configuration.md`, the `raft.rpc-timeout` row.
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to