Reported race in session open/close/truncate.
Here's the test program.
#include <string.h> #include <pthread.h> #include "wiredtiger.h" typedef struct { WT_CONNECTION* conn; long count; char table[64]; } Arg; WT_SESSION* session_open(WT_CONNECTION* conn) { WT_SESSION* session; int rc = conn->open_session(conn, NULL, NULL, &session); if (rc != 0) { fprintf(stderr, "open session failed: %s\n", wiredtiger_strerror(rc)); pthread_exit(0); } return session; } void session_close(WT_SESSION* session) { int rc = session->close(session, NULL); if (rc != 0) { fprintf(stderr, "close session failed: %s\n", wiredtiger_strerror(rc)); pthread_exit(0); } } WT_CURSOR* cursor_open(WT_SESSION* session, const char* table) { WT_CURSOR* cursor; int rc = session->open_cursor(session, table, NULL, "overwrite,raw", &cursor); if (rc != 0) { fprintf(stderr, "open cursor failed: %s\n", wiredtiger_strerror(rc)); pthread_exit(0); } return cursor; } void cursor_close(WT_CURSOR* cursor) { int rc = cursor->close(cursor); if (rc != 0) { fprintf(stderr, "close cursor failed: %s\n", wiredtiger_strerror(rc)); pthread_exit(0); } } void check_empty(WT_SESSION* session, const char* table) { WT_CURSOR* cursor = cursor_open(session, table); int rc = cursor->next(cursor); if (rc != WT_NOTFOUND) { fprintf(stderr, "cursor next failed: %s\n", wiredtiger_strerror(rc)); pthread_exit(0); } cursor_close(cursor); } void* thr(void* p) { Arg* arg = (Arg*)p; WT_CONNECTION* conn = arg->conn; WT_SESSION* session = session_open(conn); int rc = session->create(session, arg->table, NULL); if (rc != 0) { fprintf(stderr, "session create failed: %s\n", wiredtiger_strerror(rc)); return 0; } session_close(session); while (arg->count--) { session = session_open(conn); check_empty(session, arg->table); session_close(session); session = session_open(conn); rc = session->truncate(session, arg->table, NULL, NULL, NULL); if (rc != 0) { fprintf(stderr, "session truncate failed: %s\n", wiredtiger_strerror(rc)); return 0; } session_close(session); } return 0; } #define NUMTHREADS 64 int main(int argc, char** argv) { WT_CONNECTION* conn; pthread_t thread[NUMTHREADS]; Arg arg[NUMTHREADS]; int i, rc; system("rm -rf wt && mkdir wt"); rc = wiredtiger_open("wt", NULL, "create,cache_size=100MB,session_max=100", &conn); if (rc != 0) { fprintf(stderr, "connection open failed: %s\n", wiredtiger_strerror(rc)); return 1; } for (i = 0; i < NUMTHREADS; ++i) { arg[i].conn = conn; arg[i].count = 200; memset(arg[i].table, 0, sizeof arg[i].table); sprintf(arg[i].table, "table:wt%050d", i); pthread_create(&thread[i], NULL, thr, &arg[i]); } for (i = 0; i < NUMTHREADS; ++i) { void* v; pthread_join(thread[i], &v); } return 0; }
- is related to
-
WT-101 multithread configuration should block WT_CONNECTION:open_session
- Closed
- related to
-
WT-2 What does metadata look like?
- Closed
-
WT-3 What file formats are required?
- Closed
-
WT-4 Flexible cursor traversals
- Closed
-
WT-5 How does pget work: is it necessary?
- Closed
-
WT-6 Complex schema example
- Closed
-
WT-7 Do we need the handle->err/errx methods?
- Closed
-
WT-8 Do we need table load, bulk-load and/or dump methods?
- Closed
-
WT-9 Does adding schema need to be transactional?
- Closed
-
WT-11 placeholder #11
- Closed
-
WT-12 Write more examples
- Closed
-
WT-13 Define supported platforms
- Closed
-
WT-14 Windows build
- Closed
-
WT-15 Automated build/test infrastructure
- Closed