jsedding commented on code in PR #2901:
URL: https://github.com/apache/jackrabbit-oak/pull/2901#discussion_r3257799565
##########
oak-segment-remote/src/main/java/org/apache/jackrabbit/oak/segment/remote/persistentcache/package-info.java:
##########
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-@Version("2.0.0")
+@Version("2.1.0")
Review Comment:
Can we avoid this version increase by making the new toggle fields
package-private?
Given that the toggle is meant to be removed again soon, I would like to
avoid bumping the minor version.
##########
oak-segment-remote/src/main/java/org/apache/jackrabbit/oak/segment/remote/persistentcache/PersistentDiskCache.java:
##########
@@ -148,17 +171,27 @@ public void writeSegment(long msb, long lsb, Buffer
buffer) {
Runnable task = () -> {
if (writesPending.add(segmentId)) {
try {
- int fileSize;
- try (FileChannel channel = new
FileOutputStream(tempSegmentFile).getChannel()) {
- fileSize = bufferCopy.write(channel);
- }
- try {
- Files.move(tempSegmentFile.toPath(),
segmentFile.toPath(), StandardCopyOption.ATOMIC_MOVE);
- } catch (AtomicMoveNotSupportedException e) {
- Files.move(tempSegmentFile.toPath(),
segmentFile.toPath());
+ // OAK-12212: skip the on-disk write and the cacheSize
+ // increment when the segment is already on disk. Segments
+ // are immutable, so a redundant write would only rewrite
+ // identical bytes; the pre-fix behaviour still incremented
+ // cacheSize on every such call while Files.move silently
+ // replaced the file on POSIX systems, leaking phantom
+ // bytes into the in-memory counter on every redundant
+ // write. Guarded by FT_OAK-12212 (disabled = active fix).
+ if (FT_OAK_12212_DISABLE.get() || !segmentFile.exists()) {
Review Comment:
To make the code easier to understand, could we rename the toggle?
```suggestion
if (FT_OAK_12212_SKIP_MISSING_FILE_CHECK.get() ||
!segmentFile.exists()) {
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]