Debian Codegraph @

docs/api_reference/CXX/repconfig.html

raw symbols SCIP
1 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml">
4 <head>
5 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6 <title>DbEnv::rep_set_config()</title>
7 <link rel="stylesheet" href="apiReference.css" type="text/css" />
8 <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" />
9 <link rel="start" href="index.html" title="Berkeley DB C++ API Reference" />
10 <link rel="up" href="rep.html" title="Chapter 11.  Replication Methods" />
11 <link rel="prev" href="repclockskew.html" title="DbEnv::rep_set_clockskew()" />
12 <link rel="next" href="repset_limit.html" title="DbEnv::rep_set_limit()" />
13 </head>
14 <body>
15 <div xmlns="" class="navheader">
16 <div class="libver">
17 <p>Library Version 11.2.5.3</p>
18 </div>
19 <table width="100%" summary="Navigation header">
20 <tr>
21 <th colspan="3" align="center">DbEnv::rep_set_config()</th>
22 </tr>
23 <tr>
24 <td width="20%" align="left"><a accesskey="p" href="repclockskew.html">Prev</a> </td>
25 <th width="60%" align="center">Chapter 11. 
26 Replication Methods
27 </th>
28 <td width="20%" align="right"> <a accesskey="n" href="repset_limit.html">Next</a></td>
29 </tr>
30 </table>
31 <hr />
32 </div>
33 <div class="sect1" lang="en" xml:lang="en">
34 <div class="titlepage">
35 <div>
36 <div>
37 <h2 class="title" style="clear: both"><a id="repconfig"></a>DbEnv::rep_set_config()</h2>
38 </div>
39 </div>
40 </div>
41 <pre class="programlisting">#include &lt;db_cxx.h&gt;
42
43 int
44 DbEnv::rep_set_config(u_int32_t which, int onoff); </pre>
45 <p>
46 The <code class="methodname">DbEnv::rep_set_config()</code> method configures the Berkeley DB
47 replication subsystem.
48 </p>
49 <p>
50 The database environment's replication subsystem may also be
51 configured using the environment's <a href="../../programmer_reference/env_db_config.html#env_db_config.DB_CONFIG" class="olink">DB_CONFIG</a> file. The syntax
52 of the entry in that file is a single line with the string
53 "rep_set_config", one or more whitespace characters, and the
54 method <span class="bold"><strong>which</strong></span> parameter as a
55 string and optionally one or more whitespace characters, and the
56 string "on" or "off". If the optional string is omitted, the
57 default is "on"; for example, "rep_set_config DB_REP_CONF_NOWAIT"
58 or "rep_set_config DB_REP_CONF_NOWAIT on". Because the <a href="../../programmer_reference/env_db_config.html#env_db_config.DB_CONFIG" class="olink">DB_CONFIG</a>
59 file is read when the database environment is opened, it will
60 silently overrule configuration done before that time.
61 </p>
62 <p>
63 The <code class="methodname">DbEnv::rep_set_config()</code> method configures a database
64 environment, not only operations performed using the specified
65 <a class="link" href="env.html" title="Chapter 5.  The DbEnv Handle">DbEnv</a> handle.
66 </p>
67 <p>
68 The <code class="methodname">DbEnv::rep_set_config()</code> method may not be
69 called to set in-memory replication after the environment is
70 opened using the
71 <a class="xref" href="envopen.html" title="DbEnv::open()">DbEnv::open()</a> method.
72 This method may also not be called to set master leases after the
73 <a class="xref" href="repstart.html" title="DbEnv::rep_start()">DbEnv::rep_start()</a> or
74 <a class="xref" href="repmgrstart.html" title="DbEnv::repmgr_start()">DbEnv::repmgr_start()</a> methods
75 are called. For all other <span class="bold"><strong>which</strong></span>
76 parameters, this method may be called at any time during the life
77 of the application.
78 </p>
79 <p>
80 The <code class="methodname">DbEnv::rep_set_config()</code> <span>
81
82 <span>
83 method either returns a non-zero error value or throws an
84 exception that encapsulates a non-zero error value on
85 failure, and returns 0 on success.
86 </span>
87 </span>
88 </p>
89 <div class="sect2" lang="en" xml:lang="en">
90 <div class="titlepage">
91 <div>
92 <div>
93 <h3 class="title"><a id="idp9581200"></a>Parameters</h3>
94 </div>
95 </div>
96 </div>
97 <div class="sect3" lang="en" xml:lang="en">
98 <div class="titlepage">
99 <div>
100 <div>
101 <h4 class="title"><a id="idp9581896"></a>which</h4>
102 </div>
103 </div>
104 </div>
105 <p>
106 The <span class="bold"><strong>which</strong></span> parameter must be set to
107 one of the following values:
108 </p>
109 <div class="itemizedlist">
110 <ul type="disc">
111 <li>
112 <p><a id="config_DB_REP_CONF_AUTOINIT"></a>
113 <code class="literal">DB_REP_CONF_AUTOINIT</code>
114 </p>
115 <p>
116 The replication master will automatically re-initialize outdated
117 clients. This option is turned on by default.
118 </p>
119 </li>
120 <li>
121 <p><a id="config_DB_REP_CONF_BULK"></a>
122 <code class="literal">DB_REP_CONF_BULK</code>
123 </p>
124 <p>
125 The replication master sends groups of records to the clients in a
126 single network transfer.
127 </p>
128 </li>
129 <li>
130 <p><a id="config_DB_REP_CONF_DELAYCLIENT"></a>
131 <code class="literal">DB_REP_CONF_DELAYCLIENT</code>
132 </p>
133 <p>
134 The client should delay synchronizing to a newly declared master.
135 Clients configured in this way will remain
136 unsynchronized until the application calls the
137 <a class="xref" href="repsync.html" title="DbEnv::rep_sync()">DbEnv::rep_sync()</a> method.
138 </p>
139 </li>
140 <li>
141 <p><a id="config_DB_REP_CONF_INMEM"></a>
142 <code class="literal">DB_REP_CONF_INMEM</code>
143 </p>
144 <p>
145 Store internal replication information in memory only.
146 </p>
147 <p>
148 By default, replication creates files in the
149 environment home directory to preserve some
150 internal information. If this configuration flag is
151 turned on, replication only stores this internal
152 information in-memory and cannot keep persistent
153 state across a site crash or reboot. This results
154 in the following limitations:
155 </p>
156 <div class="itemizedlist">
157 <ul type="circle">
158 <li>
159 <p>
160 A master site should not reappoint itself
161 master immediately after crashing or
162 rebooting because the application would
163 incur a slightly higher risk of client
164 crashes. The former master site should
165 rejoin the replication group as a client.
166 The application should either hold an
167 election or appoint a different site to be
168 the next master.
169 </p>
170 </li>
171 <li>
172 <p>
173 An application has a slightly higher risk
174 that elections will fail or be unable to
175 complete. Calling additional elections
176 should eventually yield a winner.
177 </p>
178 </li>
179 <li>
180 <p>
181 An application has a slight risk that the
182 wrong site may win an election, resulting
183 in the loss of some data. This is
184 consistent with the general loss of data
185 durability when running in-memory.
186 </p>
187 </li>
188 <li>
189 <p>
190 Replication Manager applications will no
191 longer maintain group membership
192 information persistently on-disk. For more
193 information, see <a href="../../programmer_reference/rep_filename.html" class="olink">Managing Replication Files</a> in the
194 <em class="citetitle">Berkeley DB Programmer's Reference Guide</em>.
195 </p>
196 </li>
197 </ul>
198 </div>
199 <p>
200 This configuration flag can only be turned on
201 before the environment is opened with the
202 <a class="xref" href="envopen.html" title="DbEnv::open()">DbEnv::open()</a>
203 method. Its value cannot be changed while the
204 environment is open. All sites in the replication
205 group should have the same value for this
206 configuration flag.
207 </p>
208 </li>
209 <li>
210 <p>
211 <code class="literal">DB_REP_CONF_LEASE</code>
212 </p>
213 <p>
214 Master leases will be used for this site.
215 </p>
216 <p>
217 Configuring this option may result in
218 <code class="literal">DB_REP_LEASE_EXPIRED</code> error returns
219 from the <a class="xref" href="dbget.html" title="Db::get()">Db::get()</a> and
220 <a class="xref" href="dbcget.html" title="Dbc::get()">Dbc::get()</a> methods
221 when attempting to read entries from a database after the site's
222 master lease has expired.
223 </p>
224 <p>
225 This configuration flag may not be set after the
226 <a class="xref" href="repmgrstart.html" title="DbEnv::repmgr_start()">DbEnv::repmgr_start()</a> method or the
227 <a class="xref" href="repstart.html" title="DbEnv::rep_start()">DbEnv::rep_start()</a>
228 method is called. All sites in the replication
229 group should have the same value for this
230 configuration flag.
231 </p>
232 </li>
233 <li>
234 <p><a id="config_DB_REP_CONF_NOWAIT"></a>
235 <code class="literal">DB_REP_CONF_NOWAIT</code>
236 </p>
237 <p>
238 Berkeley DB method calls that would normally block while clients are
239 in recovery will return errors immediately.
240 </p>
241 </li>
242 <li>
243 <p><a id="config_DB_REPMGR_CONF_ELECTIONS"></a>
244 <code class="literal">DB_REPMGR_CONF_ELECTIONS</code>
245 </p>
246 <p>
247 Replication Manager automatically runs elections to
248 choose a new master when the old master appears to
249 have become disconnected. This option is turned on
250 by default.
251 </p>
252 <p>
253 If this option is turned off, the application is
254 responsible for assigning the new master
255 explicitly, by calling the
256 <code class="methodname">DB_ENV-&gt;repmgr_start()</code>
257 method.
258 </p>
259 <div class="caution" style="margin-left: 0.5in; margin-right: 0.5in;">
260 <h3 class="title">Caution</h3>
261 <p>
262 Most Replication Manager
263 applications should accept the default automatic
264 behavior. Allowing two sites in a replication
265 group to act as master simultaneously can lead to
266 loss of data.
267 </p>
268 </div>
269 <p>
270 In an application with multiple processes per
271 database environment, only the main replication
272 process may change this configuration setting.
273 </p>
274 </li>
275 <li>
276 <p><a id="config_DB_REPMGR_CONF_2SITE_STRICT"></a>
277 <code class="literal">DB_REPMGR_CONF_2SITE_STRICT</code>
278 </p>
279 <p>
280 Replication Manager observes the strict "majority" rule in managing
281 elections, even in a group with only 2 sites. This means the client
282 in a 2-site group will be unable to take over as master if the
283 original master fails or becomes disconnected. (See the
284 <a href="../../programmer_reference/rep_twosite.html" class="olink">
285 Special considerations for two-site replication groups
286 </a>
287 section in the <em class="citetitle">Berkeley DB Programmer's Reference Guide</em> for more information.)
288 Both sites in the replication group should have the same value for this
289 configuration flag. This option is turned on by
290 default.
291 </p>
292 </li>
293 </ul>
294 </div>
295 </div>
296 <div class="sect3" lang="en" xml:lang="en">
297 <div class="titlepage">
298 <div>
299 <div>
300 <h4 class="title"><a id="idp9607624"></a>onoff</h4>
301 </div>
302 </div>
303 </div>
304 <p>
305 If the <span class="bold"><strong>onoff</strong></span> parameter
306 is zero, the configuration flag is turned off.
307 Otherwise, it is turned on. Most configuration flags are
308 turned off by default, exceptions are noted above.
309 </p>
310 </div>
311 </div>
312 <div class="sect2" lang="en" xml:lang="en">
313 <div class="titlepage">
314 <div>
315 <div>
316 <h3 class="title"><a id="idp9586856"></a>Errors</h3>
317 </div>
318 </div>
319 </div>
320 <p>
321 The <code class="methodname">DbEnv::rep_set_config()</code> <span>
322
323 <span>
324 method may fail and throw a <a class="link" href="dbexception.html" title="Chapter 6. The DbException Class">DbException</a>
325 exception, encapsulating one of the following non-zero errors, or return one
326 of the following non-zero errors:
327 </span>
328 </span>
329 </p>
330 <div class="sect3" lang="en" xml:lang="en">
331 <div class="titlepage">
332 <div>
333 <div>
334 <h4 class="title"><a id="idp9604056"></a>EINVAL</h4>
335 </div>
336 </div>
337 </div>
338 <p>
339 If setting in-memory replication after the database environment is already
340 opened; if setting master leases after replication is started; if setting
341 the 2-site strict majority rule for a Base API application;
342 or if an invalid flag value or parameter was specified.
343 </p>
344 </div>
345 </div>
346 <div class="sect2" lang="en" xml:lang="en">
347 <div class="titlepage">
348 <div>
349 <div>
350 <h3 class="title"><a id="idp9620456"></a>Class</h3>
351 </div>
352 </div>
353 </div>
354 <p>
355 <a class="link" href="env.html" title="Chapter 5.  The DbEnv Handle">DbEnv</a>
356 </p>
357 </div>
358 <div class="sect2" lang="en" xml:lang="en">
359 <div class="titlepage">
360 <div>
361 <div>
362 <h3 class="title"><a id="idp9611272"></a>See Also</h3>
363 </div>
364 </div>
365 </div>
366 <p>
367 <a class="xref" href="rep.html#replist" title="Replication and Related Methods">Replication and Related Methods</a>
368 </p>
369 </div>
370 </div>
371 <div class="navfooter">
372 <hr />
373 <table width="100%" summary="Navigation footer">
374 <tr>
375 <td width="40%" align="left"><a accesskey="p" href="repclockskew.html">Prev</a> </td>
376 <td width="20%" align="center">
377 <a accesskey="u" href="rep.html">Up</a>
378 </td>
379 <td width="40%" align="right"> <a accesskey="n" href="repset_limit.html">Next</a></td>
380 </tr>
381 <tr>
382 <td width="40%" align="left" valign="top">DbEnv::rep_set_clockskew() </td>
383 <td width="20%" align="center">
384 <a accesskey="h" href="index.html">Home</a>
385 </td>
386 <td width="40%" align="right" valign="top"> DbEnv::rep_set_limit()</td>
387 </tr>
388 </table>
389 </div>
390 </body>
391 </html>