Compare commits

...

99 Commits

Author SHA1 Message Date
sueloverso
187707a5c1 WT-3000 Wait for previous writes on first write to new log file (#3139)
(cherry picked from commit 8b05389ae9)
2016-11-15 14:45:07 +11:00
Michael Cahill
2e2d5fe23b Merge branch 'mongodb-3.4' into mongodb-3.2 2016-11-07 16:52:43 +11:00
Michael Cahill
b060bd4cc0 Merge branch 'mongodb-3.4' into mongodb-3.2 2016-11-04 21:05:45 +11:00
Alex Gorrod
b11ed312ce Merge branch 'mongodb-3.4' into mongodb-3.2 2016-10-26 11:42:12 +11:00
Alex Gorrod
9cf2f89d6d Merge branch 'mongodb-3.4' into mongodb-3.2 2016-09-26 17:05:25 +10:00
Michael Cahill
bb18c43915 Merge branch 'mongodb-3.4' into mongodb-3.2 2016-09-20 09:38:17 +10:00
Michael Cahill
911c940ada Merge branch 'mongodb-3.4' into mongodb-3.2 2016-09-12 18:03:26 +10:00
Michael Cahill
7d45541f3a WT-2804 Don't read values in a tree without a snapshot. (#2924)
* Improve two recent assertions, one from WT-2798 relating to writing metadata updates to disk that are part of a running transaction, and another from WT-2802 that checks that we don't try to copy values from a cursor without a transaction pinned.  The latter doesn't apply to cursors on checkpoints (including chunk cursors in an LSM tree).

* Copy cursor values before rollback in autocommit.

  If an autocommit operation such as WT_CURSOR::update touches multiple trees (e.g., multiple column groups in a table, or index updates, or multiple chunks in an LSM tree), then some cursors may have consumed the application's key/value pair when the operation has to roll back.  Take a copy of any such values before attempting to retry the operation.

(cherry picked from commit 41eb2dcaac)
2016-08-02 17:05:11 +10:00
Michael Cahill
fb6e667667 WT-2801 Prevent eviction of metadata updates by a running checkpoint. (#2922)
(cherry picked from commit 8f02a158b5)
2016-08-02 17:02:30 +10:00
Michael Cahill
dddca65606 WT-2802 Copy values during commit before releasing snapshot. (#2917)
(cherry picked from commit 8f3e5f31da)
2016-07-29 16:35:37 +10:00
Michael Cahill
2969c02ab9 WT-2798 Fix data consistency bug with table creates during a checkpoint. (#2910)
When logging is disabled, a create operation (and potentially other
metadata updates) could write partially completed checkpoint metadata,
leaving on-disk files inconsistent until the checkpoint completes.

(cherry picked from commit 7e1a47dd45)
2016-07-29 16:19:02 +10:00
Keith Bostic
82323cf72f WT-2760 Fix a bug in backup related to directory sync. Change the filesystem API to make durable the default (#2867)
Change the default remove/rename calls to flush the enclosing directory.

Simplify the pluggable file system API by replacing the directory-sync method
with "durable" boolean argument to the remove, rename and open-file methods.

* Add "durable" arguments to relevant functions so that each remove or rename
call specifies its durability requirements.

* Switch the  WT_FILE_SYSTEM::fs_open_file type enum from WT_OPEN_FILE_TYPE,
with WT_OPEN_XXX names, to the WT_FS_OPEN_FILE_TYPE, with WT_FS_OPEN_XXX
names.

Switch the  WT_FILE_SYSTEM::fs_open_file flags from WT_OPEN_XXX names to
WT_FS_OPEN_XXX names.

* Replace the "bool durable" argument to WT_FILE_SYSTEM.fs_remove and
WT_FILE_SYSTEM.fs_rename with a "uint32_t flags" argument, and the
WT_FS_DURABLE flag.

* Remove a stray bracket.

(cherry picked from commit 11f018322c)
2016-07-29 16:18:32 +10:00
Keith Bostic
859c8eda1e WT-2730 Btree can incorrectly match key slots on new pages (#2848)
This problem can occur for both row and column store.

The WT_CURSOR_BTREE.rip_saved field potentially has the same problem
as the cip_saved field, initializing it on point-searches is wrong,
it should be initialized as a cursor moves to a new page.

* Clear cip_saved and rip_saved when starting to iterate from a search
position.  This wasn't necessary before because we cleared them in
__cursor_pos_clear(), but I removed that code.

In summary, we now clear them in the iteration code, both when starting
an iteration and when switching to a new page. That's correct because
they have nothing to do with searches so the clear doesn't belong in
__cursor_pos_clear(), and we have to do the clear when switching to a
new page regardless, __cursor_pos_clear() isn't called when switching
to a new page.

(cherry picked from commit 1b6a9220c3)
2016-07-29 16:13:37 +10:00
Keith Bostic
24cd107c1d WT-2730 column-store incorrectly matches key slots on new pages (#2847)
Reset the column-store saved slot information on each new page, otherwise
it's possible for it to match the last page we were traversing.
(cherry picked from commit 51a4e1593d)
2016-07-29 16:13:30 +10:00
David Hows
3dc8860451 WT-2711 Remove posix expanded strftime values and use older C89 values (#2865)
* WT-2711 Remove posix expanded strftime values and use older C89 values

* Fix issues with s_string

* Add a comment so nobody rewrites the strftime format and reintroduces the bug.

* Fix strings sort order.

(cherry picked from commit 1c67c4e0f0)
2016-07-29 16:12:45 +10:00
Keith Bostic
9383fc98ee WT-2711 Change statistics log configuration options (#2857)
If there's no server running, discard any configuration information so
we don't leak memory during reconfiguration.
(cherry picked from commit e001657e5c)
2016-07-29 16:12:29 +10:00
Keith Bostic
307e63aac7 WT-2711 Change statistics log configuration options (#2834)
No longer support setting the statistics_log path in WT_CONNECTION::reconfigure.
No longer support setting a custom name for statistics files, only allow a destination directory.
Be more explicit about which logging configuration options are allowed in WT_CONNECTION::reconfigure.

The aim of these changes is to avoid situations where applications that embed WiredTiger allow their users to overwrite unexpected files on a file system.

This potentially requires an upgrade step for applications that were specifying a non-standard file name component for statistics log file names, it's not backward compatible.
(cherry picked from commit 9cc5d0f4b1)
2016-07-29 16:12:16 +10:00
Michael Cahill
6f81f19793 SERVER-24971 Don't cache buffers after application eviction. (#2869)
(cherry picked from commit f98ecc9d7c)
2016-07-29 16:08:16 +10:00
Alex Gorrod
848e5f5c0b Merge branch 'mongodb-3.4' into mongodb-3.2
Choosing the content of the 3.4 branch, rather than manually
resolving merge conflicts.
2016-07-26 11:11:27 +10:00
sueloverso
8b7110bfac WT-2706 Fix lost log writes when switching files (#2803)
Fix a path that incorrectly returning success from log_write without writing a log record.

(cherry picked from commit 36d657ccc6)
2016-07-07 08:49:56 +10:00
Michael Cahill
f4954f6592 WT-2729 Focus eviction on the largest trees in cache (mongodb-3.2). (#2833)
Randomize visits to trees that use a tiny fraction of the cache.

Eviction optimizations.

Now that we are queuing more entries (potentially), make sure enough of
them become candidates.  Previously, a skewed distribution of read
generations could mean that only 10% of queue entries were considered.

Improve the efficiency of sorting the queue by calculating the score
once when pages are added to the queue.

Take care to bound the maximum eviction slot.
2016-06-28 14:58:58 +10:00
Keith Bostic
dd2a33849a WT-2708 split child-update race with reconciliation/eviction (#2835)
(cherry picked from commit 521270d54c)

When splitting the root page and updating the child's WT_REF.addr, reconciliation/eviction can race with us, updating WT_REF.addr after our read and before our update. The update is necessary because the child's
address points into the page being split: if the address changes, then it can no longer point into the page being split and the update is no longer necessary.
2016-06-28 14:17:30 +10:00
Michael Cahill
a63e21b838 SERVER-24580 Add more eviction stats to track efficiency. (#2830)
(cherry picked from commit 1f4aaa4490)
2016-06-23 17:36:28 +10:00
sueloverso
30e49acc90 WT-2696 Wait if we find an unbuffered flag without the size set yet. (#2794)
* Modify recovery test to use multiple threads to reproduce this issue.

(cherry picked from commit 0d4c83daf7)
2016-06-23 17:30:02 +10:00
Keith Bostic
063dbdfe45 WT-2672 handle system calls that don't set errno (#2765)
Define system call success as a 0 return, and split error handling into two parts: if the call returns -1, use errno, otherwise expect the failing return to be an error value.

Replace calls to remove with unlink, so we know errno will be set.  Do the best we can with rename, there's no easy workaround.

POSIX requires posix_madvise return an errno value, but some OS versions return a -1/errno pair instead (at least FreeBSD and OS X). I don't care about retrying posix_madvise calls on failure, but since WT_SYSCALL_RETRY includes the necessary error handling magic, wrap the posix_madvise calls in WT_SYSCALL_RETRY.

(cherry picked from commit ced588aecd)
2016-06-23 17:16:06 +10:00
Michael Cahill
9ee39b8aea SERVER-24580 Fix backport. 2016-06-23 16:29:47 +10:00
Michael Cahill
d68800d0e9 SERVER-24580 Update oldest txn ID with "strict, nowait" flags. (#2829)
Add more options for callers when updating the oldest ID to control how much they care about the ID being updated.
(cherry picked from commit 116e41e5e1)
2016-06-23 16:03:26 +10:00
Michael Cahill
ded2149b2c SERVER-24580 Enhance eviction when application threads are contributing (#2806)
When the cache hits eviction triggers, all application threads can
hammer the eviction queue lock, starving each other and server threads.

Also, noticed with the same workload, the eviction server doesn't need
to force updates to the oldest ID (which can starve the eviction server
thread if there are hundreds of application threads getting snapshots).
It is sufficient to update it lazily.

* Clear the eviction walk if we don't find any candidates.

Otherwise, we are keeping a page pinned in what might be an idle file,
and tying up a hazard pointer that could prevent eviction from an active
file (since the eviction server tracks how many hazard pointers it is
using to avoid going over the limit).

(cherry picked from commit 7f9d7aecea)
2016-06-23 16:03:04 +10:00
Michael Cahill
0f36f40c37 WT-2702 Block operations when the cache is 100% full. (#2798)
(cherry picked from commit ac14731a59)
2016-06-23 16:02:46 +10:00
David Hows
a6a64e986b WT-2646 Add checkpoint_wait configuration option to drop (#2768)
* Default checkpoint_wait is true. This change is useful because it means concurrent create/drop calls don't generate EBUSY returns.
* Mark lock_wait and checkpoint_wait as undoc

(cherry picked from commit 4b48ad6fb7)
2016-06-02 16:12:21 +10:00
David Hows
234b68b116 WT-2613 Add WT_UNUSED to a variable to fix Windows compilation. (#2717)
(cherry picked from commit 7deb9c213b)
2016-06-01 12:47:25 +10:00
Michael Cahill
5d215904c3 SERVER-24306 Fix stall in log_flush switching to new files. (#2761)
* SERVER-24306 Fix stall in log_flush switching to new files.

* Pass boolean false rather than 0.

(cherry picked from commit b89aaece7b)
2016-06-01 12:44:46 +10:00
Michael Cahill
18879587af WT-2629 Make the stack non-executable with GCC only. (#2742)
(cherry picked from commit f6f86961a4)
2016-06-01 12:41:58 +10:00
Michael Cahill
6bfcb1ca5b WT-2629 Don't make stacks executable in assembly source. (#2739)
(cherry picked from commit 0f7ae730d9)
2016-06-01 12:41:48 +10:00
Alex Gorrod
71c0588a77 Merge pull request #2677 from wiredtiger/wt-2560-spin
WT-2560 Spin on transaction locks.
(cherry picked from commit f498d8c1c1)
2016-06-01 10:48:12 +10:00
Michael Cahill
58765850aa Merge pull request #2660 from wiredtiger/wt-2560
WT-2560 Use a rwlock to protect transaction state, don't spin.
Conflicted on a whitespace cleanup.

(cherry picked from commit 76e286c7ba)
2016-06-01 10:46:47 +10:00
Keith Bostic
30d327f810 Merge pull request #2664 from wiredtiger/wt-2559
WT-2559 Open a local log file handle for sync.
(cherry picked from commit 6b3553003f)
2016-06-01 10:40:38 +10:00
Michael Cahill
88b898e7cb Merge pull request #2670 from wiredtiger/wt-2566
WT-2566 Lock/unlock operations should imply memory barriers.
(cherry picked from commit 05cfbc26c2)
2016-04-20 17:04:16 +10:00
Alex Gorrod
7ea2631de2 Merge branch 'mongodb-3.4' into mongodb-3.2 2016-04-08 16:48:45 +10:00
Michael Cahill
039fe06082 Merge branch 'mongodb-3.4' into mongodb-3.2 2016-04-07 17:29:23 +10:00
Michael Cahill
43e885a0f9 Merge branch 'mongodb-3.4' into mongodb-3.2 2016-03-25 08:19:12 +11:00
Michael Cahill
5cdd3e320c Merge branch 'mongodb-3.2.3' into mongodb-3.2 2016-02-18 14:00:00 +11:00
Michael Cahill
563b7823f7 Merge pull request #2495 from wiredtiger/wt-2397
WT-2397: Cursor traversal from end of the tree skips records.
(cherry picked from commit d915631b)

Manually resolved conflicts from pull request 2478.
2016-02-17 17:30:39 +11:00
Michael Cahill
5e3a56f0ab Merge pull request #2498 from wiredtiger/server-22676
SERVER-22676 Don't check duplicated create calls for matching configurations
(cherry picked from commit 98d6ce255d)
2016-02-17 17:17:20 +11:00
Michael Cahill
bc929dbcf1 Merge branch 'mongodb-3.4' into mongodb-3.2 2016-02-11 12:05:59 +11:00
Michael Cahill
07966a492a Fixup for merge vs backport. 2016-01-28 12:18:13 +11:00
Michael Cahill
67e412d4c5 Merge branch 'develop' into mongodb-3.2 2016-01-28 09:30:32 +11:00
Alex Gorrod
3c2ad56b50 Merge pull request #2415 from wiredtiger/wt-2307-fix
(cherry picked from commit 12aaeb6)

WT-2307: Fix for cursor iteration bug when pages are splitting
2015-12-29 05:42:26 +11:00
Alex Gorrod
b1768d0d9f Revert "Merge pull request #2394 from wiredtiger/SERVER-21887-sample"
The change wasn't ready for back port into 3.2.1

This reverts commit 21b5f9951e.
2015-12-22 08:15:10 +00:00
Alex Gorrod
2893117baa Revert "WT-2291: error: comparison of array 'ins->next' not equal to a null"
The change isn't ready for back port into 3.2.1

This reverts commit 4380cec93d.
2015-12-22 08:14:38 +00:00
Keith Bostic
4380cec93d WT-2291: error: comparison of array 'ins->next' not equal to a null
pointer is always true [-Werror,-Wtautological-pointer-compare]
2015-12-17 10:48:19 +11:00
Alex Gorrod
21b5f9951e Merge pull request #2394 from wiredtiger/SERVER-21887-sample
WT-2291: fix for sampling in newly created trees.
2015-12-17 10:47:55 +11:00
Keith Bostic
decd9166cc __wt_ref_info() and __ref_is_lef() no longer need a WT_SESSION_IMPL
argument, remove it.
2015-12-16 15:54:52 +11:00
Keith Bostic
d835a0c0a8 gcc47 with [-Werror=maybe-uninitialized] reports we can end up with type
uninitialized in __ref_is_leaf() (based on a call to __wt_ref_info()).
It's not really possible because the path where type isn't set is a path
where we panic because the WT_ADDR structure has an impossible type.

We already ignore the __wt_ref_info() error return in one path, and
there are only two paths that care about the returned type; remove the
error check from __wt_ref_info() and set type to 0 in the failing case
(the same value we use when there's no WT_REF addr to check), the code
that calls this function already checks addr on return.

This simplifies __ref_is_leaf() slightly, it now returns a boolean
instead of an error code with a boolean pointer argument.
2015-12-16 15:29:31 +11:00
Keith Bostic
48e1343e40 Merge pull request #2363 from wiredtiger/WT-2262
WT-2262 Have random sampling walk the tree so it isn't biased in skewed trees.
2015-12-16 15:29:13 +11:00
Michael Cahill
eb838c7f12 Merge pull request #2361 from wiredtiger/wt-2260-dont-evict-internal
WT-2260 Avoid adding internal pages to the eviction queue.
2015-12-16 15:28:52 +11:00
Alex Gorrod
a6957512a4 Merge pull request #2358 from wiredtiger/wt-2258-preload-directio 2015-12-16 15:28:11 +11:00
Michael Cahill
197eef00fd Merge branch 'develop' into mongodb-3.2 2015-12-02 22:58:11 +11:00
Michael Cahill
7a4f3259b4 Merge branch 'develop' into mongodb-3.2 2015-12-01 17:12:04 +11:00
Michael Cahill
8326df6b76 Merge branch 'develop' into mongodb-3.2 2015-11-30 15:02:38 +11:00
Keith Bostic
b65381f64c Merge branch 'develop' into mongodb-3.2 2015-11-24 11:29:41 -05:00
Michael Cahill
0019262fed Merge branch 'develop' into mongodb-3.2 2015-11-24 21:59:04 +11:00
Keith Bostic
4d72349b8a Merge branch 'develop' into mongodb-3.2 2015-11-23 09:00:49 -05:00
Michael Cahill
4898aa408f Merge branch 'develop' into mongodb-3.2 2015-11-20 16:58:33 +11:00
Michael Cahill
9d375e3416 Merge branch 'develop' into mongodb-3.2 2015-11-19 17:18:28 +11:00
Michael Cahill
d9ec1ff8ec Merge branch 'develop' into mongodb-3.2 2015-11-11 16:27:42 +11:00
Keith Bostic
465dca8b46 Merge branch 'develop' into mongodb-3.2 2015-11-03 10:33:14 -05:00
Alex Gorrod
f95877af13 Merge branch 'develop' into mongodb-3.2 2015-11-03 22:18:00 +11:00
Alex Gorrod
62c1a7aa36 Merge branch 'develop' into mongodb-3.2 2015-11-02 03:59:53 +00:00
Michael Cahill
0dc3f20df6 Merge branch 'develop' into mongodb-3.2 2015-11-02 11:43:14 +11:00
Michael Cahill
0537648e03 Merge branch 'develop' into mongodb-3.2 2015-10-09 17:07:24 +11:00
Alex Gorrod
3c856645c8 Merge branch 'develop' into mongodb-3.2 2015-09-30 15:01:57 +10:00
Michael Cahill
10208e8284 Merge branch 'develop' into mongodb-3.2 2015-09-25 15:00:04 +10:00
Michael Cahill
16e3e48d98 Merge branch 'develop' into mongodb-3.2 2015-09-18 12:56:14 +10:00
Michael Cahill
5205bb1f0f Merge branch 'develop' into mongodb-3.2 2015-09-11 16:23:01 +10:00
Michael Cahill
dca63120b7 Merge branch 'develop' into mongodb-3.2 2015-09-11 12:21:49 +10:00
sueloverso
0cccab30c0 WT-2064 Don't spin indefinitely waiting for the handle list lock in eviction
Merge pull request #2155 from wiredtiger/WT-2064

(cherry picked from commit 66757f7247)
2015-08-28 11:48:29 +10:00
Alex Gorrod
578a856c19 Merge pull request #2156 from wiredtiger/WT-2066
WT-2066 - Update the oldest transaction ID from eviction
(cherry picked from commit 8f42f02d3c)
2015-08-28 11:47:56 +10:00
Alex Gorrod
a85c5cda41 Merge pull request #2152 from wiredtiger/WT-2062
WT-2062 Try harder to make progress on in-memory splits
(cherry picked from commit 3e0c7bfa3a)
2015-08-28 11:47:30 +10:00
Michael Cahill
6da2dc175b Merge commit '12044d22cce1a79804254ac9c80b1120701bd7c8' into mongodb-3.2 2015-08-28 11:45:48 +10:00
Michael Cahill
7ffa315e39 Merge branch 'develop' into mongodb-3.2 2015-08-18 10:25:36 +10:00
Michael Cahill
26d1ad271f Merge branch 'develop' into mongodb-3.2 2015-08-12 20:36:04 +10:00
Alex Gorrod
fdedd3621c Merge branch 'develop' into mongodb-3.2 2015-07-23 15:53:52 +10:00
Alex Gorrod
4187f419f8 Merge branch 'develop' into mongodb-3.2 2015-07-23 15:50:57 +10:00
Michael Cahill
42823c9682 Merge branch 'develop' into mongodb-3.2 2015-07-17 22:19:04 +10:00
Alex Gorrod
fbaf1cf4f5 Merge branch 'develop' into mongodb-3.2 2015-06-26 05:09:48 +00:00
Alex Gorrod
3d845c98cb Merge branch 'develop' into mongodb-3.2 2015-06-10 18:54:48 +00:00
Michael Cahill
1d2fe8a145 Merge branch 'develop' into mongodb-3.2 2015-06-09 01:26:55 +10:00
Alex Gorrod
bdaaaec87d Merge branch 'develop' into mongodb-3.2 2015-05-29 00:19:26 +00:00
Michael Cahill
35cc116acd Merge branch 'develop' into mongodb-3.2 2015-05-18 15:02:56 +10:00
Alex Gorrod
cbe0fad3e9 Merge branch 'develop' into mongodb-3.2 2015-05-15 06:07:13 +00:00
Michael Cahill
4f9aa1c548 Merge branch 'develop' into mongodb-3.2 2015-05-08 14:19:20 +10:00
Michael Cahill
1f44c05f91 Merge branch 'develop' into mongodb-3.2 2015-04-27 17:43:11 +10:00
Michael Cahill
e31aa8cf29 Merge branch 'develop' into mongodb-3.2 2015-04-27 17:23:58 +10:00
Michael Cahill
c90bc747e1 Merge branch 'develop' into mongodb-3.2 2015-04-24 17:17:50 +10:00
Alex Gorrod
2c1b7aa80b Update MongoDB changelog with latest merge commits. 2015-04-23 17:28:27 +10:00
Alex Gorrod
41762ae13c Merge branch 'develop' into mongodb-3.2 2015-04-23 17:25:06 +10:00
Alex Gorrod
f7691f63a6 Add long version of commit log to NEWS.MONGODB 2015-04-23 17:21:01 +10:00
Alex Gorrod
9be5497753 Add in MongoDB changelog from 3.0 2015-04-23 11:43:19 +10:00
6 changed files with 147 additions and 37 deletions

View File

@@ -0,0 +1,20 @@
# Check create and drop behavior concurrent with checkpoints (WT-2798).
# Setup a multiple tables and a cache size large enough that checkpoints can
# take a long time.
conn_config="cache_size=8GB,log=(enabled=false),checkpoint=(wait=30)"
table_config="leaf_page_max=4k,internal_page_max=16k,type=file"
icount=10000000
table_count=100
table_count_idle=100
# Turn on create/drop of idle tables, but don't worry if individual operations
# take a long time.
idle_table_cycle=120
populate_threads=5
checkpoint_threads=0
report_interval=5
# 100 million
random_range=10000000
run_time=300
# Setup a workload that dirties a lot of the cache
threads=((count=2,reads=1),(count=2,inserts=1),(count=2,updates=1))
value_sz=500

1
dist/s_string.ok vendored
View File

@@ -863,6 +863,7 @@ lu
lwsync
lz
lzo
mT
madvise
majorp
malloc

View File

@@ -22,6 +22,8 @@ __ckpt_server_config(WT_SESSION_IMPL *session, const char **cfg, bool *startp)
*startp = false;
*startp = false;
conn = S2C(session);
WT_RET(__wt_config_gets(session, cfg, "checkpoint.wait", &cval));

View File

@@ -20,6 +20,60 @@ static int __log_write_internal(
#define WT_LOG_OPEN_CREATE_OK 0x01
#define WT_LOG_OPEN_VERIFY 0x02
/*
* __log_wait_for_earlier_slot --
* Wait for write_lsn to catch up to this slot.
*/
static void
__log_wait_for_earlier_slot(WT_SESSION_IMPL *session, WT_LOGSLOT *slot)
{
WT_CONNECTION_IMPL *conn;
WT_LOG *log;
int yield_count;
conn = S2C(session);
log = conn->log;
yield_count = 0;
while (__wt_log_cmp(&log->write_lsn, &slot->slot_release_lsn) != 0) {
/*
* If we're on a locked path and the write LSN is not advancing,
* unlock in case an earlier thread is trying to switch its
* slot and complete its operation.
*/
if (F_ISSET(session, WT_SESSION_LOCKED_SLOT))
__wt_spin_unlock(session, &log->log_slot_lock);
__wt_cond_auto_signal(session, conn->log_wrlsn_cond);
if (++yield_count < WT_THOUSAND)
__wt_yield();
else
__wt_cond_wait(session, log->log_write_cond, 200);
if (F_ISSET(session, WT_SESSION_LOCKED_SLOT))
__wt_spin_lock(session, &log->log_slot_lock);
}
}
/*
* __log_fs_write --
* Wrapper when writing to a log file. If we're writing to a new log
* file for the first time wait for writes to the previous log file.
*/
static int
__log_fs_write(WT_SESSION_IMPL *session,
WT_LOGSLOT *slot, wt_off_t offset, size_t len, const void *buf)
{
/*
* If we're writing into a new log file, we have to wait for all
* writes to the previous log file to complete otherwise there could
* be a hole at the end of the previous log file that we cannot detect.
*/
if (slot->slot_release_lsn.l.file < slot->slot_start_lsn.l.file) {
__log_wait_for_earlier_slot(session, slot);
WT_RET(__wt_log_force_sync(session, &slot->slot_release_lsn));
}
return (__wt_write(session, slot->slot_fh, offset, len, buf));
}
/*
* __wt_log_ckpt --
* Record the given LSN as the checkpoint LSN and signal the archive
@@ -576,7 +630,7 @@ __log_fill(WT_SESSION_IMPL *session,
/*
* If this is a force or unbuffered write, write it now.
*/
WT_ERR(__wt_write(session, myslot->slot->slot_fh,
WT_ERR(__log_fs_write(session, myslot->slot,
myslot->offset + myslot->slot->slot_start_offset,
record->size, record->mem));
@@ -1352,13 +1406,11 @@ __wt_log_release(WT_SESSION_IMPL *session, WT_LOGSLOT *slot, bool *freep)
WT_LSN sync_lsn;
int64_t release_buffered, release_bytes;
uint64_t fsync_duration_usecs;
int yield_count;
bool locked;
conn = S2C(session);
log = conn->log;
locked = false;
yield_count = 0;
if (freep != NULL)
*freep = 1;
release_buffered = WT_LOG_SLOT_RELEASED_BUFFERED(slot->slot_state);
@@ -1379,8 +1431,7 @@ __wt_log_release(WT_SESSION_IMPL *session, WT_LOGSLOT *slot, bool *freep)
/* Write the buffered records */
if (release_buffered != 0)
WT_ERR(__wt_write(session,
slot->slot_fh, slot->slot_start_offset,
WT_ERR(__log_fs_write(session, slot, slot->slot_start_offset,
(size_t)release_buffered, slot->slot_buf.mem));
/*
@@ -1411,22 +1462,7 @@ __wt_log_release(WT_SESSION_IMPL *session, WT_LOGSLOT *slot, bool *freep)
* be holes in the log file.
*/
WT_STAT_CONN_INCR(session, log_release_write_lsn);
while (__wt_log_cmp(&log->write_lsn, &slot->slot_release_lsn) != 0) {
/*
* If we're on a locked path and the write LSN is not advancing,
* unlock in case an earlier thread is trying to switch its
* slot and complete its operation.
*/
if (F_ISSET(session, WT_SESSION_LOCKED_SLOT))
__wt_spin_unlock(session, &log->log_slot_lock);
__wt_cond_auto_signal(session, conn->log_wrlsn_cond);
if (++yield_count < WT_THOUSAND)
__wt_yield();
else
__wt_cond_wait(session, log->log_write_cond, 200);
if (F_ISSET(session, WT_SESSION_LOCKED_SLOT))
__wt_spin_lock(session, &log->log_slot_lock);
}
__log_wait_for_earlier_slot(session, slot);
log->write_start_lsn = slot->slot_start_lsn;
log->write_lsn = slot->slot_end_lsn;

View File

@@ -34,6 +34,7 @@
static char home[512]; /* Program working dir */
static const char *progname; /* Program name */
static const char * const uri = "table:main";
bool inmem;
#define MAX_TH 12
#define MIN_TH 5
@@ -41,7 +42,9 @@ static const char * const uri = "table:main";
#define MIN_TIME 10
#define RECORDS_FILE "records-%" PRIu32
#define ENV_CONFIG \
#define ENV_CONFIG_DEF \
"create,log=(file_max=10M,archive=false,enabled)"
#define ENV_CONFIG_TXNSYNC \
"create,log=(file_max=10M,archive=false,enabled)," \
"transaction_sync=(enabled,method=none)"
#define ENV_CONFIG_REC "log=(recover=on)"
@@ -73,17 +76,28 @@ thread_run(void *arg)
WT_THREAD_DATA *td;
uint64_t i;
int ret;
char buf[MAX_VAL], kname[64];
size_t lsize;
char buf[MAX_VAL], kname[64], lgbuf[8];
char large[128*1024];
__wt_random_init(&rnd);
memset(buf, 0, sizeof(buf));
memset(kname, 0, sizeof(kname));
lsize = sizeof(large);
memset(large, 0, lsize);
td = (WT_THREAD_DATA *)arg;
/*
* The value is the name of the record file with our id appended.
*/
snprintf(buf, sizeof(buf), RECORDS_FILE, td->id);
/*
* Set up a large value putting our id in it. Write it in there a
* bunch of times, but the rest of the buffer can just be zero.
*/
snprintf(lgbuf, sizeof(lgbuf), "th-%" PRIu32, td->id);
for (i = 0; i < 128; i += strlen(lgbuf))
snprintf(&large[i], lsize - i, "%s", lgbuf);
/*
* Keep a separate file with the records we wrote for checking.
*/
@@ -107,8 +121,18 @@ thread_run(void *arg)
*/
for (i = td->start; ; ++i) {
snprintf(kname, sizeof(kname), "%" PRIu64, i);
data.size = __wt_random(&rnd) % MAX_VAL;
cursor->set_key(cursor, kname);
/*
* Every 30th record write a very large record that exceeds the
* log buffer size. This forces us to use the unbuffered path.
*/
if (i % 30 == 0) {
data.size = 128 * 1024;
data.data = large;
} else {
data.size = __wt_random(&rnd) % MAX_VAL;
data.data = buf;
}
cursor->set_value(cursor, &data);
if ((ret = cursor->insert(cursor)) != 0)
testutil_die(ret, "WT_CURSOR.insert");
@@ -136,12 +160,17 @@ fill_db(uint32_t nth)
WT_THREAD_DATA *td;
uint32_t i;
int ret;
const char *envconf;
thr = dcalloc(nth, sizeof(pthread_t));
td = dcalloc(nth, sizeof(WT_THREAD_DATA));
if (chdir(home) != 0)
testutil_die(errno, "Child chdir: %s", home);
if ((ret = wiredtiger_open(NULL, NULL, ENV_CONFIG, &conn)) != 0)
if (inmem)
envconf = ENV_CONFIG_DEF;
else
envconf = ENV_CONFIG_TXNSYNC;
if ((ret = wiredtiger_open(NULL, NULL, envconf, &conn)) != 0)
testutil_die(ret, "wiredtiger_open");
if ((ret = conn->open_session(conn, NULL, NULL, &session)) != 0)
testutil_die(ret, "WT_CONNECTION:open_session");
@@ -187,11 +216,11 @@ main(int argc, char *argv[])
WT_CURSOR *cursor;
WT_SESSION *session;
WT_RAND_STATE rnd;
uint64_t key, last_key;
uint32_t absent, count, i, nth, timeout;
uint64_t absent, count, key, last_key, middle;
uint32_t i, nth, timeout;
int ch, status, ret;
pid_t pid;
bool rand_th, rand_time, verify_only;
bool fatal, rand_th, rand_time, verify_only;
const char *working_dir;
char fname[64], kname[64];
@@ -200,17 +229,21 @@ main(int argc, char *argv[])
else
++progname;
inmem = false;
nth = MIN_TH;
rand_th = rand_time = true;
timeout = MIN_TIME;
verify_only = false;
working_dir = "WT_TEST.random-abort";
while ((ch = __wt_getopt(progname, argc, argv, "h:T:t:v")) != EOF)
while ((ch = __wt_getopt(progname, argc, argv, "h:mT:t:v")) != EOF)
switch (ch) {
case 'h':
working_dir = __wt_optarg;
break;
case 'm':
inmem = true;
break;
case 'T':
rand_th = false;
nth = (uint32_t)atoi(__wt_optarg);
@@ -303,7 +336,9 @@ main(int argc, char *argv[])
testutil_die(ret, "WT_SESSION.open_cursor: %s", uri);
absent = count = 0;
fatal = false;
for (i = 0; i < nth; ++i) {
middle = 0;
snprintf(fname, sizeof(fname), RECORDS_FILE, i);
if ((fp = fopen(fname, "r")) == NULL) {
fprintf(stderr,
@@ -313,8 +348,10 @@ main(int argc, char *argv[])
/*
* For every key in the saved file, verify that the key exists
* in the table after recovery. Since we did write-no-sync, we
* expect every key to have been recovered.
* in the table after recovery. If we're doing in-memory
* log buffering we never expect a record missing in the middle,
* but records may be missing at the end. If we did
* write-no-sync, we expect every key to have been recovered.
*/
for (last_key = UINT64_MAX;; ++count, last_key = key) {
ret = fscanf(fp, "%" SCNu64 "\n", &key);
@@ -338,9 +375,20 @@ main(int argc, char *argv[])
if ((ret = cursor->search(cursor)) != 0) {
if (ret != WT_NOTFOUND)
testutil_die(ret, "search");
printf("%s: no record with key %" PRIu64 "\n",
fname, key);
++absent;
if (!inmem)
printf("%s: no record with key %"
PRIu64 "\n", fname, key);
absent++;
middle = key;
} else if (middle != 0) {
/*
* We should never find an existing key after
* we have detected one missing.
*/
printf("%s: after absent record at %" PRIu64
" key %" PRIu64 " exists\n",
fname, middle, key);
fatal = true;
}
}
if (fclose(fp) != 0)
@@ -348,11 +396,13 @@ main(int argc, char *argv[])
}
if ((ret = conn->close(conn, NULL)) != 0)
testutil_die(ret, "WT_CONNECTION:close");
if (absent) {
printf("%" PRIu32 " record(s) absent from %" PRIu32 "\n",
if (fatal)
return (EXIT_FAILURE);
if (!inmem && absent) {
printf("%" PRIu64 " record(s) absent from %" PRIu64 "\n",
absent, count);
return (EXIT_FAILURE);
}
printf("%" PRIu32 " records verified\n", count);
printf("%" PRIu64 " records verified\n", count);
return (EXIT_SUCCESS);
}

View File

@@ -5,4 +5,5 @@ set -e
# Smoke-test recovery as part of running "make check".
$TEST_WRAPPER ./random-abort -t 10 -T 5
$TEST_WRAPPER ./random-abort -m -t 10 -T 5
$TEST_WRAPPER ./truncated-log