Skip to content

Commit

Permalink
Merge remote-tracking branch 'couchbase/unstable' into HEAD
Browse files Browse the repository at this point in the history
http: //ci-eventing.northscale.in/eventing-08.07.2020-16.19.pass.html
Change-Id: I3a5896b4881e11bd8c01d5541212face13af46e8
  • Loading branch information
jeelanp2003 committed Jul 9, 2020
2 parents 352a617 + 3cbb7f3 commit f420cff
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 13 deletions.
5 changes: 5 additions & 0 deletions features/include/lcb_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ void DeleteCallback(lcb_t instance, int cbtype, const lcb_RESPBASE *rb);

void counter_callback(lcb_t instance, int cbtype, const lcb_RESPBASE *rb);

void unlock_callback(lcb_t instance, int cbtype, const lcb_RESPBASE *rb);

std::pair<lcb_error_t, Result> LcbGet(lcb_t instance, lcb_CMDGET &cmd);

std::pair<lcb_error_t, Result> LcbSet(lcb_t instance, lcb_CMDSTORE &cmd);
Expand All @@ -65,6 +67,9 @@ std::pair<lcb_error_t, Result> LcbSubdocDelete(lcb_t instance,
std::pair<lcb_error_t, Result> LcbGetCounter(lcb_t instance,
lcb_CMDCOUNTER &cmd);

std::pair<lcb_error_t, Result> LcbUnlock(lcb_t instance,
lcb_CMDUNLOCK &cmd);

bool IsRetriable(lcb_error_t error);

template <typename CmdType, typename Callable>
Expand Down
28 changes: 28 additions & 0 deletions features/src/lcb_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,16 @@ void counter_callback(lcb_t instance, int cbtype, const lcb_RESPBASE *rb) {
<< lcb_strerror(nullptr, result->rc) << std::endl;
}

void unlock_callback(lcb_t instance, int cbtype, const lcb_RESPBASE *rb) {
auto result = reinterpret_cast<Result *>(rb->cookie);
result->rc = rb->rc;

if (rb->rc == LCB_PROTOCOL_ERROR) {
LOG(logError) << "Bucket: LCB_UNLOCK breaking out" << std::endl;
lcb_breakout(instance);
}
}

std::pair<lcb_error_t, Result> LcbGet(lcb_t instance, lcb_CMDGET &cmd) {
Result result;
auto err = lcb_get3(instance, &result, &cmd);
Expand Down Expand Up @@ -313,6 +323,24 @@ std::pair<lcb_error_t, Result> LcbGetCounter(lcb_t instance,
return {err, result};
}

std::pair<lcb_error_t, Result> LcbUnlock(lcb_t instance,
lcb_CMDUNLOCK &cmd) {
Result result;
auto err = lcb_unlock3(instance, &result, &cmd);
if (err != LCB_SUCCESS) {
LOG(logTrace) << "Bucket: Unable to set params for LCB_UNLOCK: "
<< lcb_strerror(instance, err) << std::endl;
return {err, result};
}

err = lcb_wait(instance);
if (err != LCB_SUCCESS) {
LOG(logTrace) << "Bucket: Unable to schedule LCB_UNLOCK: "
<< lcb_strerror(instance, err) << std::endl;
}
return {err, result};
}

bool IsRetriable(lcb_error_t error) {
return static_cast<bool>(LCB_EIFTMP(error));
}
Expand Down
21 changes: 8 additions & 13 deletions service_manager/http_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -1622,7 +1622,7 @@ func (m *ServiceMgr) saveTempStoreHandler(w http.ResponseWriter, r *http.Request
}

info := m.saveTempStore(app)
m.sendErrorInfo(w, info)
m.sendRuntimeInfo(w, info)
}

// Saves application to temp store
Expand Down Expand Up @@ -2627,6 +2627,7 @@ func (m *ServiceMgr) functionsHandler(w http.ResponseWriter, r *http.Request) {
info.Code = m.statusCodes.errInvalidConfig.Code
info.Info = fmt.Sprintf("Only POST call allowed to this endpoint")
m.sendErrorInfo(w, info)
return
}
appName := match[1]

Expand Down Expand Up @@ -2657,6 +2658,7 @@ func (m *ServiceMgr) functionsHandler(w http.ResponseWriter, r *http.Request) {
info.Code = m.statusCodes.errInvalidConfig.Code
info.Info = fmt.Sprintf("Only POST call allowed to this endpoint")
m.sendErrorInfo(w, info)
return
}
appName := match[1]

Expand Down Expand Up @@ -2687,6 +2689,7 @@ func (m *ServiceMgr) functionsHandler(w http.ResponseWriter, r *http.Request) {
info.Code = m.statusCodes.errInvalidConfig.Code
info.Info = fmt.Sprintf("Only POST call allowed to this endpoint")
m.sendErrorInfo(w, info)
return
}
appName := match[1]

Expand Down Expand Up @@ -2736,6 +2739,7 @@ func (m *ServiceMgr) functionsHandler(w http.ResponseWriter, r *http.Request) {
info.Code = m.statusCodes.errInvalidConfig.Code
info.Info = fmt.Sprintf("Only POST call allowed to this endpoint")
m.sendErrorInfo(w, info)
return
}
appName := match[1]

Expand Down Expand Up @@ -2852,27 +2856,19 @@ func (m *ServiceMgr) functionsHandler(w http.ResponseWriter, r *http.Request) {
m.sendErrorInfo(w, tempInfo)
return
}
m.sendRuntimeInfo(w, runtimeInfo)
} else {
m.sendErrorInfo(w, runtimeInfo)
}
m.sendRuntimeInfo(w, runtimeInfo)

case "DELETE":
audit.Log(auditevent.DeleteFunction, r, appName)

info := m.deletePrimaryStore(appName)
// Delete the application from temp store only if app does not exist in primary store
// or if the deletion succeeds on primary store
if info.Code == m.statusCodes.errAppNotDeployed.Code || info.Code == m.statusCodes.ok.Code {
audit.Log(auditevent.DeleteDrafts, r, appName)

if runtimeInfo := m.deleteTempStore(appName); runtimeInfo.Code != m.statusCodes.ok.Code {
m.sendErrorInfo(w, runtimeInfo)
return
}
} else {
m.sendErrorInfo(w, info)
info = m.deleteTempStore(appName)
}
m.sendRuntimeInfo(w, info)

default:
w.WriteHeader(http.StatusMethodNotAllowed)
Expand Down Expand Up @@ -2918,7 +2914,6 @@ func (m *ServiceMgr) functionsHandler(w http.ResponseWriter, r *http.Request) {
}
infoList = append(infoList, info)
}

m.sendRuntimeInfoList(w, infoList)

default:
Expand Down
4 changes: 4 additions & 0 deletions v8_consumer/include/timer_store.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ class TimerStore {
std::pair<lcb_error_t, Result> Get(const std::string &key,
int max_retry_count, uint32_t max_retry_secs);

std::pair<lcb_error_t, Result> Lock(const std::string &key, int max_retry_count,
uint32_t max_retry_secs, uint32_t max_lock_time);
std::pair<lcb_error_t, Result> Unlock(const std::string &key, int max_retry_count,
uint32_t max_retry_secs, lcb_CAS cas);
v8::Isolate *isolate_;
std::vector<bool> partitons_;
std::unordered_map<int64_t, TimerSpan> span_map_;
Expand Down

0 comments on commit f420cff

Please sign in to comment.