[6.0] 7523f3c12 Fix handling of failed VRT_new_backend_clustered

Reza Naghibi reza at naghibi.com
Tue Apr 20 18:29:05 UTC 2021


commit 7523f3c12da877f4374af977279358d8bba6d8ea
Author: Martin Blix Grydeland <martin at varnish-software.com>
Date:   Tue Dec 3 16:00:27 2019 +0100

    Fix handling of failed VRT_new_backend_clustered
    
    We refuse to accept new dynamic backends while the VCL is cooling, and
    drop adding the attempted backend on the VCL's backend list when that
    condition is found. But that would cause an assert later when it is picked
    off the cool_backends list for destruction. Fix this by directly
    destroying the backend instead of going through the cooling list.
    
    Note that this patch removes the ASSERT_CLI() macro in vbe_destroy().

diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c
index b64ac8521..ba0e649ed 100644
--- a/bin/varnishd/cache/cache_backend.c
+++ b/bin/varnishd/cache/cache_backend.c
@@ -405,7 +405,6 @@ vbe_destroy(const struct director *d)
 {
 	struct backend *be;
 
-	ASSERT_CLI();
 	CAST_OBJ_NOTNULL(be, d->priv, BACKEND_MAGIC);
 
 	if (be->probe != NULL)
@@ -537,8 +536,8 @@ VRT_new_backend_clustered(VRT_CTX, struct vsmw_cluster *vc,
 	if (retval == 0)
 		return (d);
 
-	VRT_delete_backend(ctx, &d);
-	AZ(d);
+	/* Undo the above */
+	d->destroy(d);
 	return (NULL);
 }
 
diff --git a/bin/varnishd/cache/cache_vcl_vrt.c b/bin/varnishd/cache/cache_vcl_vrt.c
index 4133f46b7..5f3bfeec0 100644
--- a/bin/varnishd/cache/cache_vcl_vrt.c
+++ b/bin/varnishd/cache/cache_vcl_vrt.c
@@ -142,6 +142,7 @@ VCL_AddDirector(struct vcl *vcl, struct director *d, const char *vcl_name)
 	AZ(errno=pthread_rwlock_rdlock(&vcl->temp_rwl));
 	if (vcl->temp == VCL_TEMP_COOLING) {
 		AZ(errno=pthread_rwlock_unlock(&vcl->temp_rwl));
+		REPLACE(d->display_name, NULL);
 		return (1);
 	}
 


More information about the varnish-commit mailing list