|
277 | 277 | //! &mut cache_config_1,
|
278 | 278 | //! // optional notification channel: `Option<mpsc::Sender<CacheNotify>>`
|
279 | 279 | //! None,
|
280 |
| -//! // We need to overwrite the hostname so we can start all nodes on the same host for this |
| 280 | +//! // We need to overwrite the hostname, so we can start all nodes on the same host for this |
281 | 281 | //! // example. Usually, this will be set to `None`
|
282 | 282 | //! Some("127.0.0.1:7001".to_string()),
|
283 | 283 | //! )
|
284 | 284 | //! .await?;
|
| 285 | +//! time::sleep(Duration::from_millis(100)).await; |
285 | 286 | //! println!("First cache node started");
|
286 | 287 | //!
|
287 | 288 | //! // Mimic the other 2 cache members. This should usually not be done in the same code - only
|
|
295 | 296 | //! Some("127.0.0.1:7002".to_string()),
|
296 | 297 | //! )
|
297 | 298 | //! .await?;
|
| 299 | +//! time::sleep(Duration::from_millis(100)).await; |
298 | 300 | //! println!("2nd cache node started");
|
299 | 301 | //! // Now after the 2nd cache member has been started, we would already have quorum and a
|
300 | 302 | //! // working cache layer. As long as there is no leader and / or quorum, the cache will not
|
|
309 | 311 | //! Some("127.0.0.1:7003".to_string()),
|
310 | 312 | //! )
|
311 | 313 | //! .await?;
|
| 314 | +//! time::sleep(Duration::from_millis(100)).await; |
312 | 315 | //! println!("3rd cache node started");
|
313 | 316 | //!
|
314 | 317 | //! // For the sake of this example again, we need to wait until the cache is in a healthy
|
@@ -1004,12 +1007,12 @@ pub(crate) async fn insert_from_leader(
|
1004 | 1007 | };
|
1005 | 1008 |
|
1006 | 1009 | // double check, that we are really the leader
|
1007 |
| - // this might get removed after enough testing, if it provides a performance benefit |
1008 | 1010 | if health_state.state != QuorumState::Leader && health_state.state != QuorumState::LeaderSwitch
|
1009 | 1011 | {
|
1010 |
| - let error = "Execution of 'insert_from_leader' is not allowed on a non-leader".to_string(); |
1011 |
| - warn!("is_leader state: {:?}", health_state.state); |
1012 |
| - // TODO remove this panic after testing |
| 1012 | + let error = format!("Execution of 'insert_from_leader' is not allowed on a non-leader: {:?}", health_state.state); |
| 1013 | + error!("{}", error); |
| 1014 | + // TODO we once ended up here during conflict resolution -> try to reproduce |
| 1015 | + // rather panic than have an inconsistent state |
1013 | 1016 | panic!("{}", error);
|
1014 | 1017 | }
|
1015 | 1018 |
|
|
0 commit comments