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. */
| 699 | * replication backlog and show a few final bytes to make simpler to |
| 700 | * guess what kind of bug it could be. */ |
| 701 | void showLatestBacklog(void) { |
| 702 | if (g_pserver->repl_backlog == NULL) return; |
| 703 | |
| 704 | long long dumplen = 256; |
| 705 | if (g_pserver->repl_backlog_histlen < dumplen) |
| 706 | dumplen = g_pserver->repl_backlog_histlen; |
| 707 | |
| 708 | /* Identify the first byte to dump. */ |
| 709 | long long idx = |
| 710 | (g_pserver->repl_backlog_idx + (g_pserver->repl_backlog_size - dumplen)) % |
| 711 | g_pserver->repl_backlog_size; |
| 712 | |
| 713 | /* Scan the circular buffer to collect 'dumplen' bytes. */ |
| 714 | sds dump = sdsempty(); |
| 715 | while(dumplen) { |
| 716 | long long thislen = |
| 717 | ((g_pserver->repl_backlog_size - idx) < dumplen) ? |
| 718 | (g_pserver->repl_backlog_size - idx) : dumplen; |
| 719 | |
| 720 | dump = sdscatrepr(dump,g_pserver->repl_backlog+idx,thislen); |
| 721 | dumplen -= thislen; |
| 722 | idx = 0; |
| 723 | } |
| 724 | |
| 725 | /* Finally log such bytes: this is vital debugging info to |
| 726 | * understand what happened. */ |
| 727 | serverLog(LL_WARNING,"Latest backlog is: '%s'", dump); |
| 728 | sdsfree(dump); |
| 729 | } |
| 730 | |
| 731 | /* This function is used in order to proxy what we receive from our master |
| 732 | * to our sub-slaves. */ |
no test coverage detected