From: Douglas Bagnall Date: Wed, 22 May 2024 00:15:37 +0000 (+1200) Subject: s3/torture: local_rbtree: avoid birthday collisions X-Git-Tag: tdb-1.4.11~501 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=267f307689b92bc7e1e407fb7f1a9f556d7d8b90;p=thirdparty%2Fsamba.git s3/torture: local_rbtree: avoid birthday collisions We insert 999 keys, but if two of them happen to be the same, we don't find 1000 nodes, and that is upsetting for CI: [130(1421)/303 at 4m46s] samba3.smbtorture_s3.LOCAL-RBTREE UNEXPECTED(failure): samba3.smbtorture_s3.LOCAL-RBTREE.smbtorture(none) REASON: Exception: Exception: using seed 1716333987 host=foo share=bar user= myname=runner-jlguopmm-project-6378020-concurrent-0 Running LOCAL-RBTREE run_local_rbtree: read1: 999 999, NT_STATUS_OK run_local_rbtree: delete: 999 999, NT_STATUS_OK run_local_rbtree: read2: 0 0, NT_STATUS_OK TEST LOCAL-RBTREE FAILED! LOCAL-RBTREE took 0.002706 secs This has been flapping very occasionally for a long time: https://lists.samba.org/archive/samba-technical/2016-March/112861.html Signed-off-by: Douglas Bagnall Reviewed-by: Andrew Bartlett Reviewed-by: Volker Lendecke --- diff --git a/source3/torture/torture.c b/source3/torture/torture.c index e0cc39f732d..1f8621654ec 100644 --- a/source3/torture/torture.c +++ b/source3/torture/torture.c @@ -13634,17 +13634,17 @@ static bool run_local_rbtree(int dummy) } for (i = 0; i < 999; i++) { - char key[sizeof("key-9223372036854775807")]; - char value[sizeof("value-9223372036854775807")]; + char key[sizeof("key-9223372036854775807-1234")]; + char value[sizeof("value-9223372036854775807-1234")]; - snprintf(key, sizeof(key), "key%ld", random()); - snprintf(value, sizeof(value) ,"value%ld", random()); + snprintf(key, sizeof(key), "key%ld-%d", random(), i); + snprintf(value, sizeof(value) ,"value%ld-%d", random(), i); if (!rbt_testval(db, key, value)) { goto done; } - snprintf(value, sizeof(value) ,"value%ld", random()); + snprintf(value, sizeof(value) ,"value%ld-%d", random(), i + 1); if (!rbt_testval(db, key, value)) { goto done;