Commit Graph

10 Commits

Author SHA1 Message Date
Trevor Clinkenbeard eec3cd49a0 Clean up actor compiler includes 2026-05-29 12:46:35 -07:00
Michael Stack 73442bb40e
Fix ASAN shutdown leaks and gRPC use-after-return crash (#13188)
Two issues addressed:

1. LSan reports 4648+ bytes leaked per Peer object at shutdown in
   fdb_c_api_tester and unit_tests. FlowTransport is allocated into a
   global slot and never deleted; deleting it triggers actor cancellation
   cascades that access freed state. Add suppressions for the known
   shutdown-time Peer/DDSketch/connectionKeeper leaks.

2. GrpcServer::deregisterRoleServices() takes a const UID& then
   co_awaits stopServer(). The caller passes interf.id() which becomes
   a dangling reference after the coroutine suspends (the caller actor
   frame can be reclaimed). This causes a stack-use-after-return crash
   detected by ASAN, manifesting as a segfault in fdbcli during
   configure new. Fix by passing UID by value at both call sites.
2026-05-11 12:29:20 -07:00
Trevor Clinkenbeard 652f85de07
Add and enforce more `readability-*` `clang-tidy` rules (#12765)
* Add and enforce more readability-* clang-tidy rules

* Revert readability-else-after-return changes
2026-03-12 22:30:38 -07:00
Vishesh Yadav 614ca9937e Synchronously use gRPC->Stop() in simulation 2025-11-05 18:22:44 -08:00
Vishesh Yadav ec9c50ef8a Address review comments 2025-10-31 13:05:36 -07:00
Vishesh Yadav 72d2e96b24 Make gRPC server and lifecycle part of worker interface
Also addresses some issues around TLS and initialization. The service
is started only if gRPC addresses are provided during startup.
2025-10-31 13:05:36 -07:00
Vishesh Yadav 38b7d6ff66 Implement TLS support for Flow/gRPC
This patch adds TLS support for GrpcServer and AsyncGrpcClient by
implementing `GrpcCredentialsProvider` and using that to get channel
credentials. It adds `FlowGrpc` which is a flow global instance, and
initializes TLS credentials that are consistent with the ones provided
to FlowTransport.

- Added `FlowGrpc` to manage gRPC server initialization and TLS
  configuration globally.
- `GrpcCredentialsProvider` abstracts secure/insecure communications
  configurations for server/clients.
- Introduced `GrpcTlsCredentialProvider` for dynamic TLS certificate
  reloading from filesystem and `GrpcTlsCredentialStaticProvider` for
  static in-memory credentials.
- Updated `GrpcServer` to accept a `GrpcCredentialProvider`, enabling
  dynamic TLS credential management.
- Modified `fdbserver` to use `FlowGrpc::init()` for gRPC server
  initialization instead of `GrpcServer::initInstance()`, aligning it
  with FlowTransport behavior.
- Modified `GrpcServer::run()` to use the provided
  `GrpcCredentialProvider` instead of hardcoded insecure credentials.

Testing:
- Implemented a basic mTLS test case (`/fdbrpc/grpc/basic_tls`) to
  verify secure gRPC connections using
  `GrpcTlsCredentialStaticProvider`.

Todo:
- Generate certificates during testruns instead statically.
- Add test for `GrpcTlsCredentialProvider` which reads keys/certs from
  filesystem and monitors changes.
- Verify peers rules/criterias like FDB --verify-peer feature.
2025-03-17 12:16:06 -07:00
Vishesh Yadav 4836a2e9ff Handle Exceptions in AsyncTaskExecutor
Forwards FDB's `Error` type thrown by tasks in `AsyncTaskExecutor`. Any other kind of exception is
forwarded as `unknown_error()`.
2025-03-06 17:31:20 -08:00
Vishesh Yadav 6329672513 gRPC server life-cycle management and AsyncTaskExecution
This patch has two set of changes:

- Whenever a service is registered and removed from server, we need to restart gRPC server.
  GrpcServer provides some methods that can be used by worker actors so that the life of
  services registered by them can tied to the life of the worker role itself.

- Replace asio::thread_pool with AsyncTaskExecutor both in client and server.
2025-03-05 15:17:30 -08:00
Vishesh Yadav 0032465c53
Add gRPC support to FDB (#11782)
* Implement gRPC support

* Move some CMake stuff around.

* Fix typo

* Add some test

* Add async client

* Add test for checking destroy

* [testing] Automatically discover unit-test and register as ctest

This patch adds `collect_unit_tests()` to CMake which searches over
the codebase and finds all the unit-tests written using Flow's TEST_CASE
macro and register as ctest.

The test then can be then run using ctest command or directly via Test
Explorer in VSCode.

* Fix some tests

* Use NetworkAddress

* Add another variant of call method

* Add a failed call test

* Refactor

* Cleanup shutdown

* Start working on streaming

* Implement server streaming

* Cleanup some unnecessary templating

* Cleanup some tests

* WIP Client Streaming

* WIP

* File Transfer WIP

* Remove UnitTest.h

* Take grpc addresses from command line

* startup grpc in fdbserver

* Cancel if future ref is 0

* noop

* Update some Cmake files

* Fix some build/run issues

* Review comments and remove file transfer

* Compile with gRPC present

* format

* Address review comments

* Add  assert

* fix FLOW_GRPC_ENABLED flag

* include grpc/proto headers for generated files

* fix arm build not finding generated proto

* add debug message for protobuf generation

* add generated dir again

* add check for protoc compiler
2024-12-10 20:56:59 -08:00