You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 20, 2023. It is now read-only.
Copy file name to clipboardExpand all lines: src/network/README.md
+24-18Lines changed: 24 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,31 @@
1
1
# Networking
2
2
3
3
## Overview
4
-
A prototype implementation of the Postgres network protocol in C++ in order to support communication with Postgres shell clients with Terrier.
4
+
A prototype implementation of the Postgres network protocol in C++ in order to support communication with Postgres shell clients (psql) with NoisePage.
5
+
6
+
## Description
7
+
8
+
- Expected callee: `DBMain`
9
+
- Entry point of the network layer: `NoisePageServer::RunServer()` in `noisepage_server.h`
10
+
-`NoisePageServer::RunServer()` will:
11
+
1. Create a `ConnectionDispatcherTask` (CDT) with a specified `ProtocolInterpreter` and a list of file descriptors.
12
+
Each file descriptor is registered with `libevent` to invoke a callback `connection_dispatcher_fn` whenever
13
+
the respective file descriptor becomes readable. The `ProtocolInterpreter` is saved for later use.
14
+
When the CDT is run, a pool of `ConnectionHandlerTask` (CHT) threads are created.
15
+
2. When a file descriptor `fd` becomes readable, the descriptor is dispatched from the CDT to an idle CHT with the `ProtocolInterpreter` from above.
16
+
3. The CHT creates (or reuses) a new `ConnectionHandle` (CH) to handle `fd` and invokes `ConnectionHandle::RegisterToReceiveEvents()`.
17
+
4. The CH makes a `NetworkIOWrapper` around `fd` and registers two events:
18
+
-`workpool_event_`: DOESN'T DO ANYTHING RIGHT NOW. Originally envisioned for future callback support.
19
+
-`network_event_`: Handle transitions through the state machine of the `ProtocolInterpreter`, which is currently always `PostgresProtocolInterpreter`. See footnote A1.
20
+
5. It is through `ProtocolInterpreter::Process()` that control flow proceeds to the next layer of the system.
21
+
An example is `PostgresProtocolInterpreter::Process() -> SimpleQueryCommand::Exec()`, which goes through the
22
+
`TrafficCop` before returning control flow to the `PostgresProtocolInterpreter`.
23
+
24
+
**Footnote A1.**
25
+
It was envisioned that the internal Terrier protocol (ITP) would use the same network state machine as Postgres does.
26
+
However, the `Messenger` system serves this purpose instead. This is because it does not necessarily make sense for
27
+
an internal communication protocol to have the same `TryRead`, `TryWrite`, etc., that the Postgres connection handler does.
5
28
6
-
## Scope
7
-
>Which parts of the system will this feature rely on or modify? Write down specifics so people involved can review the design doc
8
29
9
30
## Glossary
10
31
@@ -26,18 +47,3 @@ A prototype implementation of the Postgres network protocol in C++ in order to s
26
47
* RowDescription (T)
27
48
* DataRow (D)
28
49
* CommandComplete (C)
29
-
30
-
## Architectural Design
31
-
>Explain the input and output of the component, describe interactions and breakdown the smaller components if any. Include diagrams if appropriate.
32
-
33
-
## Design Rationale
34
-
>Explain the goals of this design and how the design achieves these goals. Present alternatives considered and document why they are not chosen.
35
-
36
-
## Testing Plan
37
-
Unit testing of basic command handling is provided by `test/network/network_test.cpp`. More complete test coverage will be handled by the Junit integration tests.
38
-
39
-
## Trade-offs and Potential Problems
40
-
>Write down any conscious trade-off you made that can be problematic in the future, or any problems discovered during the design process that remain unaddressed (technical debts).
41
-
42
-
## Future Work
43
-
- Support internal protocol for server-to-server communications
0 commit comments