Skip to content

Commit

Permalink
Fix pre-handshake policy resolve refresh timeouts
Browse files Browse the repository at this point in the history
If an MO reference is added locally, the refresh timeout for that MO
is in most cases set to half the PRR, or 1 hour with the default timeout
values. If the Processor invokes the OpflexPool's sendToRole handler
before the peer has completed the identity request handshake, then the
OpflexPool won't send the message, and the MO's timeout is unchanged.
When the handshake does happen, the processor re-sends the policy
resolve requests for those MOs, but it doesn't update the timeouts
for those MOs. This can lead to excessive timeout values in some cases
(e.g. request gets rejected with an error, even if the error state is
short-lived).

This patch adds updates of the refresh time for the handshake
succeeded callback, in order to avoid the excessive timeout
described above.
  • Loading branch information
tbachman committed Jun 16, 2023
1 parent 9fbe5b1 commit fec9259
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
8 changes: 7 additions & 1 deletion libopflex/engine/Processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -733,15 +733,21 @@ OpflexHandler* Processor::newHandler(OpflexConnection* conn) {

void Processor::handleNewConnections() {
const std::lock_guard<std::mutex> lock(item_mutex);
obj_state_by_uri& uri_index = obj_state.get<uri_tag>();

for (const item& i : obj_state) {
uint64_t newexp = 0;
uint64_t newexp = i.expiration;
const ClassInfo& ci = store->getClassInfo(i.details->class_id);
obj_state_by_uri::iterator uit = uri_index.find(i.uri);
if (i.details->state == IN_SYNC) {
declareObj(ci.getType(), i, newexp);
}
if (i.details->state == RESOLVED) {
resolveObj(ci.getType(), i, newexp, false);
}
if (newexp != i.expiration) {
uri_index.modify(uit, Processor::change_expiration(newexp));
}
}
}

Expand Down
17 changes: 17 additions & 0 deletions libopflex/engine/test/Processor_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,23 @@ BOOST_FIXTURE_TEST_CASE( policy_resolve_flaky, PolicyFixture ) {
WAIT_FOR(opflexServer->getListener().applyConnPred(resolutions_pred, NULL), 1000);
}

// test policy resolve retry after connection ready
BOOST_FIXTURE_TEST_CASE( policy_resolve_retry, PolicyFixture ) {
opflexServer->getListener().applyConnPred(make_flaky_pred, NULL);
setup();
WAIT_FOR(processor.getRefCount(c4u) > 0, 1000);
WAIT_FOR(!processor.isObjNew(c5u), 1000);
startClient();
WAIT_FOR(connReady(processor.getPool(), LOCALHOST, 8009), 1000);

WAIT_FOR(itemPresent(client2, 4, c4u), 1000);
WAIT_FOR(itemPresent(client2, 6, c6u), 1000);
BOOST_CHECK_EQUAL("test", client2->get(4, c4u)->getString(9));
BOOST_CHECK_EQUAL("test2", client2->get(6, c6u)->getString(13));

WAIT_FOR(opflexServer->getListener().applyConnPred(resolutions_pred, NULL), 1000);
}

class StateFixture : public ServerFixture {
public:
StateFixture()
Expand Down

0 comments on commit fec9259

Please sign in to comment.