| 444 | |
| 445 | |
| 446 | void GroupProcess::reconnecting(int64_t sessionId) |
| 447 | { |
| 448 | if (error.isSome() || sessionId != zk->getSessionId()) { |
| 449 | return; |
| 450 | } |
| 451 | |
| 452 | LOG(INFO) << "Lost connection to ZooKeeper, attempting to reconnect ..."; |
| 453 | |
| 454 | // Set 'retrying' to false to prevent retry() from executing sync() |
| 455 | // before the group reconnects to ZooKeeper. The group will sync |
| 456 | // with ZooKeeper after it is connected. |
| 457 | retrying = false; |
| 458 | |
| 459 | // ZooKeeper won't tell us of a session expiration until we |
| 460 | // reconnect, which could occur much much later than the session was |
| 461 | // actually expired. This can lead to a prolonged split-brain |
| 462 | // scenario when network partitions occur. Rather than wait for a |
| 463 | // reconnection to occur (i.e., a network partition to be repaired) |
| 464 | // we create a local timer and "expire" our session prematurely if |
| 465 | // we haven't reconnected within the session expiration time out. |
| 466 | // The timer can be reset if the connection is restored. |
| 467 | |
| 468 | // We expect to see exactly one `reconnecting` event when our |
| 469 | // session is disconnected, even if we're disconnected for an |
| 470 | // extended period. Since we clear the `connectTimer` when the |
| 471 | // connection is established, it should still be unset here. |
| 472 | CHECK_NONE(connectTimer); |
| 473 | |
| 474 | // Use the negotiated session timeout for the connect timer. |
| 475 | connectTimer = delay(zk->getSessionTimeout(), |
| 476 | self(), |
| 477 | &Self::timedout, |
| 478 | zk->getSessionId()); |
| 479 | } |
| 480 | |
| 481 | |
| 482 | void GroupProcess::timedout(int64_t sessionId) |
nothing calls this directly
no test coverage detected