|
26 | 26 | public enum EnvFlags implements MaskedFlag {
|
27 | 27 |
|
28 | 28 | /**
|
29 |
| - * Mmap at a fixed address (experimental). |
| 29 | + * http://www.lmdb.tech/doc/group__mdb.html#ga32a193c6bf4d7d5c5d579e71f22e9340 |
30 | 30 | */
|
| 31 | + |
31 | 32 | /**
|
32 | 33 | * Mmap at a fixed address (experimental).
|
| 34 | + * MDB_FIXEDMAP : Use a fixed address for the mmap region. This flag must be |
| 35 | + * specified when creating the environment, and is stored persistently in the |
| 36 | + * environment. If successful, the memory map will always reside at the same |
| 37 | + * virtual address and pointers used to reference data items in the database will |
| 38 | + * be constant across multiple invocations. This option may not always work, |
| 39 | + * depending on how the operating system has allocated memory to shared |
| 40 | + * libraries and other uses. The feature is highly experimental. |
33 | 41 | */
|
34 | 42 | MDB_FIXEDMAP(0x01),
|
| 43 | + |
35 | 44 | /**
|
36 | 45 | * No environment directory.
|
| 46 | + * MDB_NOSUBDIR : By default, LMDB creates its environment in a directory whose pathname is |
| 47 | + * given in path, and creates its data and lock files under that directory. |
| 48 | + * With this option, path is used as-is for the database main data file. The |
| 49 | + * database lock file is the path with "-lock" appended. |
37 | 50 | */
|
38 | 51 | MDB_NOSUBDIR(0x4000),
|
| 52 | + |
39 | 53 | /**
|
40 |
| - * Don't fsync after commit. |
| 54 | + * MDB_RDONLY : Open the environment in read-only mode. No write operations will |
| 55 | + * be allowed. LMDB will still modify the lock file - except on read-only |
| 56 | + * filesystems, where LMDB does not use locks. |
41 | 57 | */
|
42 |
| - MDB_NOSYNC(0x1_0000), |
| 58 | + MDB_RDONLY_ENV(0x2_0000), |
| 59 | + |
43 | 60 | /**
|
44 |
| - * Read only. |
| 61 | + * MDB_WRITEMAP : Use a writeable memory map unless MDB_RDONLY is set. This is |
| 62 | + * faster and uses fewer mallocs, but loses protection from application bugs |
| 63 | + * like wild pointer writes and other bad updates into the database. |
| 64 | + * Incompatible with nested transactions. Do not mix processes with and without |
| 65 | + * MDB_WRITEMAP on the same environment. This can defeat durability (mdb_env_sync etc). |
45 | 66 | */
|
46 |
| - MDB_RDONLY_ENV(0x2_0000), |
| 67 | + MDB_WRITEMAP(0x8_0000), |
| 68 | + |
47 | 69 | /**
|
48 | 70 | * Don't fsync metapage after commit.
|
| 71 | + * MDB_NOMETASYNC : Flush system buffers to disk only once per transaction, omit the |
| 72 | + * metadata flush. Defer that until the system flushes files to disk, or next non-MDB_RDONLY |
| 73 | + * commit or mdb_env_sync(). This optimization maintains database integrity, but a system |
| 74 | + * crash may undo the last committed transaction. I.e. it preserves the ACI (atomicity, |
| 75 | + * consistency, isolation) but not D (durability) database property. This flag may be |
| 76 | + * changed at any time using mdb_env_set_flags(). |
49 | 77 | */
|
50 | 78 | MDB_NOMETASYNC(0x4_0000),
|
| 79 | + |
51 | 80 | /**
|
52 |
| - * Use writable mmap. |
| 81 | + * Don't fsync after commit. |
| 82 | + * MDB_NOSYNC : Don't flush system buffers to disk when committing a transaction. |
| 83 | + * This optimization means a system crash can corrupt the database or lose the last |
| 84 | + * transactions if buffers are not yet flushed to disk. The risk is governed by how |
| 85 | + * often the system flushes dirty buffers to disk and how often mdb_env_sync() is called. |
| 86 | + * However, if the filesystem preserves write order and the MDB_WRITEMAP flag is not used, |
| 87 | + * transactions exhibit ACI (atomicity, consistency, isolation) properties and only lose D |
| 88 | + * (durability). I.e. database integrity is maintained, but a system crash may undo the |
| 89 | + * final transactions. Note that (MDB_NOSYNC | MDB_WRITEMAP) leaves the system with no hint |
| 90 | + * for when to write transactions to disk, unless mdb_env_sync() is called. |
| 91 | + * (MDB_MAPASYNC | MDB_WRITEMAP) may be preferable. This flag may be changed at any time |
| 92 | + * using mdb_env_set_flags(). |
53 | 93 | */
|
54 |
| - MDB_WRITEMAP(0x8_0000), |
| 94 | + MDB_NOSYNC(0x1_0000), |
| 95 | + |
55 | 96 | /**
|
56 | 97 | * Use asynchronous msync when {@link #MDB_WRITEMAP} is used.
|
| 98 | + * MDB_MAPASYNC : When using MDB_WRITEMAP, use asynchronous flushes to disk. |
| 99 | + * As with MDB_NOSYNC, a system crash can then corrupt the database or lose the |
| 100 | + * last transactions. Calling mdb_env_sync() ensures on-disk database integrity |
| 101 | + * until next commit. This flag may be changed at any time using mdb_env_set_flags(). |
57 | 102 | */
|
58 | 103 | MDB_MAPASYNC(0x10_0000),
|
| 104 | + |
59 | 105 | /**
|
60 | 106 | * Tie reader locktable slots to {@link Txn} objects instead of to threads.
|
| 107 | + * MDB_NOTLS : Don't use Thread-Local Storage. Tie reader locktable slots to |
| 108 | + * MDB_txn objects instead of to threads. I.e. mdb_txn_reset() keeps the slot |
| 109 | + * reseved for the MDB_txn object. A thread may use parallel read-only transactions. |
| 110 | + * A read-only transaction may span threads if the user synchronizes its use. |
| 111 | + * Applications that multiplex many user threads over individual OS threads |
| 112 | + * need this option. Such an application must also serialize the write |
| 113 | + * transactions in an OS thread, since LMDB's write locking is unaware |
| 114 | + * of the user threads. |
61 | 115 | */
|
62 | 116 | MDB_NOTLS(0x20_0000),
|
| 117 | + |
63 | 118 | /**
|
64 | 119 | * Don't do any locking, caller must manage their own locks.
|
| 120 | + * MDB_NOLOCK : Don't do any locking. If concurrent access is anticipated, |
| 121 | + * the caller must manage all concurrency itself. For proper operation |
| 122 | + * the caller must enforce single-writer semantics, and must ensure |
| 123 | + * that no readers are using old transactions while a writer is active. |
| 124 | + * The simplest approach is to use an exclusive lock so that no readers |
| 125 | + * may be active at all when a writer begins. |
65 | 126 | */
|
66 | 127 | MDB_NOLOCK(0x40_0000),
|
| 128 | + |
67 | 129 | /**
|
68 | 130 | * Don't do readahead (no effect on Windows).
|
| 131 | + * MDB_NORDAHEAD : Turn off readahead. Most operating systems perform |
| 132 | + * readahead on read requests by default. This option turns it off if |
| 133 | + * the OS supports it. Turning it off may help random read performance |
| 134 | + * when the DB is larger than RAM and system RAM is full. The option |
| 135 | + * is not implemented on Windows. |
69 | 136 | */
|
70 | 137 | MDB_NORDAHEAD(0x80_0000),
|
| 138 | + |
71 | 139 | /**
|
72 | 140 | * Don't initialize malloc'd memory before writing to datafile.
|
| 141 | + * MDB_NOMEMINIT : Don't initialize malloc'd memory before writing to |
| 142 | + * unused spaces in the data file. By default, memory for pages written |
| 143 | + * to the data file is obtained using malloc. While these pages may be |
| 144 | + * reused in subsequent transactions, freshly malloc'd pages will be |
| 145 | + * initialized to zeroes before use. This avoids persisting leftover |
| 146 | + * data from other code (that used the heap and subsequently freed |
| 147 | + * the memory) into the data file. Note that many other system |
| 148 | + * libraries may allocate and free memory from the heap for |
| 149 | + * arbitrary uses. E.g., stdio may use the heap for file I/O buffers. |
| 150 | + * This initialization step has a modest performance cost so some |
| 151 | + * applications may want to disable it using this flag. This option |
| 152 | + * can be a problem for applications which handle sensitive data |
| 153 | + * like passwords, and it makes memory checkers like Valgrind noisy. |
| 154 | + * This flag is not needed with MDB_WRITEMAP, which writes directly |
| 155 | + * to the mmap instead of using malloc for pages. The initialization |
| 156 | + * is also skipped if MDB_RESERVE is used; the caller is expected to |
| 157 | + * overwrite all of the memory that was reserved in that case. This |
| 158 | + * flag may be changed at any time using mdb_env_set_flags(). |
73 | 159 | */
|
74 | 160 | MDB_NOMEMINIT(0x100_0000);
|
75 | 161 |
|
|
0 commit comments