From 375674ba958d55457c0cfe95f68fea0e61fcad24 Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Fri, 27 Jul 2012 17:49:12 +0000 Subject: [PATCH] Improve testing code to better diagnose concurrency bugs. --- contrib/hashtest/hashtest.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/contrib/hashtest/hashtest.c b/contrib/hashtest/hashtest.c index d15c76abaf..90d525da1d 100644 --- a/contrib/hashtest/hashtest.c +++ b/contrib/hashtest/hashtest.c @@ -193,8 +193,15 @@ chash_concurrent_test(PG_FUNCTION_ARGS) e.val = 0; ok = CHashSearch(chash, &e); if (!ok) + { + uint64 retry = 1; elog(LOG, "search %u: not found", i); - else if (e.val != MyProcPid) + while (!CHashSearch(chash, &e)) + ++retry; + elog(LOG, "search %u: eventually found it after " + UINT64_FORMAT " retries", i, retry); + } + if (e.val != MyProcPid) elog(LOG, "search %u: expected %u found %u", i, (unsigned) MyProcPid, e.val); } @@ -205,7 +212,14 @@ chash_concurrent_test(PG_FUNCTION_ARGS) e.key = seed | i; ok = CHashDelete(chash, &e); if (!ok) + { + uint64 retry = 1; elog(LOG, "delete %u: not found", i); + while (!CHashDelete(chash, &e)) + ++retry; + elog(LOG, "delete %u: eventually deleted it after " + UINT64_FORMAT " retries", i, retry); + } } PG_RETURN_VOID(); -- 2.39.5