2024-08-02 20:17:29 It's funny how often that fails to get mentioned when it's the case. 2024-08-02 22:05:58 Hey, just a little tidbit it might be handy to have in mind at some point. Bash arithmetic doesn't seem to handle modulo operations (% operator) right. It's fine for positive numbers, but for example -1 % 10 returns -1, whereas I think it should be 9. 2024-08-02 22:06:13 It's probably not "wrong" - there's probably a reason it's fine. It's just not what I expected or needed, though. 2024-08-02 22:06:40 Python, for example, returns 9 for -1 % 10. 2024-08-02 22:07:45 Bash seems to do the operation as though the number were positive, and then put the - back on when it's done if it was there to begin with. 2024-08-02 22:09:50 I think there's two opinions on this point: is % the mathematical modulo operator, or is it "remainder after division"? Those are the same if both operands are positive, but differ if one of them is negative. 2024-08-02 22:10:20 modulus isn't portable between languages 2024-08-02 22:10:30 Right. 2024-08-02 22:10:45 I think remainder-after-division is easier to implement on a reasonably normal CPU, but mathematical-modulus is usually easier to work with. 2024-08-02 22:10:48 I think of it like "clock arithmetic." Noon minus one hour is 11. 2024-08-02 22:11:09 Or at least that's how it suited me to think of it for what I was just doing when it came to my attention. 2024-08-02 22:11:42 I'm measuring the handhake time between my system canisters at work. I do that by gettng the time in ms, doing the handshake, and getting the time in ms again. 2024-08-02 22:11:49 Like I said, the mathematical version is usually what we actually want, but it's rarely (IMO) what we're given. :/ 2024-08-02 22:11:51 And I needed to watch out for rolling over midnight. 2024-08-02 22:12:09 I thought modulo 86400000 would do the trick, but it doesn't because of this. 2024-08-02 22:12:23 Before I subtract I check, and if the second one is smaller I just add 86400000 to it. 2024-08-02 22:13:23 That's usually what you've got to do, yes. Or (x % n + x) % n, if you don't want a conditional in the expression (and don't care about computation cost too much). 2024-08-02 22:13:53 Ok, well, I'm glad this is a known issue - I'd just never bumped into it before. 2024-08-02 22:15:07 The recent big outage we had after hurricane Beryl seems to have damaged out network at the office - ever since then my jobs have started getting stuck periodically, on these handshakes. 2024-08-02 22:15:24 It was poor initial coding on my part - I was just sending an ssh command and presuming it got there. 2024-08-02 22:15:42 I modified it so it expects something as a result of that command and confirms it, and re-tries if it gets a timeout instead. 2024-08-02 22:16:07 I was guilty of "coding for the good path." 2024-08-02 22:16:18 It's either that, or the network's Just Had Enough of This Shit. 2024-08-02 22:16:21 I know how it feels. 2024-08-02 22:16:24 But, it did work fine for three years, so... 2024-08-02 22:16:32 :-) 2024-08-02 22:17:11 Adding the lag measurement wsa just a little frill I thew in as long as I was in the neighborhood. Writing those out the session logs. 2024-08-02 22:17:30 "to" 2024-08-02 22:17:46 So far it looks like 200-300 ms is "normal."