Sentinel: more robust failover detection as observer.
Sentinel: more robust failover detection as observer.

Sentinel observers detect failover checking if a slave attached to the
monitored master turns into its replication state from slave to master.
However while this change may in theory only happen after a SLAVEOF NO
ONE command, in practie it is very easy to reboot a slave instance with
a wrong configuration that turns it into a master, especially if it was
a past master before a successfull failover.

This commit changes the detection policy so that if an instance goes
from slave to master, but at the same time the runid has changed, we
sense a reboot, and in that case we don't detect a failover at all.

This commit also introduces the "reboot" sentinel event, that is logged
at "warning" level (so this will trigger an admin notification).

The commit also fixes a problem in the disconnect handler that assumed
that the instance object always existed, that is not the case. Now we
no longer assume that redisAsyncFree() will call the disconnection
handler before returning.

riyan8250/redis,MSOpenTech/redis,0x20h/redis,hawkchch/redis,rrsean/redis-3.0-annotated,tidatida/annotated_redis_source,ksarch-saas/redis,cnbin/redis,cusspvz/redis,kmiku7/redis,tanghaodong25/redis,honestme/redis,zguangyu/redis,Hailei/redis,taoguan/redis,thomasdarimont/redis,pedigree/redis,RepmujNetsik/redis,roth1002/redis,soveran/redis,josiahcarlson/redis,oranagra/redis,ketor/redis,huyuezheng/redis,cnbin/redis,cloudrain21/redis,spinlock/redis,taoguan/redis,arijitvt/redis,pcarrier/redis,takeshineshiro/redis,oranagra/redis,Sciumo/redis,shreesundara/redis,GitHubMota/redis,PradheepShrinivasan/redis,PKRoma/redis,nnog/redis,xlzhan/redis,honestme/redis,pietern/redis,ChanningDuan/annotated_redis_source,pcarrier/redis,machicao2013/redis-source-annotated,kaushik94/redis,izhoujie/redis,AplayER/redis,MasahikoSawada/redis,jbochi/redis,seandsky/redis,abhiklodh/redis,jxwr/redis,mpalmer/redis,modulexcite/redis,CodeJuan/redis,taoguan/redis,hornen/redis,StevenTsai/redis,iandyh/redis,mumingv/redis-3.0-annotated,iandyh/redis,jbochi/parallel_redis,janekmi/redis,LongXQ/redis,ttuna/msot-redis,dreamquster/redis,valdsJohn/redis,brg-liuwei/redis,francischan714/redis,mingyaaaa/redis,jxwr/redis,splitice/redis,itugs/redis,dreamquster/redis,haima-zju/redis-3.0-annotated,himoca/redis,weizijun/redis,190235047/redis,july2993/redis,slfs007/mk-redis,netroby/redis,PKRoma/redis,ctripcorp/redis,tellapart/redis,fengshao0907/redis,rogerchina/redis,fengshao0907/redis-3.0-annotated,itugs/redis,yuhc/redis-benchmark-enhanced,davidradunz/redis,ErikDubbelboer/redis,weizijun/redis,fankeke/redis-3.0-annotated,yybirdcf/learn-redis,SummonY/redis,gspandy/annotated_redis_source,devaos/redis,wuxiaowei907/annotated_redis_source,huangz1990/redis-3.0-annotated,unasm/redis-3.0-annotated,wangyikai/redis,pmem/redis,wbailey5/redis,ipmobiletech/redis,j0hnma/hszredis,rrsean/redis-3.0-annotated,CodeJuan/redis,thomasdarimont/redis,mcanthony/redis,AALEKH/redis,MSOpenTech/redis,fengshao0907/redis,ctripcorp/redis,supasate/redis,HeartSaVioR/redis,antirez/redis,j0hnma/szredis,RepmujNetsik/redis,universsky/redis,Soledad89/redis,j0hnma/szredis,JoeWoo/redis,zhcy/redis,h0x91b/redis,cusspvz/redis,valdsJohn/redis,antirez/redis,linfangrong/redis,louisliangjun/redis,mattsta/redis,hedisdb/hedis,Aaron1992/redis,MSOpenTech/redis,weizijun/redis,harrisonfeng/redis,ncopa/redis,zguangyu/redis,neomantra/redis,ituncle/redis,OmarQunsul/graph-redis,wuyu201321060203/redis-3.0-annotated,louisliangjun/redis,ituncle/redis,viongpanzi/annotated_redis_source,huangz1990/annotated_redis_source,gilala/bjredis,fengshao0907/redis-3.0-annotated,kmiku7/redis,Hailei/redis,CodeJuan/redis,yuzhangjob/redis-3.0-annotated-unstable,saisai/redis,GitHubMota/redis,seppo0010/redis,takeshineshiro/redis,ramonsnir/redis,gilala/redis,csuhawk/redis,huyuezheng/redis,ytjiang/redis,soloestoy/redis,Hailei/redis,modulexcite/redis,hornen/redis,0x20h/redis,timothyohare/3rdPartySrc-redis,twskipper/redis,clamoriniere1A/redis,190235047/redis,MasahikoSawada/redis,netroby/redis,huyuezheng/redis,badboy/redis,davidradunz/redis,zhcy/redis,0x55/redis-3.0-annotated,nnog/redis,HunanTV/redis,SummonY/redis,july2993/redis,gilala/hredis,LongXQ/redis,nilyang/redis-tdd-annotation,PKRoma/redis,kaushik94/redis,shshlzh/redis-3.0-annotated,fankeke/redis-3.0-annotated,AALEKH/redis,zguangyu/redis,flashbuckets/redis,kaushik94/redis,PKRoma/redis,josiahcarlson/redis,seppo0010/rlite-server,narma/redis,SyntaxStacks/redis,zhiliaoniu/redis,OmarQunsul/graph-redis,holstvoogd/redis,timothyohare/3rdPartySrc-redis,pcarrier/redis,huangz1990/redis-3.0-annotated,sunlianqiang/redis-3.0-annotated,wujf/redis,tellapart/redis,figoxu/annotated_redis_source,HouKangkang/redis-3.0-annotated,darksideofthemoo/redis-histogram,Sciumo/redis,jackyan/redis,soloestoy/redis,aluzzardi/redis,ofirluzon/redis,h0x91b/redis,SummonY/redis,pedigree/redis,mengzhejin/RedisStudy,SyntaxStacks/redis,shining-yang/redis,shreesundara/redis,elkingtonmcb/redis,atreeyang/redis,zhiliaoniu/redis,magastzheng/redis-3.0-annotated,gilala/hbjredis,badboy/redis,Wangyao14cyy/redis,soloestoy/redis,jackyan/redis,rouzier/redis,splitice/redis,huangz1990/experiment-redis,clamoriniere1A/redis,gongice/redis-3.0-annotated,colstrom/redis,sunheehnus/redis,mengzhejin/RedisStudy,hgl888/redis,StevenTsai/redis,magastzheng/redis-3.0-annotated,z-fork/redis,idning/redis,tjschuck/redis,YongMan/redis,elkingtonmcb/redis,shreesundara/redis,soveran/redis,duanx/redis,mrb/redis,hhli/redis,jingjidejuren/redis,moonbingbing/redis-3.0-annotated,danny200309/annotated_redis_source,maodeyi/redis_lua,qiyang0221/redis,csuhawk/redis,seppo0010/rlite-server,danny200309/annotated_redis_source,ton31337/redis,OmarQunsul/graph-redis,guker/redis,zhoudayang/redis,Markgorden/redis,machicao2013/redis-source-annotated,StevenTsai/redis,ReadCode/redis-3.0-annotated,sunlianqiang/redis-3.0-annotated,spinlock/redis,mverrilli/redis,ctripcorp/redis,nilyang/redis-tdd-annotation,wuyu201321060203/redis-3.0-annotated,gilala/bjredis,neomantra/redis,aluzzardi/redis,tanghaodong25/redis,xuzhezhaozhao/redis_reading,shining-yang/redis,ChaosCoo/annotated_redis_source,GrimDerp/redis,splitice/redis,wbailey5/redis,kensou97/redis,duanx/redis,janekmi/redis,netroby/redis,citusdata/redis,whille/redis-3.0-annotated,hornen/redis,programmecat/redis,mverrilli/redis,OmarQunsul/graph-redis,twskipper/redis,jbochi/parallel_redis,badboy/redis,kensou97/redis,yossigo/redis,AplayER/redis,adamweixuan/redis-3.0-annotated,wprice/redis,hgl888/redis,msn217/redis-3.0-annotated,yossigo/redis,wenxueliu/redis_comment,blackmady/redis,gilala/redis,Wangyao14cyy/redis,viongpanzi/annotated_redis_source,darksideofthemoo/redis-histogram,fengshao0907/annotated_redis_source,healerkx/redis,buobao/redis-3.0-annotated,machicao2013/redis-source-annotated,fankeke/redis-3.0-annotated,yuhc/redis-benchmark-enhanced,MOON-CLJ/redis,louisliangjun/redis,idning/redis,shreesundara/redis,alenslan/redis,healerkx/redis,hgl888/redis,mengyou0304/redis,YuanZhewei/redis,ttuna/msot-redis,zy416548283/redis-3.0-annotated,shshlzh/redis-3.0-annotated,SyntaxStacks/redis,ytjiang/redis,davidradunz/redis,tzq668766/redis-3.0-annotated,gspandy/annotated_redis_source,ReadCode/redis-3.0-annotated,allengaller/redis,seppo0010/redis,colstrom/redis,gilala/redis,ncopa/redis,danny200309/annotated_redis_source,kensou97/redis,nnog/redis,brg-liuwei/redis,programmecat/redis,thomasdarimont/redis,onlymellb/redis-3.0-annotated,Cisphyx/redis-websockets,wenxueliu/redis_comment,z-fork/redis,hawkchch/redis,charsyam/redis,riyan8250/redis,xujunhai1991/redis,hedisdb/hedis,Aliceljm1/redis,rogerlz/redis,jermnelson/redis,mingyaaaa/redis,atreeyang/redis,haima-zju/redis-3.0-annotated,taoguan/redis,jasonkying/redis,Cisphyx/redis-websockets,davidradunz/redis,nilyang/redis-tdd-annotation,hgl888/redis,allengaller/redis,ChaosCoo/annotated_redis_source,devaos/redis,csuhawk/redis,pedigree/redis,moonbingbing/redis-3.0-annotated,vincent-vivian-liu/redis,drinkthere/redis-3.0-annotated,0x55/redis-3.0-annotated,mgk/redis,vincent-vivian-liu/redis,seppo0010/redis,blackmady/redis,drinkthere/redis-3.0-annotated,Aaron1992/redis,a-pavlov/redis,4396/redis,saisai/redis,badboy/redis,ErikDubbelboer/redis,programmecat/redis,ttuna/msot-redis,gaoxianglong/redis,ttuna/msot-redis,sunheehnus/redis,Aliceljm1/redis,josiahcarlson/redis,aluzzardi/redis,gilala/hredis,zguangyu/redis,j0hnma/szredis,zhiliaoniu/redis,ttuna/msot-redis,neomantra/redis,dayuoba/redis,cusspvz/redis,GrimDerp/redis,mingyaaaa/redis,colstrom/redis,msn217/redis-3.0-annotated,aluzzardi/redis,july2993/redis,HeartSaVioR/redis,seandsky/redis,slfs007/mk-redis,mattsta/redis,Aliceljm1/redis,ouyangkongtong/redis,zhcy/redis,ramonsnir/redis,hedisdb/hedis,magastzheng/redis-3.0-annotated,190235047/redis,nilyang/redis-tdd-annotation,roth1002/redis,charsyam/redis,clamoriniere1A/redis,mrb/redis,ipmobiletech/redis,linfangrong/redis,NBSW/redis,devaos/redis,ChanningDuan/annotated_redis_source,j0hnma/hszredis,dayuoba/redis,linfangrong/redis,mattsta/redis,xujunhai1991/redis,elkingtonmcb/redis,alenslan/redis,jasonkying/redis,mgk/redis,MSOpenTech/redis,janekmi/redis,seppo0010/rlite-server,wbailey5/redis,haima-zju/redis-3.0-annotated,francischan714/redis,cusspvz/redis,itugs/redis,Aliceljm1/redis-3.0-annotated,Hailei/redis,wangyikai/redis,xlzhan/redis,mcanthony/redis,dayuoba/redis,0x55/redis-3.0-annotated,harrisonfeng/redis,xuguruogu/redis,rogerchina/redis,maodeyi/redis_lua,hhli/redis,tanghaodong25/redis,wuyu201321060203/redis-3.0-annotated,spearhead-ea/redis,NBSW/redis,universsky/redis,YuanZhewei/redis,mverrilli/redis,izhoujie/redis,shining-yang/redis,flashbuckets/redis,tzq668766/redis-3.0-annotated,a-pavlov/redis,MasahikoSawada/redis,rouzier/redis,abhiklodh/redis,seppo0010/rlite-server,allengaller/redis,mumingv/redis-3.0-annotated,ouyangkongtong/redis,zhaobo1023/redis-3.0-annotated,xuguruogu/redis,HouKangkang/redis-3.0-annotated,francischan714/redis,gilala/bjredis,jacklee0810/annotated_redis_source,pietern/redis,huangz1990/redis-3.0-annotated,universsky/redis,yossigo/redis,190235047/redis,z-fork/redis,antirez/redis,darksideofthemoo/redis-histogram,riyan8250/redis,MOON-CLJ/redis,pmem/redis,zy416548283/redis-3.0-annotated,ChanningDuan/annotated_redis_source,mumingv/redis-3.0-annotated,4396/redis,idning/redis,onlymellb/redis-3.0-annotated,fengshao0907/redis,miaoyc1989/redis-3.0-annotated,holstvoogd/redis,gaoxianglong/redis,mrb/redis,spinlock/redis,Aaron1992/redis,mpalmer/redis,ErikDubbelboer/redis,figoxu/annotated_redis_source,NBSW/redis,duanx/redis,rogerchina/redis,mengyou0304/redis,zhaobo1023/redis-3.0-annotated,mumingv/redis,timothyohare/3rdPartySrc-redis,charsyam/redis,elkingtonmcb/redis,PKRoma/redis,wprice/redis,janekmi/redis,wuxiaowei907/annotated_redis_source,sunlianqiang/redis-3.0-annotated,itamarhaber/redis,WorkingOfTimtohyZhang/redis-3.0-annotated,ksarch-saas/redis,pkdevbox/redis,ton31337/redis,mumingv/redis,gilala/hbjredis,yybirdcf/learn-redis,nnog/redis,vincent-vivian-liu/redis,jermnelson/redis,healerkx/redis,dreamquster/redis,SummonY/redis,fengshao0907/redis-3.0-annotated,dayuoba/redis,yossigo/redis,WorkingOfTimtohyZhang/redis-3.0-annotated,pmem/redis,dramenk/annotated_redis_source,rogerlz/redis,narma/redis,kmiku7/redis,splitice/redis,machicao2013/redis-source-annotated,rrsean/redis-3.0-annotated,simplestbest/redis,wprice/redis,zczhuohuo/redis,supasate/redis,CodeJuan/redis,itamarhaber/redis,ErikDubbelboer/redis,RepmujNetsik/redis,ofirluzon/redis,mpalmer/redis,adamweixuan/redis-3.0-annotated,SyntaxStacks/redis,timothyohare/3rdPartySrc-redis,miaoyc1989/redis-3.0-annotated,hawkchch/redis,vincent-vivian-liu/redis,hhli/redis,takeshineshiro/redis,seandsky/redis,0x55/redis-3.0-annotated,jackyan/redis,hhli/redis,netroby/redis,a-pavlov/redis,gilala/redis,cnbin/redis,xlzhan/redis,qiyang0221/redis,simplestbest/redis,StevenTsai/redis,gilala/hredis,pmem/redis,4396/redis,a-pavlov/redis,gechong/redis-3.0-annotated,Markgorden/redis,cloudrain21/redis,aim-for-better/redis,gaoxianglong/redis,viongpanzi/annotated_redis_source,colstrom/redis,izhoujie/redis,YuanZhewei/redis,idning/redis,xuguruogu/redis,itamarhaber/redis,msn217/redis-3.0-annotated,figoxu/annotated_redis_source,flashbuckets/redis,GrimDerp/redis,citusdata/redis,neomantra/redis,LongXQ/redis,ton31337/redis,slfs007/mk-redis,kensou97/redis,JoeWoo/redis,0x20h/redis,Soledad89/redis,AALEKH/redis,alenslan/redis,jbochi/redis,pietern/redis,nuxeh/redis,huyuezheng/redis,wangyikai/redis,wenxueliu/redis_comment,shshlzh/redis-3.0-annotated,ytjiang/redis,RepmujNetsik/redis,rogerlz/redis,yybirdcf/learn-redis,harrisonfeng/redis,oranagra/redis,huangz1990/experiment-redis,j0hnma/hszredis,maodeyi/redis_lua,MSOpenTech/redis,charsyam/redis,gspandy/annotated_redis_source,YongMan/redis,dramenk/annotated_redis_source,antirez/redis,supasate/redis,simplestbest/redis,wujf/redis,tzq668766/redis-3.0-annotated,cnbin/redis,zczhuohuo/redis,ChaosCoo/annotated_redis_source,soloestoy/redis,rogerlz/redis,gechong/redis-3.0-annotated,Sciumo/redis,guker/redis,4396/redis,AplayER/redis,oranagra/redis,miaoyc1989/redis-3.0-annotated,YuraLukashik/redis,devaos/redis,AALEKH/redis,zhcy/redis,arijitvt/redis,jbochi/parallel_redis,rouzier/redis,dramenk/annotated_redis_source,pedigree/redis,ksarch-saas/redis,mumingv/redis,gilala/hbjredis,holstvoogd/redis,Aliceljm1/redis-3.0-annotated,ton31337/redis,YuraLukashik/redis,pkdevbox/redis,onlymellb/redis-3.0-annotated,JoeWoo/redis,adamweixuan/redis-3.0-annotated,pkdevbox/redis,dongqifan2/redis-3.0-annotated,jbochi/redis,h0x91b/redis,programmecat/redis,fengshao0907/redis,drinkthere/redis-3.0-annotated,YuraLukashik/redis,tellapart/redis,honestme/redis,zhiliaoniu/redis,ipmobiletech/redis,zczhuohuo/redis,tanghaodong25/redis,ncopa/redis,valdsJohn/redis,wangyikai/redis,tidatida/annotated_redis_source,rouzier/redis,qiyang0221/redis,gongice/redis-3.0-annotated,neomantra/redis,wujf/redis,arijitvt/redis,gilala/bjredis,himoca/redis,whille/redis-3.0-annotated,jacklee0810/annotated_redis_source,xuzhezhaozhao/redis_reading,mcanthony/redis,alenslan/redis,dongqifan2/redis-3.0-annotated,itugs/redis,ketor/redis,ituncle/redis,harrisonfeng/redis,mgk/redis,oranagra/redis,darksideofthemoo/redis-histogram,kmiku7/redis,soveran/redis,shshlzh/redis-3.0-annotated,huangz1990/experiment-redis,riyan8250/redis,duanx/redis,seppo0010/redis,Aliceljm1/redis,modulexcite/redis,universsky/redis,sunheehnus/redis,LongXQ/redis,buobao/redis-3.0-annotated,hawkchch/redis,mengyou0304/redis,yuzhangjob/redis-3.0-annotated-unstable,hedisdb/hedis,HunanTV/redis,francischan714/redis,gilala/hredis,twskipper/redis,WorkingOfTimtohyZhang/redis-3.0-annotated,huangz1990/annotated_redis_source,spearhead-ea/redis,supasate/redis,ofirluzon/redis,aim-for-better/redis,narma/redis,tellapart/redis,ofirluzon/redis,ituncle/redis,spearhead-ea/redis,blackmady/redis,wujf/redis,ketor/redis,mengyou0304/redis,tjschuck/redis,thomasdarimont/redis,HeartSaVioR/redis,unasm/redis-3.0-annotated,takeshineshiro/redis,valdsJohn/redis,linfangrong/redis,soloestoy/redis,pietern/redis,JoeWoo/redis,tjschuck/redis,ReadCode/redis-3.0-annotated,huangz1990/experiment-redis,seandsky/redis,honestme/redis,simplestbest/redis,fengshao0907/annotated_redis_source,j0hnma/hszredis,GitHubMota/redis,PradheepShrinivasan/redis,zczhuohuo/redis,flashbuckets/redis,jacklee0810/annotated_redis_source,xlzhan/redis,PradheepShrinivasan/redis,nuxeh/redis,louisliangjun/redis,xuguruogu/redis,hornen/redis,gongice/redis-3.0-annotated,ipmobiletech/redis,abhiklodh/redis,Soledad89/redis,iandyh/redis,roth1002/redis,jacklee0810/redis-3.0-annotated,ytjiang/redis,july2993/redis,xuzhezhaozhao/redis_reading,modulexcite/redis,yuhc/redis-benchmark-enhanced,Soledad89/redis,guker/redis,wbailey5/redis,nuxeh/redis,brg-liuwei/redis,yuzhangjob/redis-3.0-annotated-unstable,Markgorden/redis,jacklee0810/redis-3.0-annotated,healerkx/redis,gaoxianglong/redis,jasonkying/redis,jacklee0810/redis-3.0-annotated,tidatida/annotated_redis_source,abhiklodh/redis,holstvoogd/redis,blackmady/redis,mumingv/redis,jackyan/redis,jingjidejuren/redis,dreamquster/redis,mcanthony/redis,HunanTV/redis,Aliceljm1/redis-3.0-annotated,atreeyang/redis,zy416548283/redis-3.0-annotated,cloudrain21/redis,YuraLukashik/redis,Wangyao14cyy/redis,gechong/redis-3.0-annotated,ctripcorp/redis,jxwr/redis,jermnelson/redis,xujunhai1991/redis,ouyangkongtong/redis,jingjidejuren/redis,yuhc/redis-benchmark-enhanced,kaushik94/redis,mverrilli/redis,zhoudayang/redis,arijitvt/redis,wuyu201321060203/redis-3.0-annotated,pcarrier/redis,jingjidejuren/redis,charsyam/redis,guker/redis,Sciumo/redis,GitHubMota/redis,brg-liuwei/redis,Aaron1992/redis,izhoujie/redis,j0hnma/szredis,spinlock/redis,tjschuck/redis,wprice/redis,josiahcarlson/redis,ramonsnir/redis,weizijun/redis,z-fork/redis,citusdata/redis,himoca/redis,mingyaaaa/redis,Cisphyx/redis-websockets,mrb/redis,zhoudayang/redis,xujunhai1991/redis,Markgorden/redis,buobao/redis-3.0-annotated,clamoriniere1A/redis,cloudrain21/redis,h0x91b/redis,miaoyc1989/redis-3.0-annotated,allengaller/redis,dongqifan2/redis-3.0-annotated,atreeyang/redis,NBSW/redis,YongMan/redis,GrimDerp/redis,citusdata/redis,ofirluzon/redis,mengzhejin/RedisStudy,MasahikoSawada/redis,gilala/hbjredis,ncopa/redis,HeartSaVioR/redis,soveran/redis,PradheepShrinivasan/redis,unasm/redis-3.0-annotated,mpalmer/redis,yossigo/redis,YuanZhewei/redis,roth1002/redis,rogerchina/redis,moonbingbing/redis-3.0-annotated,mgk/redis,ksarch-saas/redis,pkdevbox/redis,Cisphyx/redis-websockets,yybirdcf/learn-redis,nuxeh/redis,aim-for-better/redis,aim-for-better/redis,saisai/redis,Wangyao14cyy/redis,whille/redis-3.0-annotated,xuzhezhaozhao/redis_reading,iandyh/redis,wenxueliu/redis_comment,fengshao0907/annotated_redis_source,HunanTV/redis,MOON-CLJ/redis,saisai/redis,HouKangkang/redis-3.0-annotated,wuxiaowei907/annotated_redis_source,zhaobo1023/redis-3.0-annotated,shining-yang/redis,ouyangkongtong/redis,csuhawk/redis,qiyang0221/redis,AplayER/redis,huangz1990/annotated_redis_source,jasonkying/redis,sunheehnus/redis,YongMan/redis,0x20h/redis,itamarhaber/redis,mengzhejin/RedisStudy,zhoudayang/redis,twskipper/redis