summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Chen <luke.chen@mongodb.com>2022-12-19 18:08:43 +1100
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-12-19 07:28:46 +0000
commita024a72f29101bce28fc612c7dc02fcf6ea95391 (patch)
tree95b98b378eaae596010f1c766dcb09b2ac1070b8
parent715be2d1a59b914f5902b1cf0daad0dcbaf2154e (diff)
downloadmongo-a024a72f29101bce28fc612c7dc02fcf6ea95391.tar.gz
Import wiredtiger: 4c5b256a1fd4cb08ba970b2eb998a16b0aee6f86 from branch mongodb-4.4
ref: b4da1f016d..4c5b256a1f for: 4.4.19 WT-9599 Acquire the hot backup lock to call fallocate in the block manager
-rw-r--r--src/third_party/wiredtiger/import.data2
-rw-r--r--src/third_party/wiredtiger/src/block/block_write.c11
-rw-r--r--src/third_party/wiredtiger/src/include/os_fhandle_inline.h20
-rw-r--r--src/third_party/wiredtiger/src/log/log.c3
4 files changed, 29 insertions, 7 deletions
diff --git a/src/third_party/wiredtiger/import.data b/src/third_party/wiredtiger/import.data
index 20ffbbe421e..4b69f835232 100644
--- a/src/third_party/wiredtiger/import.data
+++ b/src/third_party/wiredtiger/import.data
@@ -2,5 +2,5 @@
"vendor": "wiredtiger",
"github": "wiredtiger/wiredtiger.git",
"branch": "mongodb-4.4",
- "commit": "b4da1f016dc9e7f83f85f0b5622848a3cc77143a"
+ "commit": "4c5b256a1fd4cb08ba970b2eb998a16b0aee6f86"
}
diff --git a/src/third_party/wiredtiger/src/block/block_write.c b/src/third_party/wiredtiger/src/block/block_write.c
index 442d69927f8..e3522239db3 100644
--- a/src/third_party/wiredtiger/src/block/block_write.c
+++ b/src/third_party/wiredtiger/src/block/block_write.c
@@ -39,9 +39,8 @@ __wt_block_truncate(WT_SESSION_IMPL *session, WT_BLOCK *block, wt_off_t len)
* backups, which only copies log files, or targeted backups, stops all block truncation
* unnecessarily). We may want a more targeted solution at some point.
*/
- if (conn->hot_backup_start == 0) {
+ if (conn->hot_backup_start == 0)
WT_WITH_HOTBACKUP_READ_LOCK(session, ret = __wt_ftruncate(session, block->fh, len), NULL);
- }
/*
* The truncate may fail temporarily or permanently (for example, there may be a file mapping if
@@ -151,10 +150,12 @@ __wt_block_extend(WT_SESSION_IMPL *session, WT_BLOCK *block, WT_FH *fh, wt_off_t
}
/*
- * The extend might fail (for example, the file is mapped into memory), or discover file
- * extension isn't supported; both are OK.
+ * The extend might fail (for example, the file is mapped into memory or a backup is in
+ * progress), or discover file extension isn't supported; both are OK.
*/
- ret = __wt_fextend(session, fh, block->extend_size);
+ if (S2C(session)->hot_backup_start == 0)
+ WT_WITH_HOTBACKUP_READ_LOCK(
+ session, ret = __wt_fextend(session, fh, block->extend_size), NULL);
return (ret == EBUSY || ret == ENOTSUP ? 0 : ret);
}
diff --git a/src/third_party/wiredtiger/src/include/os_fhandle_inline.h b/src/third_party/wiredtiger/src/include/os_fhandle_inline.h
index c79c6ddd155..766a3fd843f 100644
--- a/src/third_party/wiredtiger/src/include/os_fhandle_inline.h
+++ b/src/third_party/wiredtiger/src/include/os_fhandle_inline.h
@@ -51,6 +51,9 @@ static inline int
__wt_fextend(WT_SESSION_IMPL *session, WT_FH *fh, wt_off_t offset)
{
WT_FILE_HANDLE *handle;
+#ifdef HAVE_DIAGNOSTIC
+ wt_off_t cur_size;
+#endif
WT_ASSERT(session, !F_ISSET(S2C(session), WT_CONN_READONLY));
WT_ASSERT(session, !F_ISSET(S2C(session), WT_CONN_IN_MEMORY));
@@ -63,6 +66,13 @@ __wt_fextend(WT_SESSION_IMPL *session, WT_FH *fh, wt_off_t offset)
* function to call.
*/
handle = fh->handle;
+#ifdef HAVE_DIAGNOSTIC
+ /* Make sure we don't try to shrink the file during backup. */
+ if (handle->fh_size != NULL) {
+ WT_RET(handle->fh_size(handle, (WT_SESSION *)session, &cur_size));
+ WT_ASSERT(session, cur_size <= offset || S2C(session)->hot_backup_start == 0);
+ }
+#endif
if (handle->fh_extend_nolock != NULL)
return (handle->fh_extend_nolock(handle, (WT_SESSION *)session, offset));
if (handle->fh_extend != NULL)
@@ -135,6 +145,9 @@ static inline int
__wt_ftruncate(WT_SESSION_IMPL *session, WT_FH *fh, wt_off_t offset)
{
WT_FILE_HANDLE *handle;
+#ifdef HAVE_DIAGNOSTIC
+ wt_off_t cur_size;
+#endif
WT_ASSERT(session, !F_ISSET(S2C(session), WT_CONN_READONLY));
@@ -146,6 +159,13 @@ __wt_ftruncate(WT_SESSION_IMPL *session, WT_FH *fh, wt_off_t offset)
* function to call.
*/
handle = fh->handle;
+#ifdef HAVE_DIAGNOSTIC
+ /* Make sure we don't try to shrink the file during backup. */
+ if (handle->fh_size != NULL) {
+ WT_RET(handle->fh_size(handle, (WT_SESSION *)session, &cur_size));
+ WT_ASSERT(session, cur_size <= offset || S2C(session)->hot_backup_start == 0);
+ }
+#endif
if (handle->fh_truncate != NULL)
return (handle->fh_truncate(handle, (WT_SESSION *)session, offset));
return (__wt_set_return(session, ENOTSUP));
diff --git a/src/third_party/wiredtiger/src/log/log.c b/src/third_party/wiredtiger/src/log/log.c
index 0222230a473..e2104268277 100644
--- a/src/third_party/wiredtiger/src/log/log.c
+++ b/src/third_party/wiredtiger/src/log/log.c
@@ -600,7 +600,8 @@ __log_prealloc(WT_SESSION_IMPL *session, WT_FH *fh)
/*
* We have exclusive access to the log file and there are no other writes happening
- * concurrently, so there are no locking issues.
+ * concurrently, so there are no locking issues. We don't need to worry about hot backup because
+ * logging never reduces the length of the file in pre-allocate.
*/
ret = __wt_fextend(session, fh, conn->log_extend_len);
return (ret == EBUSY || ret == ENOTSUP ? 0 : ret);