| 144 | } |
| 145 | |
| 146 | Future<Void> commit(bool sequential) override { |
| 147 | if (getAvailableSize() <= 0) { |
| 148 | TraceEvent(SevError, "KeyValueStoreMemory_OutOfSpace", id).log(); |
| 149 | return Never(); |
| 150 | } |
| 151 | |
| 152 | if (recovering.isError()) |
| 153 | throw recovering.getError(); |
| 154 | if (!recovering.isReady()) |
| 155 | return waitAndCommit(this, sequential); |
| 156 | |
| 157 | if (!disableSnapshot && replaceContent && !firstCommitWithSnapshot) { |
| 158 | transactionSize += SERVER_KNOBS->REPLACE_CONTENTS_BYTES; |
| 159 | committedWriteBytes += SERVER_KNOBS->REPLACE_CONTENTS_BYTES; |
| 160 | semiCommit(); |
| 161 | } |
| 162 | |
| 163 | if (transactionIsLarge) { |
| 164 | fullSnapshot(data); |
| 165 | resetSnapshot = true; |
| 166 | committedWriteBytes = notifiedCommittedWriteBytes.get(); |
| 167 | overheadWriteBytes = 0; |
| 168 | |
| 169 | if (disableSnapshot) { |
| 170 | return Void(); |
| 171 | } |
| 172 | log_op(OpCommit, StringRef(), StringRef()); |
| 173 | } else { |
| 174 | int64_t bytesWritten = commit_queue(queue, !disableSnapshot, sequential); |
| 175 | |
| 176 | if (disableSnapshot) { |
| 177 | return Void(); |
| 178 | } |
| 179 | |
| 180 | if (bytesWritten > 0 || committedWriteBytes > notifiedCommittedWriteBytes.get()) { |
| 181 | committedWriteBytes += bytesWritten + overheadWriteBytes + |
| 182 | OP_DISK_OVERHEAD; // OP_DISK_OVERHEAD is for the following log_op(OpCommit) |
| 183 | notifiedCommittedWriteBytes.set(committedWriteBytes); // This set will cause snapshot items to be |
| 184 | // written, so it must happen before the OpCommit |
| 185 | log_op(OpCommit, StringRef(), StringRef()); |
| 186 | overheadWriteBytes = log->getCommitOverhead(); |
| 187 | } |
| 188 | } |
| 189 | |
| 190 | auto c = log->commit(); |
| 191 | |
| 192 | committedDataSize = data.sumTo(data.end()); |
| 193 | transactionSize = 0; |
| 194 | transactionIsLarge = false; |
| 195 | firstCommitWithSnapshot = false; |
| 196 | |
| 197 | addActor.send(commitAndUpdateVersions(this, c, previousSnapshotEnd)); |
| 198 | return c; |
| 199 | } |
| 200 | |
| 201 | Future<Optional<Value>> readValue(KeyRef key, IKeyValueStore::ReadType, Optional<UID> debugID) override { |
| 202 | if (recovering.isError()) |
nothing calls this directly
no test coverage detected