1 /*
2  * Knobs.h
3  *
4  * This source file is part of the FoundationDB open source project
5  *
6  * Copyright 2013-2018 Apple Inc. and the FoundationDB project authors
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *     http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 
21 #ifndef FDBCLIENT_KNOBS_H
22 #define FDBCLIENT_KNOBS_H
23 #pragma once
24 
25 #include "flow/Knobs.h"
26 #include "flow/flow.h"
27 
28 class ClientKnobs : public Knobs {
29 public:
30 	int BYTE_LIMIT_UNLIMITED;
31 	int ROW_LIMIT_UNLIMITED;
32 
33 	int TOO_MANY; // FIXME: this should really be split up so we can control these more specifically
34 
35 	double SYSTEM_MONITOR_INTERVAL;
36 
37 	double FAILURE_MAX_DELAY;
38 	double FAILURE_MIN_DELAY;
39 	double FAILURE_TIMEOUT_DELAY;
40 	double CLIENT_FAILURE_TIMEOUT_DELAY;
41 	double FAILURE_EMERGENCY_DELAY;
42 	double FAILURE_MAX_GENERATIONS;
43 
44 	// wrong_shard_server sometimes comes from the only nonfailed server, so we need to avoid a fast spin
45 	double WRONG_SHARD_SERVER_DELAY; // SOMEDAY: This delay can limit performance of retrieving data when the cache is mostly wrong (e.g. dumping the database after a test)
46 	double FUTURE_VERSION_RETRY_DELAY;
47 	int REPLY_BYTE_LIMIT;
48 	double DEFAULT_BACKOFF;
49 	double DEFAULT_MAX_BACKOFF;
50 	double BACKOFF_GROWTH_RATE;
51 	double RESOURCE_CONSTRAINED_MAX_BACKOFF;
52 	int PROXY_COMMIT_OVERHEAD_BYTES;
53 
54 	int64_t TRANSACTION_SIZE_LIMIT;
55 	int64_t KEY_SIZE_LIMIT;
56 	int64_t SYSTEM_KEY_SIZE_LIMIT;
57 	int64_t VALUE_SIZE_LIMIT;
58 	int64_t SPLIT_KEY_SIZE_LIMIT;
59 	int METADATA_VERSION_CACHE_SIZE;
60 
61 	int MAX_BATCH_SIZE;
62 	double GRV_BATCH_TIMEOUT;
63 	int BROADCAST_BATCH_SIZE;
64 
65 	// When locationCache in DatabaseContext gets to be this size, items will be evicted
66 	int LOCATION_CACHE_EVICTION_SIZE;
67 	int LOCATION_CACHE_EVICTION_SIZE_SIM;
68 
69 	int GET_RANGE_SHARD_LIMIT;
70 	int WARM_RANGE_SHARD_LIMIT;
71 	int STORAGE_METRICS_SHARD_LIMIT;
72 	double STORAGE_METRICS_UNFAIR_SPLIT_LIMIT;
73 	double STORAGE_METRICS_TOO_MANY_SHARDS_DELAY;
74 	double AGGREGATE_HEALTH_METRICS_MAX_STALENESS;
75 	double DETAILED_HEALTH_METRICS_MAX_STALENESS;
76 
77 	//KeyRangeMap
78 	int KRM_GET_RANGE_LIMIT;
79 	int KRM_GET_RANGE_LIMIT_BYTES; //This must be sufficiently larger than KEY_SIZE_LIMIT to ensure that at least two entries will be returned from an attempt to read a key range map
80 
81 	int DEFAULT_MAX_OUTSTANDING_WATCHES;
82 	int ABSOLUTE_MAX_WATCHES; //The client cannot set the max outstanding watches higher than this
83 	double WATCH_POLLING_TIME;
84 	double NO_RECENT_UPDATES_DURATION;
85 	double FAST_WATCH_TIMEOUT;
86 	double WATCH_TIMEOUT;
87 
88 	double IS_ACCEPTABLE_DELAY;
89 
90 
91 	// Core
92 	int64_t CORE_VERSIONSPERSECOND;  // This is defined within the server but used for knobs based on server value
93 	int LOG_RANGE_BLOCK_SIZE;
94 	int MUTATION_BLOCK_SIZE;
95 
96 	// Taskbucket
97 	int TASKBUCKET_MAX_PRIORITY;
98 	double TASKBUCKET_CHECK_TIMEOUT_CHANCE;
99 	double TASKBUCKET_TIMEOUT_JITTER_OFFSET;
100 	double TASKBUCKET_TIMEOUT_JITTER_RANGE;
101 	double TASKBUCKET_CHECK_ACTIVE_DELAY;
102 	int TASKBUCKET_CHECK_ACTIVE_AMOUNT;
103 	int TASKBUCKET_TIMEOUT_VERSIONS;
104 	int TASKBUCKET_MAX_TASK_KEYS;
105 
106 	// Backup
107 	int BACKUP_CONCURRENT_DELETES;
108 	int BACKUP_SIMULATED_LIMIT_BYTES;
109 	int BACKUP_GET_RANGE_LIMIT_BYTES;
110 	int BACKUP_LOCK_BYTES;
111 	double BACKUP_RANGE_TIMEOUT;
112 	double BACKUP_RANGE_MINWAIT;
113 	int BACKUP_SNAPSHOT_DISPATCH_INTERVAL_SEC;
114 	int BACKUP_DEFAULT_SNAPSHOT_INTERVAL_SEC;
115 	int BACKUP_SHARD_TASK_LIMIT;
116 	double BACKUP_AGGREGATE_POLL_RATE;
117 	double BACKUP_AGGREGATE_POLL_RATE_UPDATE_INTERVAL;
118 	int BACKUP_LOG_WRITE_BATCH_MAX_SIZE;
119 	int BACKUP_LOG_ATOMIC_OPS_SIZE;
120 	int BACKUP_MAX_LOG_RANGES;
121 	int BACKUP_SIM_COPY_LOG_RANGES;
122 	int BACKUP_OPERATION_COST_OVERHEAD;
123 	int BACKUP_VERSION_DELAY;
124 	int BACKUP_MAP_KEY_LOWER_LIMIT;
125 	int BACKUP_MAP_KEY_UPPER_LIMIT;
126 	int BACKUP_COPY_TASKS;
127 	int BACKUP_BLOCK_SIZE;
128 	int BACKUP_TASKS_PER_AGENT;
129 	int CLEAR_LOG_RANGE_COUNT;
130 	int SIM_BACKUP_TASKS_PER_AGENT;
131 	int BACKUP_RANGEFILE_BLOCK_SIZE;
132 	int BACKUP_LOGFILE_BLOCK_SIZE;
133 	int BACKUP_DISPATCH_ADDTASK_SIZE;
134 	int RESTORE_DISPATCH_ADDTASK_SIZE;
135 	int RESTORE_DISPATCH_BATCH_SIZE;
136 	int RESTORE_WRITE_TX_SIZE;
137 	int APPLY_MAX_LOCK_BYTES;
138 	int APPLY_MIN_LOCK_BYTES;
139 	int APPLY_BLOCK_SIZE;
140 	double APPLY_MAX_DECAY_RATE;
141 	double APPLY_MAX_INCREASE_FACTOR;
142 	double BACKUP_ERROR_DELAY;
143 	double BACKUP_STATUS_DELAY;
144 	double BACKUP_STATUS_JITTER;
145 
146 	// Configuration
147 	int32_t DEFAULT_AUTO_PROXIES;
148 	int32_t DEFAULT_AUTO_RESOLVERS;
149 	int32_t DEFAULT_AUTO_LOGS;
150 
151 	// Client Status Info
152 	double CSI_SAMPLING_PROBABILITY;
153 	int64_t CSI_SIZE_LIMIT;
154 	double CSI_STATUS_DELAY;
155 
156 	int HTTP_SEND_SIZE;
157 	int HTTP_READ_SIZE;
158 	int HTTP_VERBOSE_LEVEL;
159 	std::string HTTP_REQUEST_ID_HEADER;
160 	int BLOBSTORE_CONNECT_TRIES;
161 	int BLOBSTORE_CONNECT_TIMEOUT;
162 	int BLOBSTORE_MAX_CONNECTION_LIFE;
163 	int BLOBSTORE_REQUEST_TRIES;
164 	int BLOBSTORE_REQUEST_TIMEOUT;
165 	int BLOBSTORE_REQUESTS_PER_SECOND;
166 	int BLOBSTORE_LIST_REQUESTS_PER_SECOND;
167 	int BLOBSTORE_WRITE_REQUESTS_PER_SECOND;
168 	int BLOBSTORE_READ_REQUESTS_PER_SECOND;
169 	int BLOBSTORE_DELETE_REQUESTS_PER_SECOND;
170 	int BLOBSTORE_CONCURRENT_REQUESTS;
171 	int BLOBSTORE_MULTIPART_MAX_PART_SIZE;
172 	int BLOBSTORE_MULTIPART_MIN_PART_SIZE;
173 	int BLOBSTORE_CONCURRENT_UPLOADS;
174 	int BLOBSTORE_CONCURRENT_LISTS;
175 	int BLOBSTORE_CONCURRENT_WRITES_PER_FILE;
176 	int BLOBSTORE_CONCURRENT_READS_PER_FILE;
177 	int BLOBSTORE_READ_BLOCK_SIZE;
178 	int BLOBSTORE_READ_AHEAD_BLOCKS;
179 	int BLOBSTORE_READ_CACHE_BLOCKS_PER_FILE;
180 	int BLOBSTORE_MAX_SEND_BYTES_PER_SECOND;
181 	int BLOBSTORE_MAX_RECV_BYTES_PER_SECOND;
182 
183 	int CONSISTENCY_CHECK_RATE_LIMIT_MAX;
184 	int CONSISTENCY_CHECK_ONE_ROUND_TARGET_COMPLETION_TIME;
185 	int CONSISTENCY_CHECK_RATE_WINDOW;
186 
187 	// TLS related
188 	int CHECK_CONNECTED_COORDINATOR_NUM_DELAY;
189 
190 	ClientKnobs(bool randomize = false);
191 };
192 
193 extern ClientKnobs const* CLIENT_KNOBS;
194 
195 #endif
196