diff options
author | Michael Cahill <michael.cahill@wiredtiger.com> | 2013-12-11 10:17:54 +1100 |
---|---|---|
committer | Michael Cahill <michael.cahill@wiredtiger.com> | 2013-12-11 10:17:54 +1100 |
commit | 4df3f8d705c1176d970fe4ddd6ea6ae2d75c8ebf (patch) | |
tree | 13f19db745033a4d80d277af610c6b57629cb2fc | |
parent | 8a9328bed4458bbbd41ad0b3304bb5c55fd28ade (diff) | |
download | mongo-4df3f8d705c1176d970fe4ddd6ea6ae2d75c8ebf.tar.gz |
imported patch schema-lock-timeout-abort
-rw-r--r-- | src/include/schema.h | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/include/schema.h b/src/include/schema.h index ab06e1c0cad..649c1317134 100644 --- a/src/include/schema.h +++ b/src/include/schema.h @@ -68,7 +68,8 @@ struct __wt_table { #define WT_COLGROUPS(t) WT_MAX((t)->ncolgroups, 1) #define WT_WITH_SCHEMA_LOCK(session, op) do { \ - int schema_locked = 0; \ + int schema_locked = 0, waited = 0; \ + struct timespec __start, __now; \ WT_ASSERT(session, \ F_ISSET(session, WT_SESSION_SCHEMA_LOCKED) || \ !F_ISSET(session, WT_SESSION_NO_SCHEMA_LOCK)); \ @@ -77,8 +78,15 @@ struct __wt_table { session, &S2C(session)->schema_lock) == 0) { \ F_SET(session, WT_SESSION_SCHEMA_LOCKED); \ schema_locked = 1; \ - } else \ + } else { \ + (void)__wt_epoch(session, &__now); \ + if (!waited) { \ + __start = __now; \ + waited = 1; \ + } else if (WT_TIMEDIFF(__now, __start) > WT_BILLION / 2)\ + abort(); \ __wt_yield(); \ + } \ (op); \ if (schema_locked) { \ F_CLR(session, WT_SESSION_SCHEMA_LOCKED); \ |