Skip to content
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

Introduce multi-threaded/multi-version client support for GRV caching #6664

Merged
merged 19 commits into from Apr 7, 2022

Conversation

sfc-gh-jfu
Copy link
Collaborator

@sfc-gh-jfu sfc-gh-jfu commented Mar 23, 2022

This PR is a follow-up to #5725 and adds functionality to the fdb_c and MultiVersionApi related interfaces to support GRV caching behaving as expected, especially in commit->read (your own commits) patterns when there are multiple connections to the same cluster. The correctness is tested through the C API framework for multi-threaded operations introduced by #6433, enabled by setting the transaction option to use the GRV cache within the existing tests.

Code-Reviewer Section

The general guidelines can be found here.

Please check each of the following things and check all boxes before accepting a PR.

  • The PR has a description, explaining both the problem and the solution.
  • The description mentions which forms of testing were done and the testing seems reasonable.
  • Every function/class/actor that was touched is reasonably well documented.

For Release-Branches

If this PR is made against a release-branch, please also check the following:

  • This change/bugfix is a cherry-pick from the next younger branch (younger release-branch or master if this is the youngest branch)
  • There is a good reason why this PR needs to go into a release branch and this reason is documented (either in the description above or in a linked GitHub issue)

@fdb-windows-ci
Copy link
Collaborator

Doxense CI Report for Windows 10

@foundationdb-ci
Copy link
Contributor

AWS CodeBuild CI Report for Linux CentOS 7

  • CodeBuild project: foundationdb-pr
  • Commit ID: 3441987
  • Result: SUCCEEDED
  • Error: N/A
  • Build Logs (available for 30 days)

@foundationdb-ci
Copy link
Contributor

AWS CodeBuild CI Report for Linux CentOS 7

  • CodeBuild project: foundationdb-pr
  • Commit ID: 7af4b24
  • Result: SUCCEEDED
  • Error: N/A
  • Build Logs (available for 30 days)

@foundationdb-ci
Copy link
Contributor

AWS CodeBuild CI Report for Linux CentOS 7

  • CodeBuild project: foundationdb-pr
  • Commit ID: 9f72d68
  • Result: SUCCEEDED
  • Error: N/A
  • Build Logs (available for 30 days)

fdbclient/MultiVersionTransaction.actor.cpp Outdated Show resolved Hide resolved
fdbclient/MultiVersionTransaction.actor.cpp Outdated Show resolved Hide resolved
fdbclient/MultiVersionTransaction.actor.cpp Show resolved Hide resolved
fdbclient/NativeAPI.actor.cpp Outdated Show resolved Hide resolved
fdbclient/NativeAPI.actor.cpp Outdated Show resolved Hide resolved
fdbclient/FDBTypes.h Show resolved Hide resolved
@fdb-windows-ci
Copy link
Collaborator

Doxense CI Report for Windows 10

@foundationdb-ci
Copy link
Contributor

AWS CodeBuild CI Report for Linux CentOS 7

  • CodeBuild project: foundationdb-pr
  • Commit ID: 53d252f
  • Result: SUCCEEDED
  • Error: N/A
  • Build Logs (available for 30 days)

@sfc-gh-jfu sfc-gh-jfu marked this pull request as ready for review March 30, 2022 17:58
@foundationdb-ci
Copy link
Contributor

AWS CodeBuild CI Report for macOS BigSur 11.5.2

  • CodeBuild project: foundationdb-pr-macos
  • Commit ID: 9d0a520
  • Result: SUCCEEDED
  • Error: N/A
  • Build Logs (available for 30 days)

@fdb-windows-ci
Copy link
Collaborator

Doxense CI Report for Windows 10

@foundationdb-ci
Copy link
Contributor

AWS CodeBuild CI Report for Linux CentOS 7

  • CodeBuild project: foundationdb-pr
  • Commit ID: 9d0a520
  • Result: SUCCEEDED
  • Error: N/A
  • Build Logs (available for 30 days)

@foundationdb-ci
Copy link
Contributor

