X-Recipient: archive-cygwin AT delorie DOT com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:references :mime-version:content-type:in-reply-to; q=dns; s=default; b=Kv8E SkG9QMT4h197Pp5K3sJPvcIIE7i9b6CT5HEnPtyNcXoFPYpaMZ3lPtyzneLccAo7 kPefOxbPcY1F0XFkdYxGFix7UF2ttPiWHGCau93oSECTZk1b2Z+4CAY93TxyHclV qvfC4a68dJzIyZtuZyDUEEJaiXCEiWOSBokXODs= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:references :mime-version:content-type:in-reply-to; s=default; bh=ADp7GWYsM7 n8r36FeJuYFLLe7LU=; b=KnLDQLeK3ETz+clkz/VWN+wAFrofcNr91RksWuKLB4 jThnMkyqX8drWR8Bt/2ZOanrdgGTd2L8CRMpXnWarEUpkNKbjjQsjonyXa8o+w9+ RAe8otTA7JlvCARDv35+LcLGzlhlNLctwfQ2o7mHUeQ7yvpDsspoGnWN1bab1nwT 8= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM autolearn=no version=3.3.2 spammy=awhile, Pick, cease, classic X-HELO: mail-pg0-f47.google.com 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:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=CtKgNGWGYgT8te0R2OziqUX6eGJQOzC1rUja/LryavU=; b=h9ITnWvj4uxN/BidU4aXnt2rUuT9zH1yfMfaqBuOgRxA4rmKNDVONlLqEGmxA+UZ98 N+zfFtZ/cKw05yPWTngHKLMLMel5KWffUvqgYxtlKONiozO1uN5b8yZseSIoRnbp5qYz sxPuD8JHkjv95Yn9Uf+mEjGjFmbk+gEOiCL/eLch9aEWPl1hKTnew/MDpl/5bG6M7wac AE4882SdtrSOtX2Ant8yNjpIlhX79FgdkUbZrG4F841VSDzf9fS2Qug3edOe8JzcWLtF 92T9QKYOmWej4CUmUrhDb2HrG+MRFA01Cf/HXInsmCvfuO7303fDws8Elma6VcCzEvnE diQw== X-Gm-Message-State: AFeK/H31VGpdamfuWpdVULBW3WHmZ5k8IcPyhl1FZ5yiasP6MnUXnVYHb4gSpZ11I4dzig== X-Received: by 10.84.253.15 with SMTP id z15mr12597831pll.142.1491100588278; Sat, 01 Apr 2017 19:36:28 -0700 (PDT) Date: Sat, 1 Apr 2017 22:36:24 -0400 From: Noah Misch To: cygwin AT cygwin DOT com Subject: Re: cygserver - Postgres Multiple connection Load Testing - Inifinte Loop Message-ID: <20170402023624.GA2561924@tornado.leadboat.com> References: <200408030333 DOT i733XEXn023894 AT mx3 DOT redhat DOT com> <20040803100612 DOT GP31522 AT cygbert DOT vinschen DOT de> <20170321025614 DOT GA2100214 AT tornado DOT leadboat DOT com> <20170324171101 DOT GI29995 AT calimero DOT vinschen DOT de> <20170328052652 DOT GA2351961 AT tornado DOT leadboat DOT com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="Nq2Wo0NMKNjxTN9z" Content-Disposition: inline In-Reply-To: <20170328052652.GA2351961@tornado.leadboat.com> User-Agent: Mutt/1.5.24 (2015-08-30) --Nq2Wo0NMKNjxTN9z Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Mar 28, 2017 at 01:26:52AM -0400, Noah Misch wrote: > On Fri, Mar 24, 2017 at 06:11:01PM +0100, Corinna Vinschen wrote: > > I pushed a patchset now, and uploaded new developer snapshots for > > testing to https://cygwin.com/snapshots/ > > > Please give it a try > I call the cygwin-20170324 freezes "limited" because the symptoms differ from > the classic freeze I described upthread. "strace /bin/true" and "cat > /proc/sysvipc/sem" do not hang, but every PostgreSQL backend process is stuck > waiting on a synchronization primitive. > > I can distill another self-contained test case for the limited freeze seen in > cygwin-20170324, but that make take awhile. I'm sending this early report so > you're aware of the possible regression in cygwin-20170324. I'm attaching a new test program that demonstrates the regression. My previous test program created sixteen processes that each picked a random semaphore to lock. Now, each process picks two semaphores and locks them in order. This proceeds smoothly on GNU/Linux and on cygwin-20170321.tar.xz "cygserver -r 40". It freezes within one second on cygwin-20170324.tar.xz "cygserver -r 40". --Nq2Wo0NMKNjxTN9z Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="sema_two.c" /* * Demonstrate cygserver bug introduced in cygwin-20170324.tar.xz snapshot. Run * without arguments. Test against "cygserver -r 40" to get enough threads. * This is otherwise compatible with default cygserver settings; it uses a * single semaphore set of eight semaphores. * * Output will cease within a few seconds. On older cygserver and non-Cygwin * systems, it will run to completion. */ #include #include #include #include #include #include #include #include #define SEM_KEY 0x631a2c3f #define N_WORKER 16 #define N_SEMA (N_WORKER/2) #define N_CYCLE 1000000 union semun { int val; struct semid_ds *buf; unsigned short *array; }; static int print_every = 1; static int lock(int set, unsigned short sem_num) { struct sembuf op; op.sem_num = sem_num; op.sem_op = -1; op.sem_flg = 0; if (0 > semop(set, &op, 1)) { perror("semop"); return 1; } return 0; } static int unlock(int set, unsigned short sem_num) { struct sembuf op; op.sem_num = sem_num; op.sem_op = 1 ; /* only difference vs. lock() */ op.sem_flg = 0; if (0 > semop(set, &op, 1)) { perror("semop"); return 1; } return 0; } /* In parallel, N_WORKER processes run this function. */ static int do_worker(int ordinal, int set) { int i; printf("start worker %d\n", ordinal); fflush(stdout); for (i = 1; i <= N_CYCLE; i++) { unsigned short s0, s1; /* Pick two non-identical semaphore numbers. */ s0 = random() % N_SEMA; do { s1 = random() % N_SEMA; } while (s0 == s1); /* Lock the lower one first, thereby preventing deadlock. */ if (lock(set, s0 < s1 ? s0 : s1) || lock(set, s0 < s1 ? s1 : s0) || unlock(set, s0) || unlock(set, s1)) return 1; if (i % print_every == 0) { printf("worker %d: %d cycles elapsed\n", ordinal, i); fflush(stdout); } } return 0; } int main(int argc, char **argv) { int status = 1, set, i, child_status; if (argc == 2) print_every = atoi(argv[1]); else if (argc != 1) { fprintf(stderr, "Usage: sema_two [print-every-N]\n"); return status; } puts("semget"); fflush(stdout); set = semget(SEM_KEY, N_SEMA, IPC_CREAT | 0600); if (set == -1) { perror("semget"); return status; } puts("SETVAL"); fflush(stdout); for (i = 0; i < N_SEMA; i++) { union semun s; s.val = 1; if (0 > semctl(set, i, SETVAL, s)) { perror("semctl(SETVAL)"); goto cleanup; } } for (i = 0; i < N_WORKER; i++) { pid_t pid; pid = fork(); switch (pid) { case -1: perror("fork"); goto cleanup; case 0: return do_worker(i, set); } } status = 0; cleanup: while (wait(&child_status) != -1) ; if (errno != ECHILD) { perror("wait"); status = 1; } if (0 > semctl(set, 0, IPC_RMID)) { perror("semtctl(IPC_RMID)"); status = 1; } return status; } --Nq2Wo0NMKNjxTN9z Content-Type: text/plain; charset=us-ascii -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple --Nq2Wo0NMKNjxTN9z--