This is a debugging function that gets called when we detect something * wrong with the replication protocol: the goal is to peek into the * replication backlog and show a few final bytes to make simpler to * guess what kind of bug it could be. */
| 320 | * replication backlog and show a few final bytes to make simpler to |
| 321 | * guess what kind of bug it could be. */ |
| 322 | void showLatestBacklog(void) { |
| 323 | if (server.repl_backlog == NULL) return; |
| 324 | |
| 325 | long long dumplen = 256; |
| 326 | if (server.repl_backlog_histlen < dumplen) |
| 327 | dumplen = server.repl_backlog_histlen; |
| 328 | |
| 329 | /* Identify the first byte to dump. */ |
| 330 | long long idx = |
| 331 | (server.repl_backlog_idx + (server.repl_backlog_size - dumplen)) % |
| 332 | server.repl_backlog_size; |
| 333 | |
| 334 | /* Scan the circular buffer to collect 'dumplen' bytes. */ |
| 335 | sds dump = sdsempty(); |
| 336 | while(dumplen) { |
| 337 | long long thislen = |
| 338 | ((server.repl_backlog_size - idx) < dumplen) ? |
| 339 | (server.repl_backlog_size - idx) : dumplen; |
| 340 | |
| 341 | dump = sdscatrepr(dump,server.repl_backlog+idx,thislen); |
| 342 | dumplen -= thislen; |
| 343 | idx = 0; |
| 344 | } |
| 345 | |
| 346 | /* Finally log such bytes: this is vital debugging info to |
| 347 | * understand what happened. */ |
| 348 | serverLog(LL_WARNING,"Latest backlog is: '%s'", dump); |
| 349 | sdsfree(dump); |
| 350 | } |
| 351 | |
| 352 | /* This function is used in order to proxy what we receive from our master |
| 353 | * to our sub-slaves. */ |
no test coverage detected