You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/07/11 15:59:58 UTC

[GitHub] [airflow] potiuk commented on pull request #24967: Add TCP_KEEPALIVE option to http provider

potiuk commented on PR #24967:
URL: https://github.com/apache/airflow/pull/24967#issuecomment-1180588876

   I think this one is worth breaking change (which is not really breaking in most cases) - enabling TCP Keepalive for SimpleHTTPOperator will have very limited impact in vast majority of cases (either no or very little increased traffic) however it will help out-of-the-box for a number of problems that people report with long running idle connections. 
   
   The one "drawback" I can think of in making such a "breaking" change is that in some cases, the firewalls will actully NOT break connections that were broken before because they were idle. However, that is usually not something that should be seen as "bad" - the way how TCP/HTTP works, is that such firewalls breaking idle connections have rather bad effect on the client - the client does not get "disconnect" and the connection is kept open from the client, so the client does not realise tha the connection has already been broken. So even if the connetion is broken, airflow still thinks it is not. Adding Keepalive will actually make it behave much better in case the server stops responding as lack of ACK in Keepalive will actually signal to client that it should close the connection and error out. So in all cases, it seems like a better behaviour. And you can still disable it by setting "tcp_keep_alive" to False.
   
   It is a breaking change though, so we should increase the version of the provider.
   
   It's very difficult to test this one via unit tests, but I tested it in Breeze using `tcpdump' by setting the values to low ones (keep alives generated avery second after 1 second of inactivity) resulted in this:
   
   ```
   tcpdump -vv tcp -i lo -n
   tcpdump: listening on lo, link-type EN10MB (Ethernet), snapshot length 262144 bytes
   15:28:46.111503 IP (tos 0x0, ttl 64, id 5429, offset 0, flags [DF], proto TCP (6), length 60)
       127.0.0.1.57584 > 127.0.0.1.2222: Flags [S], cksum 0xfe30 (incorrect -> 0x0b0f), seq 1769816328, win 65495, options [mss 65495,sackOK,TS val 1780041397 ecr 0,nop,wscale 7], length 0
   15:28:46.111509 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto TCP (6), length 60)
       127.0.0.1.2222 > 127.0.0.1.57584: Flags [S.], cksum 0xfe30 (incorrect -> 0x8c03), seq 2041795716, ack 1769816329, win 65483, options [mss 65495,sackOK,TS val 1780041397 ecr 1780041397,nop,wscale 7], length 0
   15:28:46.111514 IP (tos 0x0, ttl 64, id 5430, offset 0, flags [DF], proto TCP (6), length 52)
       127.0.0.1.57584 > 127.0.0.1.2222: Flags [.], cksum 0xfe28 (incorrect -> 0xb2bf), seq 1, ack 1, win 512, options [nop,nop,TS val 1780041397 ecr 1780041397], length 0
   15:28:46.111535 IP (tos 0x0, ttl 64, id 5431, offset 0, flags [DF], proto TCP (6), length 201)
       127.0.0.1.57584 > 127.0.0.1.2222: Flags [P.], cksum 0xfebd (incorrect -> 0x33f6), seq 1:150, ack 1, win 512, options [nop,nop,TS val 1780041397 ecr 1780041397], length 149
   15:28:46.111537 IP (tos 0x0, ttl 64, id 17233, offset 0, flags [DF], proto TCP (6), length 52)
       127.0.0.1.2222 > 127.0.0.1.57584: Flags [.], cksum 0xfe28 (incorrect -> 0xb22b), seq 1, ack 150, win 511, options [nop,nop,TS val 1780041397 ecr 1780041397], length 0
   15:28:47.151984 IP (tos 0x0, ttl 64, id 5432, offset 0, flags [DF], proto TCP (6), length 52)
       127.0.0.1.57584 > 127.0.0.1.2222: Flags [.], cksum 0xfe28 (incorrect -> 0xae1b), seq 149, ack 1, win 512, options [nop,nop,TS val 1780042437 ecr 1780041397], length 0
   15:28:47.152031 IP (tos 0x0, ttl 64, id 17234, offset 0, flags [DF], proto TCP (6), length 52)
       127.0.0.1.2222 > 127.0.0.1.57584: Flags [.], cksum 0xfe28 (incorrect -> 0xae1a), seq 1, ack 150, win 512, options [nop,nop,TS val 1780042437 ecr 1780041397], length 0
   15:28:50.159130 IP (tos 0x0, ttl 64, id 5433, offset 0, flags [DF], proto TCP (6), length 52)
       127.0.0.1.57584 > 127.0.0.1.2222: Flags [.], cksum 0xfe28 (incorrect -> 0x9e4c), seq 149, ack 1, win 512, options [nop,nop,TS val 1780045444 ecr 1780042437], length 0
   15:28:50.159150 IP (tos 0x0, ttl 64, id 17235, offset 0, flags [DF], proto TCP (6), length 52)
       127.0.0.1.2222 > 127.0.0.1.57584: Flags [.], cksum 0xfe28 (incorrect -> 0xa25b), seq 1, ack 150, win 512, options [nop,nop,TS val 1780045444 ecr 1780041397], length 0
   15:28:53.167721 IP (tos 0x0, ttl 64, id 5434, offset 0, flags [DF], proto TCP (6), length 52)
       127.0.0.1.57584 > 127.0.0.1.2222: Flags [.], cksum 0xfe28 (incorrect -> 0x86cc), seq 149, ack 1, win 512, options [nop,nop,TS val 1780048453 ecr 1780045444], length 0
   15:28:53.167749 IP (tos 0x0, ttl 64, id 17236, offset 0, flags [DF], proto TCP (6), length 52)
       127.0.0.1.2222 > 127.0.0.1.57584: Flags [.], cksum 0xfe28 (incorrect -> 0x969a), seq 1, ack 150, win 512, options [nop,nop,TS val 1780048453 ecr 1780041397], length 0
   15:28:56.175674 IP (tos 0x0, ttl 64, id 5435, offset 0, flags [DF], proto TCP (6), length 52)
       127.0.0.1.57584 > 127.0.0.1.2222: Flags [.], cksum 0xfe28 (incorrect -> 0x6f4b), seq 149, ack 1, win 512, options [nop,nop,TS val 1780051461 ecr 1780048453], length 0
   15:28:56.175713 IP (tos 0x0, ttl 64, id 17237, offset 0, flags [DF], proto TCP (6), length 52)
       127.0.0.1.2222 > 127.0.0.1.57584: Flags [.], cksum 0xfe28 (incorrect -> 0x8ada), seq 1, ack 150, win 512, options [nop,nop,TS val 1780051461 ecr 1780041397], length 0
   15:28:59.181101 IP (tos 0x0, ttl 64, id 5436, offset 0, flags [DF], proto TCP (6), length 52)
       127.0.0.1.57584 > 127.0.0.1.2222: Flags [.], cksum 0xfe28 (incorrect -> 0x57ce), seq 149, ack 1, win 512, options [nop,nop,TS val 1780054466 ecr 1780051461], length 0
   15:28:59.181160 IP (tos 0x0, ttl 64, id 17238, offset 0, flags [DF], proto TCP (6), length 52)
       127.0.0.1.2222 > 127.0.0.1.57584: Flags [.], cksum 0xfe28 (incorrect -> 0x7f1d), seq 1, ack 150, win 512, options [nop,nop,TS val 1780054466 ecr 1780041397], length 0
   15:29:02.193450 IP (tos 0x0, ttl 64, id 5437, offset 0, flags [DF], proto TCP (6), length 52)
       127.0.0.1.57584 > 127.0.0.1.2222: Flags [.], cksum 0xfe28 (incorrect -> 0x404c), seq 149, ack 1, win 512, options [nop,nop,TS val 1780057479 ecr 1780054466], length 0
   15:29:02.193484 IP (tos 0x0, ttl 64, id 17239, offset 0, flags [DF], proto TCP (6), length 52)
       127.0.0.1.2222 > 127.0.0.1.57584: Flags [.], cksum 0xfe28 (incorrect -> 0x7358), seq 1, ack 150, win 512, options [nop,nop,TS val 1780057479 ecr 1780041397], length 0
   15:29:05.197792 IP (tos 0x0, ttl 64, id 5438, offset 0, flags [DF], proto TCP (6), length 52)
       127.0.0.1.57584 > 127.0.0.1.2222: Flags [.], cksum 0xfe28 (incorrect -> 0x28cb), seq 149, ack 1, win 512, options [nop,nop,TS val 1780060483 ecr 1780057479], length 0
   15:29:05.197797 IP (tos 0x0, ttl 64, id 17240, offset 0, flags [DF], proto TCP (6), length 52)
       127.0.0.1.2222 > 127.0.0.1.57584: Flags [.], cksum 0xfe28 (incorrect -> 0x679c), seq 1, ack 150, win 512, options [nop,nop,TS val 1780060483 ecr 1780041397], length 0
   15:29:08.209579 IP (tos 0x0, ttl 64, id 5439, offset 0, flags [DF], proto TCP (6), length 52)
       127.0.0.1.57584 > 127.0.0.1.2222: Flags [.], cksum 0xfe28 (incorrect -> 0x114b), seq 149, ack 1, win 512, options [nop,nop,TS val 1780063495 ecr 1780060483], length 0
   15:29:08.209608 IP (tos 0x0, ttl 64, id 17241, offset 0, flags [DF], proto TCP (6), length 52)
       127.0.0.1.2222 > 127.0.0.1.57584: Flags [.], cksum 0xfe28 (incorrect -> 0x5bd8), seq 1, ack 150, win 512, options [nop,nop,TS val 1780063495 ecr 1780041397], length 0
   15:29:11.215237 IP (tos 0x0, ttl 64, id 5440, offset 0, flags [DF], proto TCP (6), length 52)
       127.0.0.1.57584 > 127.0.0.1.2222: Flags [.], cksum 0xfe28 (incorrect -> 0xf9c7), seq 149, ack 1, win 512, options [nop,nop,TS val 1780066502 ecr 1780063495], length 0
   15:29:11.215267 IP (tos 0x0, ttl 64, id 17242, offset 0, flags [DF], proto TCP (6), length 52)
       127.0.0.1.2222 > 127.0.0.1.57584: Flags [.], cksum 0xfe28 (incorrect -> 0x5018), seq 1, ack 150, win 512, options [nop,nop,TS val 1780066503 ecr 1780041397], length 0
   15:29:13.836305 IP (tos 0x0, ttl 64, id 17243, offset 0, flags [DF], proto TCP (6), length 52)
       127.0.0.1.2222 > 127.0.0.1.57584: Flags [F.], cksum 0xfe28 (incorrect -> 0x45da), seq 1, ack 150, win 512, options [nop,nop,TS val 1780069124 ecr 1780041397], length 0
   15:29:13.836498 IP (tos 0x0, ttl 64, id 5441, offset 0, flags [DF], proto TCP (6), length 52)
       127.0.0.1.57584 > 127.0.0.1.2222: Flags [F.], cksum 0xfe28 (incorrect -> 0xd989), seq 150, ack 2, win 512, options [nop,nop,TS val 1780069124 ecr 1780069124], length 0
   15:29:13.836517 IP (tos 0x0, ttl 64, id 17244, offset 0, flags [DF], proto TCP (6), length 52)
       127.0.0.1.2222 > 127.0.0.1.57584: Flags [.], cksum 0xfe28 (incorrect -> 0xd989), seq 2, ack 151, win 512, options [nop,nop,TS val 1780069124 ecr 1780069124], length 0
   ```
   (continues every second while the long running HTTP request runs)
   
   Where setting tcp_keep_alive=False resulted in this (no regular keepalive messages - the initial exchange was the only traffic, it did not run continuously while the requests runs:
   
   ```
   15:29:52.543116 IP (tos 0x0, ttl 64, id 6929, offset 0, flags [DF], proto TCP (6), length 60)
       127.0.0.1.57900 > 127.0.0.1.2222: Flags [S], cksum 0xfe30 (incorrect -> 0xe043), seq 2766482349, win 65495, options [mss 65495,sackOK,TS val 1780107830 ecr 0,nop,wscale 7], length 0
   15:29:52.543126 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto TCP (6), length 60)
       127.0.0.1.2222 > 127.0.0.1.57900: Flags [S.], cksum 0xfe30 (incorrect -> 0x6a9d), seq 3903183018, ack 2766482350, win 65483, options [mss 65495,sackOK,TS val 1780107830 ecr 1780107830,nop,wscale 7], length 0
   15:29:52.543133 IP (tos 0x0, ttl 64, id 6930, offset 0, flags [DF], proto TCP (6), length 52)
       127.0.0.1.57900 > 127.0.0.1.2222: Flags [.], cksum 0xfe28 (incorrect -> 0x9159), seq 1, ack 1, win 512, options [nop,nop,TS val 1780107830 ecr 1780107830], length 0
   15:29:52.543161 IP (tos 0x0, ttl 64, id 6931, offset 0, flags [DF], proto TCP (6), length 201)
       127.0.0.1.57900 > 127.0.0.1.2222: Flags [P.], cksum 0xfebd (incorrect -> 0x1290), seq 1:150, ack 1, win 512, options [nop,nop,TS val 1780107830 ecr 1780107830], length 149
   15:29:52.543164 IP (tos 0x0, ttl 64, id 2663, offset 0, flags [DF], proto TCP (6), length 52)
       127.0.0.1.2222 > 127.0.0.1.57900: Flags [.], cksum 0xfe28 (incorrect -> 0x90c5), seq 1, ack 150, win 511, options [nop,nop,TS val 1780107830 ecr 1780107830], length 0
   z15:30:33.983987 IP (tos 0x0, ttl 64, id 2664, offset 0, flags [DF], proto TCP (6), length 52)
       127.0.0.1.2222 > 127.0.0.1.57900: Flags [F.], cksum 0xfe28 (incorrect -> 0xeee0), seq 1, ack 150, win 512, options [nop,nop,TS val 1780149272 ecr 1780107830], length 0
   15:30:33.984321 IP (tos 0x0, ttl 64, id 6932, offset 0, flags [DF], proto TCP (6), length 52)
       127.0.0.1.57900 > 127.0.0.1.2222: Flags [F.], cksum 0xfe28 (incorrect -> 0x4cfd), seq 150, ack 2, win 512, options [nop,nop,TS val 1780149272 ecr 1780149272], length 0
   15:30:33.984356 IP (tos 0x0, ttl 64, id 2665, offset 0, flags [DF], proto TCP (6), length 52)
       127.0.0.1.2222 > 127.0.0.1.57900: Flags [.], cksum 0xfe28 (incorrect -> 0x4cfd), seq 2, ack 151, win 512, options [nop,nop,TS val 1780149272 ecr 1780149272], length 0
   ```
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org