varnishtest "h2 queuing deadlock"

barrier b1 cond 2

# A reserve of 1 thread in a pool of 3 leaves a maximum
# of 2 running sessions, the streams will be queued (except
# stream 0 that is part of the h2 session).

varnish v1 -cliok "param.set thread_pools 1"
varnish v1 -cliok "param.set thread_pool_min 3"
varnish v1 -cliok "param.set thread_pool_max 3"
varnish v1 -cliok "param.set thread_pool_reserve 1"
varnish v1 -cliok "param.set thread_pool_watchdog 5"
varnish v1 -cliok "param.set feature +http2"
varnish v1 -cliok "param.set feature +no_coredump"

varnish v1 -vcl {
	backend b1 { .host = "${bad_ip}"; }
	sub vcl_recv {
		return (synth(200));
	}
} -start

logexpect l1 -v v1 -g raw {
	expect * *	Error	"Pool Herder: Queue does not move*"
} -start

# Starve the pool with h2 sessions

client c1 {
	txpri
	stream 0 rxsettings -run

	barrier b1 sync

	stream 1 {
		txreq
		# can't be scheduled, don't rx
	} -run
} -start

client c2 {
	txpri
	stream 0 rxsettings -run

	barrier b1 sync

	stream 1 {
		txreq
		# can't be scheduled, don't rx
	} -run
} -start

client c1 -wait
client c2 -wait

varnish v1 -vsl_catchup

# At this point c1 and c2 closed their connections

client c3 {
	txreq
	delay 10
} -run

logexpect l1 -wait

varnish v1 -cliok panic.show
varnish v1 -cliok panic.clear

varnish v1 -expectexit 0x20

