CEPH - messenger rebind race
A message that is not in the archive (sent off-list or not yet received): [email protected]
[CCing Greg and ceph-devel]
Quoted 17 lines · Guang Yang
Hi Sage,
Sorry to bother you directly, I am debugging / fixing issue
http://tracker.ceph.com/issues/8232, during which time I studied the messenger component of CEPH. With more understanding of the messenger component, I started getting confused by the fix of issue 6992
(http://tracker.ceph.com/issues/6992) in terms of how it could help to solve the problem (though I fully agree we should stop accepter first and then clear all PIPEs).Looking at the logs posted along with the issue 6992, the failure happened at
pipe::writter::connectside (it should be a brand new connect instead of a re-connect as cs = 0, pgs = 0) after a rebind, and the failed one already has the updated local address, it is confused to me how the connection could be established? As there isconnect_seqcheck at the remote side which is likely to fail for this connection attempt (which is a positive value), unless there is some race at remote side updatingconnet_seqandin_seq.
Quoted 1 line
Am I missing something obviously on this?
Honestly I haven't looked closely at that old log; I would focus on the new log.
Looking at it now (for the first time, sorry), the last line is
-2> 2014-05-04 06:16:07.957897 7f71063ee700 2 --
10.193.207.180:6884/1037605 >> 10.193.207.183:6958/5001307 pipe(0x1cfa1400 sd=132 :60749 s=1 pgs=0 cs=0 l=0 c=0x12b4e160). got newly_acked_seq 10 vs out_seq 0
If I'm reading it right, that's an outgoing connection with the same source as the mark_down_all. If it existed before the mark_down_all, something is really broken because mark_dwon_all should have set it to STATE_CLOSED and the connect() function checks the state. Which makes me think that it was initiated after.
My guess is that this is a race in OSD.cc. We do the rebind() stuff, but only a bit further down do consume_map() which publishes the map to the OSDService with all kind of complicated handoff. I'm forgetting right now how this is supposed to work, but my guess is that this is the heart of the problem: some random PG thread is trying to send to an OSD using the older map and grabs the older OSDMap ref and opens the connection *after* we do the rebind() and mark_down_all().
Does this sound plausible?
sage
Quoted 20 lines · Sage Weil
[CCing Greg and ceph-devel]
Quoted 17 lines · Guang Yang
Hi Sage,
Sorry to bother you directly, I am debugging / fixing issue
http://tracker.ceph.com/issues/8232, during which time I studied the messenger component of CEPH. With more understanding of the messenger component, I started getting confused by the fix of issue 6992
(http://tracker.ceph.com/issues/6992) in terms of how it could help to solve the problem (though I fully agree we should stop accepter first and then clear all PIPEs).Looking at the logs posted along with the issue 6992, the failure happened at
pipe::writter::connectside (it should be a brand new connect instead of a re-connect as cs = 0, pgs = 0) after a rebind, and the failed one already has the updated local address, it is confused to me how the connection could be established? As there isconnect_seqcheck at the remote side which is likely to fail for this connection attempt (which is a positive value), unless there is some race at remote side updatingconnet_seqandin_seq.
Quoted 4 lines
Quoted 1 line
Am I missing something obviously on this?
Honestly I haven't looked closely at that old log; I would focus on the new log.
Likewise, I didn't compare the patch to the bug. The patch was definitely fixing a race with incoming connections, but it's possible it's mismatched with the backtrace or something.
Quoted 8 lines
Looking at it now (for the first time, sorry), the last line is
-2> 2014-05-04 06:16:07.957897 7f71063ee700 2 --10.193.207.180:6884/1037605 >> 10.193.207.183:6958/5001307 pipe(0x1cfa1400 sd=132 :60749 s=1 pgs=0 cs=0 l=0 c=0x12b4e160). got
newly_acked_seq10 vsout_seq0
Quoted 5 lines
If I'm reading it right, that's an outgoing connection with the same source as the
mark_down_all. If it existed before themark_down_all, something is really broken becausemark_dwon_allshould have set it toSTATE_CLOSEDand theconnect()function checks the state. Which makes me think that it was initiated after.
*smacks forehead*
For some reason I've been thinking it was a broken incoming connection rather than an outgoing one. But of course it's not, so...
Quoted 9 lines
My guess is that this is a race in OSD.cc. We do the
rebind()stuff, but only a bit further down doconsume_map()which publishes the map to the OSDService with all kind of complicated handoff. I'm forgetting right now how this is supposed to work, but my guess is that this is the heart of the problem: some random PG thread is trying to send to an OSD using the older map and grabs the older OSDMap ref and opens the connection *after* we do therebind()andmark_down_all().Does this sound plausible?
Well, I don't think it's supposed to happen — we hold a write on the map_lock during this time period and update the OSDSuperblock epochs before dropping it (and then doing consume_map()). But it's not pre-publishing and it might not even be that complicated a race, but just something wrong in the main thread. Sadly the msgr_crash.log file we have right now doesn't have enough info for me to identify the issue and code inspection doesn't sound like any fun, so a good log still sounds like the best way to identify the issue.
-Greg
Software Engineer #42 @ http://inktank.com | http://ceph.com
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 76 lines · Guang
Thanks Sage and Greg!
I just capture a crash from which I get the logs from both side (sadly we still use debug_ms=0 as increasing the
debug_mslevel dramatically consume more disk spaces), from the log, I think I get some more clues how this failure happened.Let us say we have two messengers C and S, at C side, it did a rebind and cleared everything.
The logs at C side are:
————
-6> 2014-05-07 12:29:35.3624487fcc26e8c7002 --
10.193.207.191:6918/24089488 >> 10.193.207.182:6982/57027253 pipe(0x19cfec80 sd=139 :48953 s=1 pgs=0 cs=0 l=0 c=0x13d62c
60). gotnewly_acked_seq59 vsout_seq0-5> 2014-05-07 12:29:35.362487 7fcc26e8c700 2 --10.193.207.191:6918/24089488 >> 10.193.207.182:6982/57027253 pipe(0x19cfec80 sd=139 :48953 s=1 pgs=0 cs=0 l=0 c=0x13d62c
60). discarding previously sent 0 osd_map(36192..36196 src has
35392..36196) v3-4> 2014-05-07 12:29:35.362504 7fcc26e8c700 2 -- 10.193.207.191:6918/24089488 >> 10.193.207.182:6982/57027253 pipe(0x19cfec80 sd=139 :48953 s=1 pgs=0 cs=0 l=0 c=0x13d62c 60). discarding previously sent 0 pg_notify(4.4d21(21) epoch 36196) v4 -3> 2014-05-07 12:29:35.362530 7fcc26e8c700 2 -- 10.193.207.191:6918/24089488 >> 10.193.207.182:6982/57027253 pipe(0x19cfec80 sd=139 :48953 s=1 pgs=0 cs=0 l=0 c=0x13d62c 60). discarding previously sent 0 pg_notify(3.4d22(21) epoch 36196) v4 -2> 2014-05-07 12:29:35.362561 7fcc26e8c700 2 -- 10.193.207.191:6918/24089488 >> 10.193.207.182:6982/57027253 pipe(0x19cfec80 sd=139 :48953 s=1 pgs=0 cs=0 l=0 c=0x13d62c 60). discarding previously sent 0 pg_query(4.3279 epoch 36196) v2 -1> 2014-05-07 12:29:35.362571 7fcc26e8c700 2 -- 10.193.207.191:6918/24089488 >> 10.193.207.182:6982/57027253 pipe(0x19cfec80 sd=139 :48953 s=1 pgs=0 cs=0 l=0 c=0x13d62c 60). discarding previously sent 0 pg_query(3.327a epoch 36196) v2 0> 2014-05-07 12:29:35.363457 7fcc26e8c700 -1 msg/Pipe.cc: In function'int
Pipe::connect()' thread7fcc26e8c700time 2014-05-07 12:29:35.362587
msg/Pipe.cc: 1045: FAILED assert(m)
————
The logs at S side are:
———2014-05-07 12:29:09.820735 7eff50794700 0 -- 10.193.207.182:6982/57027253Quoted 1 line
Quoted 1 line
10.193.207.191:6918/24089488 pipe(0x170bf680 sd=63 :57524 s=2 pgs=24805
cs=1 l=0 c=0x1691b340).fault with nothing to send, going to standby
2014-05-07 12:29:35.361030 7eff40042700 10 osd.363 36196 new session 0x17d33500 con=0x17fdf080 addr=10.193.207.191:6918/24089488 2014-05-07 12:29:35.361068 7eff40042700 0 -- 10.193.207.182:6982/57027253Quoted 1 line
Quoted 1 line
10.193.207.191:6918/24089488 pipe(0xfe07400 sd=343 :6982 s=0 pgs=0 cs=0
l=0 c=0x17fdf080).accept
connect_seq0 vs existing 1 state standby2014-05-07 12:29:35.361078 7eff40042700 0 -- 10.193.207.182:6982/57027253Quoted 1 line
Quoted 1 line
10.193.207.191:6918/24089488 pipe(0xfe07400 sd=343 :6982 s=0 pgs=0 cs=0
l=0 c=0x17fdf080).accept
peer reset, then tried to connect to us, replacing
———
And it looks like the below round trips happened between the two sides.
1. C tried to establish a new connection (when it gets some message to
send) with S with cs=0 (and a new larger pgs)
2. At S side, there was an existing connection with C (cs=1, pgs=24805,
in_seq>59).
3. This is what happened at S side:
3.1 lookup pipe and find an existing one -
https://github.com/ceph/ceph/blob/master/src/msg/Pipe.cc#L445
3.2 the execution flow comes to replacing the existing pipe -
https://github.com/ceph/ceph/blob/master/src/msg/Pipe.cc#L473
3.3 as this is a lossy connection, the original pipe would be cleared. 3.4 then it comes to the open section
(https://github.com/ceph/ceph/blob/master/src/msg/Pipe.cc#L649) and echo back a reply with tagCEPH_MSGR_TAG_SEQalong with the seq from original pipe
4. At C side
4.1 as this is a brand new pipe so thatout_seqis zero, however, the above message comes with along a originalnewly_ack_seq, this bring the assertion failure we observed.
Quoted 4 lines
If this makes sense, at step 3.4, we properly should not echo original seq if this is a branch new connection attempt (cs = 0).
Does this look like reasonable?
Ah! Yes, you're exactly right. This error makes sense; too — the CEPH_MSGR_TAG_SEQ is much newer than the rest of the reconnect logic.
Quoted 3 lines · Guang
I think the next question is, why C failed to find a PIPE (locally) for S but there is actually one PIPE existing at S side (with C), is it possible that C unregister the pipe but S has not been aware yet?
Exactly. In the other logs I've seen, C has done a mark_down_all() (which kills every single pipe) while doing a rebind(); generally this is as a consequence of getting an OSDMap which says it's down. If S has not yet seen this map, it won't have nuked the Connection on its side.
Would you like to prepare a patch, or should I? :)
-Greg
Software Engineer #42 @ http://inktank.com | http://ceph.com
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html