Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1jCn8c-0002Ls-M8 for pgsql-hackers@arkaria.postgresql.org; Fri, 13 Mar 2020 16:26:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jCn8b-0008HP-H5 for pgsql-hackers@arkaria.postgresql.org; Fri, 13 Mar 2020 16:26:17 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1jCn7r-0004Fo-Ec for pgsql-hackers@lists.postgresql.org; Fri, 13 Mar 2020 16:25:31 +0000 Received: from mail-lj1-x234.google.com ([2a00:1450:4864:20::234]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jCn7o-0002Rv-6J for pgsql-hackers@postgresql.org; Fri, 13 Mar 2020 16:25:30 +0000 Received: by mail-lj1-x234.google.com with SMTP id o10so11182101ljc.8 for ; Fri, 13 Mar 2020 09:25:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=rUybDQce0+RA6bl/nLO8y9Lo9RwDOO0F4gdq+QWa248=; b=Sso+Q86F8MU2DKxnrGvdMZnQOR+UcDBhMIGW26yFnensLjkk66oaxSIWvXGT9SKgQ2 B5Fe/9e9JgN54l2Y1z9/NCqObGt3r0N81tdNjpyKy9YDy306WLkrGpr4OgWLXbzjA+HH XHj2rKcOCfOPGKVwThh8bLUevuDW5RHmrKfmuzwGMO2OAu5rEAMzdsvo02Ray5rAjWHd tLBOD8wU4tooMxZazoexxGoVtbdvf1pZda6fFl8QwymJ8glXmC/LwG9K/q2J+0Y5NkvD 17Njay2n3AYm8WqTex8jivNRsw0aDzaqM9OJVBBXQdmjE63my0FHr3MyS0cchnc6jTJv +M3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=rUybDQce0+RA6bl/nLO8y9Lo9RwDOO0F4gdq+QWa248=; b=O4Wm7EWfSIusNLzi6etP4n502yOeDN8NyH0eaXaPLdlZUseci4+sYFPrfT4Cs7Xoch FWhWX0EVwqcygjOipNd6huaOQOEIC6qo9VU21HoG8YpXvDuzktjUqeJQKmneIJi9SOKQ TMpGa7nq09yJDB39rhrdmXtWX/k24ZiHlhBeWC8TCBlyKBONS8RJJZQoIo0svxwrVO7G oVfnxH4xWjaF+F69R5UB10CgiIEI/brI5OVbDLVVPerI5LAfqxMeOG5fUCieVn6r2goH dHveSBc5Ufe4ior4iv0SnwIsGR1zTDkN+GOTVdYypV/eCXe8sgH0sqxn7WFDwNw6rg+A jP0A== X-Gm-Message-State: ANhLgQ2z/NQdVZQuYRKw4JhHFQr9gQw6/gJgeVggYDDAkmL7//bNWwrU wf5lsVoRbiq1wbqrSKK5a5k= X-Google-Smtp-Source: ADFU+vv8OaED6x0740fofUEgKa7M3h28DSi4kGwTrFLyG3CnnLZ5n7NawaR1AH5MMGQ+w22Y7YQr4Q== X-Received: by 2002:a2e:9e03:: with SMTP id e3mr8741546ljk.186.1584116726115; Fri, 13 Mar 2020 09:25:26 -0700 (PDT) Received: from nol (82-64-124-11.subs.proxad.net. [82.64.124.11]) by smtp.gmail.com with ESMTPSA id e9sm19798281ljp.24.2020.03.13.09.25.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Mar 2020 09:25:25 -0700 (PDT) Date: Fri, 13 Mar 2020 17:25:20 +0100 From: Julien Rouhaud To: Tom Lane Cc: Alvaro Herrera , Michael Paquier , Andres Freund , pgsql-hackers Subject: Re: Add an optional timeout clause to isolationtester step. Message-ID: <20200313162520.GA80899@nol> References: <24078.1583958800@sss.pgh.pa.us> <20200311205254.GA2648@alvherre.pgsql> <20200313090450.6crpgoula5nrgadl@nol> <32140.1584108740@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <32140.1584108740@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Fri, Mar 13, 2020 at 10:12:20AM -0400, Tom Lane wrote: > Julien Rouhaud writes: > > > I'm not familiar with those test so I'm probably missing something, but looks > > like all isolation tests that setup a timeout are doing so to test server side > > features (deadlock detection, statement and lock timeout). I'm not sure how > > adding a client-side facility to detect locks earlier is going to help reducing > > the server side timeouts? > > The point is that those timeouts have to be set long enough for even a > very slow machine to reach a desired state before the timeout happens; > on faster machines the test is just uselessly sleeping for a long time, > because of the fixed timeout. My thought was that maybe the tests could > be recast as "watch for session to reach $expected_state and then do > the next thing", allowing them to be automatically adaptive to the > machine's speed. This might require some rather subtle test redesign > and/or addition of more infrastructure (to allow recognition of the > desired state and/or taking an appropriate next action). I'm prepared > to believe that not much can be done about timeouts.spec in particular, > but it seems to me that the long delays in the deadlock tests are not > inherent in what we need to test. Ah I see. I'll try to see if that could help the deadlock tests, but for sure such feature would allow us to get rid of the two pg_sleep(5) in tuplelock-update. It seems that for all the possibly interesting cases, what we want to wait on is an heavyweight lock, which is already what isolationtester detects. Maybe we could simply implement something like step "" [ WAIT UNTIL BLOCKED ] { } without any change to the blocking detection function? > > For the REINDEX CONCURRENTLY failure test, the problem that needs to be solved > > isn't detecting that the command is blocked as it's already getting blocked on > > a heavyweight lock, but being able to reliably cancel a specific query as early > > as possible, which AFAICS isn't possible with current isolation tester: > > Right, it's the same thing of needing to wait till the backend has reached > a particular state before you do the next thing. > > > So we would actually only need something like this to make it work: > > step "" [ CANCEL IF BLOCKED ] { > I continue to resist the idea of hard-wiring this feature to query cancel > as the action-to-take. That will more or less guarantee that it's not > good for anything but this one test case. I think that the feature > should have the behavior of "treat this step as blocked once it's reached > state X", and then you make the next step in the permutation be one that > issues a query cancel. (Possibly, using pg_stat_activity and > pg_cancel_backend for that will be painful enough that we'd want to > invent separate script syntax that says "send a cancel to session X". > But that's a separate discussion.) I agree. A new step option to kill a session rather than executing sql would go perfectly with the above new active-wait-for-blocking-state feature.