Skip to content

Commit cadbc8e

Browse files
authored
Merge pull request #26113 from rwestMSFT/rw-0217-fua-linux
Add FUA KB info to PMEM on Linux page
2 parents bfb64ee + f5de025 commit cadbc8e

3 files changed

Lines changed: 87 additions & 62 deletions

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
author: rwestMSFT
3+
ms.author: randolphwest
4+
ms.date: 02/21/2023
5+
ms.service: sql
6+
ms.subservice: linux
7+
ms.topic: include
8+
---
9+
Certain versions of supported Linux distributions provide support for FUA I/O subsystem capability, which provides data durability. [!INCLUDE [ssnoversion-md](../../includes/ssnoversion-md.md)] uses FUA capability to provide highly efficient and reliable I/O for [!INCLUDE [ssnoversion-md](../../includes/ssnoversion-md.md)] workloads. For more information on FUA support by Linux distribution and its effect on [!INCLUDE [ssnoversion-md](../../includes/ssnoversion-md.md)], see [SQL Server On Linux: Forced Unit Access (FUA) Internals](https://techcommunity.microsoft.com/t5/sql-server-blog/sql-server-on-linux-forced-unit-access-fua-internals/ba-p/3199102).
10+
11+
SUSE Linux Enterprise Server 12 SP5, Red Hat Enterprise Linux 8.0, and Ubuntu 18.04 introduced support for FUA capability in the I/O subsystem. If you're using [!INCLUDE [sssql17-md](../../includes/sssql17-md.md)] CU 6 and later versions, you should use following configuration for high performing and efficient I/O implementation with FUA by [!INCLUDE [ssnoversion-md](../../includes/ssnoversion-md.md)].
12+
13+
Use this recommended configuration if the following conditions are met.
14+
15+
- Using [!INCLUDE [sssql17-md](../../includes/sssql17-md.md)] CU 6 and later versions
16+
- Using a Linux distribution and version that supports FUA capability (starting with Red Hat Enterprise Linux 8.0, SUSE Linux Enterprise Server 12 SP5, or Ubuntu 18.04)
17+
- On storage subsystem and/or hardware that supports and is configured for FUA capability
18+
19+
Recommended configuration:
20+
21+
1. Enable Trace Flag 3979 as a startup parameter
22+
1. Use **mssql-conf** to configure `control.writethrough = 1` and `control.alternatewritethrough = 0`
23+
24+
For almost all other configuration that doesn't meet the previous conditions, the recommended configuration is as follows:
25+
26+
1. Enable Trace Flag 3982 as a startup parameter (which is the default for [!INCLUDE [ssnoversion-md](../../includes/ssnoversion-md.md)] in the Linux ecosystem), and make sure that Trace Flag 3979 isn't enabled as a startup parameter
27+
1. Use **mssql-conf** to configure `control.writethrough = 1` and `control.alternatewritethrough = 1`

docs/linux/sql-server-linux-configure-pmem.md

Lines changed: 39 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,28 @@
11
---
22
title: Configure persistent memory (PMEM) - Linux
33
description: Learn how to configure persistent memory (PMEM) for SQL Server on Linux, and how to create namespaces for PMEM devices
4-
ms.custom: seo-lt-2019
5-
author: briancarrig
4+
author: briancarrig
65
ms.author: brcarrig
7-
ms.date: 09/21/2021
8-
ms.topic: conceptual
6+
ms.reviewer: randolphwest
7+
ms.date: 02/21/2023
98
ms.service: sql
109
ms.subservice: linux
10+
ms.topic: conceptual
11+
ms.custom: seo-lt-2019
1112
monikerRange: ">= sql-server-linux-ver15 || >= sql-server-ver15"
1213
---
1314
# Configure persistent memory (PMEM) for SQL Server on Linux
1415

1516
[!INCLUDE [SQL Server - Linux](../includes/applies-to-version/sql-linux.md)]
1617

17-
This article describes how to configure the persistent memory (PMEM) for [!INCLUDE[sqlv15](../includes/sssql19-md.md)] on Linux.
18+
This article describes how to configure the persistent memory (PMEM) for [!INCLUDE [sssql19-md](../includes/sssql19-md.md)] and later versions on Linux.
1819

1920
## Overview
2021

21-
[!INCLUDE[sqlv15](../includes/sssql19-md.md)] has many in-memory features that use persistent memory. This document covers the steps required to configure persistent memory for SQL Server on Linux.
22+
[!INCLUDE [sssql19-md](../includes/sssql19-md.md)] introduced many in-memory features that use persistent memory. This article covers the steps required to configure persistent memory for [!INCLUDE [ssnoversion-md](../includes/ssnoversion-md.md)] on Linux.
2223

23-
> [!NOTE]
24-
> The term _enlightenment_ was introduced to convey the concept of working with a persistent memory aware file system. Direct access to the file system from user-space applications is facilitated using memory mapping (`mmap()`). When a memory mapping for a file is created the application can issue load/store instructions bypassing the I/O stack completely. This is considered an "enlightened" file access method from the perspective of the host extension application (which is the black box code that allows SQLPAL interact with the Windows or Linux OS).
24+
> [!NOTE]
25+
> The term _enlightenment_ was introduced to convey the concept of working with a persistent memory aware file system. Direct access to the file system from user-space applications is facilitated using memory mapping (`mmap()`). When a memory mapping for a file is created the application can issue load/store instructions bypassing the I/O stack completely. This is considered an "enlightened" file access method from the perspective of the host extension application (which is the code that allows SQLPAL interact with the Windows or Linux OS).
2526
2627
## Create namespaces for PMEM devices
2728

@@ -30,16 +31,16 @@ This article describes how to configure the persistent memory (PMEM) for [!INCLU
3031
In Linux, use the `ndctl` utility.
3132

3233
- Install `ndctl` to configure PMEM device. You can find it [here](https://docs.pmem.io/getting-started-guide/installing-ndctl).
33-
- Use `ndctl` to create a namespace. Namespaces are interleaved across PMEM NVDIMMs and can provide different types of user-space access to memory regions on the device. `fsdax` is default and desired mode for SQL Server.
34+
- Use `ndctl` to create a namespace. Namespaces are interleaved across PMEM NVDIMMs and can provide different types of user-space access to memory regions on the device. `fsdax` is default and desired mode for [!INCLUDE [ssnoversion-md](../includes/ssnoversion-md.md)].
3435

35-
```bash
36-
ndctl create-namespace -f -e namespace0.0 --mode=fsdax* --map=dev
36+
```bash
37+
ndctl create-namespace -f -e namespace0.0 --mode=fsdax --map=dev
3738
```
3839

39-
We have chosen `fsdax` mode and are using system memory to store per-page metadata. We recommend using `--map=dev`. This stores the meta data on the namespace directly. Storing meta data in memory using `--map=mem` is considered experimental at this time.
40+
We have chosen `fsdax` mode and are using system memory to store per-page metadata. We recommend using `--map=dev`. This option stores the meta data on the namespace directly. Storing meta data in memory using `--map=mem` is experimental at this time.
41+
42+
Use `ndctl` to verify the namespace.
4043

41-
Use `ndctl` to verify the namespace.
42-
4344
Sample output follows:
4445

4546
```bash
@@ -74,33 +75,48 @@ mount -o dax,noatime /dev/pmem0 /mnt/dax
7475

7576
## Technical considerations
7677

77-
- Block allocation of 2 MB for either XFS/EXT4, as described above
78+
- Block allocation of 2 MB for either XFS/EXT4, as described previously
7879
- Misalignment between block allocation and `mmap` results in silent fallback to 4 KB
7980
- File sizes should be a multiple of 2 MB (modulo 2 MB)
80-
- Do not disable transparent huge pages (THP) (enabled by default on most distros)
81+
- Don't disable transparent huge pages (THP) (enabled by default on most distributions)
8182

82-
Once the device has been configured with `ndctl`, created, and mounted, you can place database files in it or create a new database.
83+
Once the device is configured with `ndctl`, created, and mounted, you can place database files in it or create a new database.
8384

84-
You can store the SQL Server data files (MDFS, NDFS) and tempdb files on a PMEM device when configured with the mode `fsdax` using the command below. This shouldn't be used to store the SQL Server log (LDFS) files, as transaction log needs to be on storage that provides sector atomic guarantees:
85+
You can store the [!INCLUDE [ssnoversion-md](../includes/ssnoversion-md.md)] data files (MDFS, NDFS) and `tempdb` files on a PMEM device when configured with the mode `fsdax` using the following command. Don't use this to store the [!INCLUDE [ssnoversion-md](../includes/ssnoversion-md.md)] log (LDFS) files, as transaction log needs to be on storage that provides sector atomic guarantees:
8586

8687
```bash
8788
ndctl create-namespace -f -e namespace0.0 --mode=fsdax --map=dev
8889
```
8990

9091
Before you set the map option in the preceding command, keep the following points in mind:
9192

92-
- For best performance at accessing and updating these NVDIMM page entries for this device, it's preferable to use `-map=mem `
93+
- For best performance at accessing and updating these NVDIMM page entries for this device, it's preferable to use `-map=mem`
9394
- If the capacity of the NVDIMM is too large (greater than 512 GB), set the `–map=dev`, which would impact the IO throughput and stymie the performance
9495

95-
For SQL Server log files on PMEM devices, provision the PMEM device(s) to use sector/Block Translation Table (BTT). This provides the needed sector atomicity for SQL Server logs files for this technology of storage devices. We also recommend that you perform workload performance validations and compare the SQL Server log performance for your workload between this solution and best-in-class NVMe SSDs, and then select the solution that best meets your needs and provides better performance.
96+
For [!INCLUDE [ssnoversion-md](../includes/ssnoversion-md.md)] log files on PMEM devices, con the PMEM device(s) to use sector/Block Translation Table (BTT). This provides the needed sector atomicity for [!INCLUDE [ssnoversion-md](../includes/ssnoversion-md.md)] logs files for this technology of storage devices. We also recommend that you perform workload performance validations. You can compare the [!INCLUDE [ssnoversion-md](../includes/ssnoversion-md.md)] log performance for your workload between this solution and best-in-class NVMe SSDs, and then select the solution that best meets your needs and provides better performance.
9697

9798
```bash
9899
ndctl create-namespace -f -e namespace0.0 --mode= sector
99100
```
100101

101-
Because PMEM devices are O_DIRECT (direct I/O) safe, consider enabling trace flag 3979 to disable the forced flush mechanism. For more information, see [FUA support](https://support.microsoft.com/help/4131496/enable-forced-flush-mechanism-in-sql-server-2017-on-linux). Forced unit access internals are covered here [FUA internals](/archive/blogs/bobsql/sql-server-on-linux-forced-unit-access-fua-internals).
102+
### Disable forced flush behavior
103+
104+
Because PMEM devices are `O_DIRECT` (direct I/O) safe, you can [disable the forced flush behavior](#sql-server-and-forced-unit-access-fua-io-subsystem-capability).
105+
106+
> [!NOTE]
107+
> A storage system can make sure that any cached or staged writes are considered safe and durable, by guaranteeing that writes issued to the device are kept on a medium that will persist across system crashes, interface resets and power failures, and the medium itself is hardware redundant.
108+
109+
- Database (`.mdf` and `.ndf`) and transaction log (`.ldf`) files don't use `writethrough` and `alternatewritethrough` by default in [!INCLUDE [sssql17-md](../includes/sssql17-md.md)] CU 6 and later versions, because they use the forced flush behavior. Trace Flag 3979 disables the use of the forced flush behavior for database and transaction log files, and uses the `writethrough` and `alternatewritethrough` logic.
110+
111+
- Other files that are opened by using `FILE_FLAG_WRITE_THROUGH` in [!INCLUDE [ssnoversion-md](../includes/ssnoversion-md.md)], such as database snapshots, internal snapshots for database consistency checks (`DBCC CHECKDB`), profiler trace files, and extended event trace files, use the `writethrough` and `alternatewritethrough` optimizations.
112+
113+
For more information about the changes introduced in [!INCLUDE [sssql17-md](../includes/sssql17-md.md)] CU 6, see [KB 4131496](https://support.microsoft.com/help/4131496). For more information about forced unit access (FUA) internals, see [FUA internals](/archive/blogs/bobsql/sql-server-on-linux-forced-unit-access-fua-internals).
114+
115+
#### SQL Server and Forced Unit Access (FUA) I/O subsystem capability
116+
117+
[!INCLUDE [linux-forced-unit-access](includes/linux-forced-unit-access.md)]
102118

103119
## Next steps
104120

105-
For more information about SQL Server on Linux, see [SQL Server on Linux](sql-server-linux-overview.md).
106-
For performance best practices for SQL Server on Linux, see [Performance Best Practices](sql-server-linux-performance-best-practices.md).
121+
- [SQL Server on Linux](sql-server-linux-overview.md)
122+
- [Performance Best Practices](sql-server-linux-performance-best-practices.md)

0 commit comments

Comments
 (0)