-
Notifications
You must be signed in to change notification settings - Fork 134
/
Copy pathcdcpb.proto
191 lines (157 loc) · 4.75 KB
/
cdcpb.proto
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
syntax = "proto3";
package cdcpb;
import "raft_cmdpb.proto";
import "metapb.proto";
import "errorpb.proto";
import "kvrpcpb.proto";
import "gogoproto/gogo.proto";
import "rustproto.proto";
option(gogoproto.sizer_all) = true;
option(gogoproto.marshaler_all) = true;
option(gogoproto.unmarshaler_all) = true;
option(rustproto.lite_runtime_all) = true;
option java_package = "org.tikv.kvproto";
message Header {
uint64 cluster_id = 1;
string ticdc_version = 2;
}
message DuplicateRequest {
uint64 region_id = 1;
}
message Compatibility {
string required_version = 1;
}
// ClusterIDMismatch is an error variable that
// tells people that the cluster ID of the request does not match the TiKV cluster ID.
message ClusterIDMismatch {
// The current tikv cluster ID.
uint64 current = 1;
// The cluster ID of the TiCDC request.
uint64 request = 2;
}
message Error {
errorpb.NotLeader not_leader = 1;
errorpb.RegionNotFound region_not_found = 2;
errorpb.EpochNotMatch epoch_not_match = 3;
DuplicateRequest duplicate_request = 4;
Compatibility compatibility = 5;
ClusterIDMismatch cluster_id_mismatch = 6;
errorpb.ServerIsBusy server_is_busy = 7;
}
message TxnInfo {
uint64 start_ts = 1;
bytes primary = 2;
}
message TxnStatus {
uint64 start_ts = 1;
uint64 min_commit_ts = 2;
uint64 commit_ts = 3;
bool is_rolled_back = 4;
}
message Event {
enum LogType {
UNKNOWN = 0;
PREWRITE = 1;
COMMIT = 2;
ROLLBACK = 3;
COMMITTED = 4;
INITIALIZED = 5;
}
message Row {
uint64 start_ts = 1;
uint64 commit_ts = 2;
LogType type = 3;
enum OpType {
UNKNOWN = 0;
PUT = 1;
DELETE = 2;
}
OpType op_type = 4;
bytes key = 5;
bytes value = 6;
bytes old_value = 7;
// expire_ts_unix_secs is used for RawKV (see `ChangeDataRequest.KvApi`),
// and represents the expiration time of this row.
// Absolute time, seconds since Unix epoch.
uint64 expire_ts_unix_secs = 8;
// The source of this row.
uint64 txn_source = 9;
}
message Entries {
repeated Row entries = 1;
}
message Admin {
raft_cmdpb.AdminRequest admin_request = 1;
raft_cmdpb.AdminResponse admin_response = 2;
}
message LongTxn {
repeated TxnInfo txn_info = 1;
}
uint64 region_id = 1;
uint64 index = 2;
uint64 request_id = 7;
oneof event {
Entries entries = 3;
Admin admin = 4;
Error error = 5;
uint64 resolved_ts = 6 [deprecated=true];
// Note that field 7 is taken by request_id.
LongTxn long_txn = 8;
// More region level events ...
}
}
// NOTE: events and resolved_ts won't appear simultaneously in one ChangeDataEvent.
message ChangeDataEvent {
repeated Event events = 1;
ResolvedTs resolved_ts = 2;
// More store level events ...
}
message ResolvedTs {
repeated uint64 regions = 1;
uint64 ts = 2;
uint64 request_id = 3;
}
message ChangeDataRequest {
message Register {}
message Deregister {}
message NotifyTxnStatus {
repeated TxnStatus txn_status = 1;
}
Header header = 1;
uint64 region_id = 2;
metapb.RegionEpoch region_epoch = 3;
uint64 checkpoint_ts = 4;
bytes start_key = 5;
bytes end_key = 6;
// Used for CDC to identify events corresponding to different requests.
// Generally in one call stream, a region can be subscribed multiple
// times with different `request_id`s.
uint64 request_id = 7;
kvrpcpb.ExtraOp extra_op = 8;
oneof request {
// A normal request that trying to register change data feed on a region.
Register register = 9;
// Notify the region that some of the running transactions on the region has a pushed
// min_commit_ts so that the resolved_ts can be advanced.
NotifyTxnStatus notify_txn_status = 10;
Deregister deregister = 13;
}
// KvAPI specifies to capture data written by different KV API.
// See more details in https://github.com/tikv/rfcs/blob/master/text/0069-api-v2.md.
enum KvAPI {
TiDB = 0;
RawKV = 1;
TxnKV = 2;
}
KvAPI kv_api = 11;
// Whether to filter out the value write by cdc itself.
bool filter_loop = 12;
}
service ChangeData {
rpc EventFeed(stream ChangeDataRequest) returns(stream ChangeDataEvent);
// EventFeedV2 is like EventFeed, with some new changes:
// * clients send requested features in HTTP/2 headers;
// * if servers meets unsupported feature request,
// it can fail the stream with an UNIMPLEMENTED error.
rpc EventFeedV2(stream ChangeDataRequest) returns (stream ChangeDataEvent);
}