AWS CodeBuild CI Report for Linux CentOS 7

  • CodeBuild project: foundationdb-pr
  • Commit ID: 4677b59
  • Result: FAILED
  • Error: Error while executing command: ctest -j ${NPROC} --no-compress-output -T test --output-on-failure. Reason: exit status 8
  • Build Logs (available for 30 days)

@fdb-windows-ci
Copy link
Collaborator

Doxense CI Report for Windows 10

@fdb-windows-ci
Copy link
Collaborator

Doxense CI Report for Windows 10

@foundationdb-ci
Copy link
Contributor

AWS CodeBuild CI Report for macOS BigSur 11.5.2

  • CodeBuild project: foundationdb-pr-macos
  • Commit ID: c46ad3c
  • Result: SUCCEEDED
  • Error: N/A
  • Build Logs (available for 30 days)

@foundationdb-ci
Copy link
Contributor

AWS CodeBuild CI Report for Linux CentOS 7

  • CodeBuild project: foundationdb-pr
  • Commit ID: c46ad3c
  • Result: SUCCEEDED
  • Error: N/A
  • Build Logs (available for 30 days)

fdbclient/MultiVersionTransaction.actor.cpp Outdated Show resolved Hide resolved
fdbclient/NativeAPI.actor.cpp Outdated Show resolved Hide resolved
fdbclient/NativeAPI.actor.cpp Show resolved Hide resolved
fdbclient/MultiVersionTransaction.actor.cpp Show resolved Hide resolved
fdbclient/MultiVersionTransaction.actor.cpp Show resolved Hide resolved
@@ -233,10 +252,18 @@ void DatabaseContext::updateCachedReadVersion(double t, Version v) {
}

Version DatabaseContext::getCachedReadVersion() {
if (sharedStatePtr) {
MutexHolder mutex(sharedStatePtr->mutexLock);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would suggest to plan a follow up task to optimize synchonization on the global cachedReadVersion. Mutex gives a reliable implementation, but it can introduce a significant overhead in a configuration with multiple FDB threads. I think we can replace mutex with atomics. It is not completely trivial, because the cachedReadVersion and lastGrvTime must be updated atomically, but it is doable. We can discuss it after you are done with this PR.

@fdb-windows-ci
Copy link
Collaborator

Doxense CI Report for Windows 10

@foundationdb-ci
Copy link
Contributor

AWS CodeBuild CI Report for Linux CentOS 7

  • CodeBuild project: foundationdb-pr
  • Commit ID: 1b9bd59
  • Result: SUCCEEDED
  • Error: N/A
  • Build Logs (available for 30 days)

fdbclient/NativeAPI.actor.cpp Outdated Show resolved Hide resolved
fdbclient/MultiVersionTransaction.actor.cpp Show resolved Hide resolved
test_grv.py Outdated Show resolved Hide resolved
@foundationdb-ci
Copy link
Contributor

AWS CodeBuild CI Report for macOS BigSur 11.5.2

  • CodeBuild project: foundationdb-pr-macos
  • Commit ID: b0ae22f
  • Result: SUCCEEDED
  • Error: N/A
  • Build Logs (available for 30 days)

@fdb-windows-ci
Copy link
Collaborator

Doxense CI Report for Windows 10

@foundationdb-ci
Copy link
Contributor

AWS CodeBuild CI Report for Linux CentOS 7

  • CodeBuild project: foundationdb-pr
  • Commit ID: b0ae22f
  • Result: SUCCEEDED
  • Error: N/A
  • Build Logs (available for 30 days)

@sfc-gh-jfu
Copy link
Collaborator Author

Testing done: 100k correctness passed at 20220406-163540-jfu-foundationdb2-1b627eb6a933ea08
ctest with multi-threaded client and grv caching enabled passed
manual cluster upgrade performed with upgrade + grv cache behaving as expected
@sfc-gh-vgasiunas

@sfc-gh-vgasiunas sfc-gh-vgasiunas merged commit 2ff1198 into apple:main Apr 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants