Skip to content

Commit 9a9ed8d

Browse files
committed
CCBC-1612: refresh configuration on errors when faster failover is enabled
Try to refresh configuration in case of network errors to speed up the recovery process during failover. Change-Id: Ieead623872105dc8660d492159f712475be45bff Reviewed-on: https://review.couchbase.org/c/libcouchbase/+/197340 Reviewed-by: Jared Casey <[email protected]> Tested-by: Build Bot <[email protected]>
1 parent 429e1d2 commit 9a9ed8d

File tree

8 files changed

+16
-14
lines changed

8 files changed

+16
-14
lines changed

src/bootstrap.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ lcb_STATUS Bootstrap::bootstrap(unsigned options)
295295
last_refresh = now;
296296
}
297297
if (parent->settings->bucket) {
298-
options &= BS_REFRESH_OPEN_BUCKET;
298+
options |= BS_REFRESH_OPEN_BUCKET;
299299
}
300300
parent->confmon->start(options);
301301
return LCB_SUCCESS;

src/bucketconfig/bc_cccp.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ struct CccpProvider : public Provider {
6767
void configure_nodes(const lcb::Hostlist &) override;
6868
void config_updated(lcbvb_CONFIG *) override;
6969
void dump(FILE *) const override;
70-
lcb_STATUS refresh() override;
70+
lcb_STATUS refresh(unsigned options = 0) override;
7171

7272
ConfigInfo *get_cached() override
7373
{
@@ -430,13 +430,14 @@ static void on_connected(lcbio_SOCKET *sock, void *data, lcb_STATUS err, lcbio_O
430430
cccp->request_config();
431431
}
432432

433-
lcb_STATUS CccpProvider::refresh()
433+
lcb_STATUS CccpProvider::refresh(unsigned options)
434434
{
435435
if (has_pending_request()) {
436436
return LCB_ERR_BUSY;
437437
}
438438

439-
return schedule_next_request(LCB_SUCCESS, /* can_rollover */ true, /* skip_if_push_supported */ true);
439+
return schedule_next_request(LCB_SUCCESS, /* can_rollover */ true,
440+
/* skip_if_push_supported */ (options & lcb::BS_REFRESH_INCRERR) == 0);
440441
}
441442

442443
bool CccpProvider::pause()

src/bucketconfig/bc_file.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ struct FileProvider : Provider, Listener {
4949

5050
/* Overrides */
5151
ConfigInfo *get_cached() override;
52-
lcb_STATUS refresh() override;
52+
lcb_STATUS refresh(unsigned options = 0) override;
5353
void dump(FILE *) const override;
5454
void clconfig_lsn(EventType, ConfigInfo *) override;
5555

@@ -197,7 +197,7 @@ void FileProvider::reload_cache()
197197
}
198198
}
199199

200-
lcb_STATUS FileProvider::refresh()
200+
lcb_STATUS FileProvider::refresh(unsigned /* options */)
201201
{
202202
if (!timer.is_armed()) {
203203
timer.signal();

src/bucketconfig/bc_http.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ bool HttpProvider::pause()
403403
return LCB_SUCCESS;
404404
}
405405

406-
lcb_STATUS HttpProvider::refresh()
406+
lcb_STATUS HttpProvider::refresh(unsigned /* options */)
407407
{
408408
/**
409409
* We want a grace interval here because we might already be fetching a

src/bucketconfig/bc_http.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ struct HttpProvider : Provider {
6363

6464
/* Overrides */
6565
bool pause() override;
66-
lcb_STATUS refresh() override;
66+
lcb_STATUS refresh(unsigned options = 0) override;
6767
ConfigInfo *get_cached() override;
6868
void config_updated(lcbvb_CONFIG *) override;
6969
void configure_nodes(const lcb::Hostlist &) override;

src/bucketconfig/bc_static.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ class StaticProvider : public Provider
4949
return config;
5050
}
5151

52-
lcb_STATUS refresh() override
52+
lcb_STATUS refresh(unsigned options = 0) override
5353
{
54+
(void)options;
5455
async.signal();
5556
return LCB_SUCCESS;
5657
}

src/bucketconfig/clconfig.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ struct Confmon {
239239
* @see #stop()
240240
* @see #is_refreshing()
241241
*/
242-
void start(bool refresh = false);
242+
void start(unsigned options = 0);
243243

244244
/**
245245
* @brief Cancel a pending configuration refresh.
@@ -450,7 +450,7 @@ struct Provider {
450450
* should implement a timeout mechanism of its choice to promptly deliver
451451
* a success or failure.
452452
*/
453-
virtual lcb_STATUS refresh() = 0;
453+
virtual lcb_STATUS refresh(unsigned options = 0) = 0;
454454

455455
/**
456456
* Callback invoked to the provider to indicate that it should cease

src/bucketconfig/confmon.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ void Confmon::do_next_provider()
306306
cur_provider->refresh();
307307
}
308308

309-
void Confmon::start(bool refresh)
309+
void Confmon::start(unsigned options)
310310
{
311311
lcb_U32 tmonext = 0;
312312
as_stop.cancel();
@@ -325,10 +325,10 @@ void Confmon::start(bool refresh)
325325
}
326326
}
327327

328-
if (refresh) {
328+
if (options) {
329329
lcb_log(LOGARGS(this, TRACE), "Refreshing current cluster map (bucket: \"%s\"), next update in %dus",
330330
settings->bucket, tmonext);
331-
cur_provider->refresh();
331+
cur_provider->refresh(options);
332332
}
333333
as_start.rearm(tmonext);
334334
}

0 commit comments

Comments
 (0)