diff --git a/oap-storage/oap-storage/src/main/java/oap/storage/MemoryStorage.java b/oap-storage/oap-storage/src/main/java/oap/storage/MemoryStorage.java index e916b55f31..a070a4ab6f 100644 --- a/oap-storage/oap-storage/src/main/java/oap/storage/MemoryStorage.java +++ b/oap-storage/oap-storage/src/main/java/oap/storage/MemoryStorage.java @@ -301,11 +301,20 @@ public boolean put( @Nonnull I id, @Nonnull T object ) { requireNonNull( id ); requireNonNull( object ); return lock.synchronizedOn( id, () -> { - boolean isNew = !data.containsKey( id ); - var nm = data.compute( id, ( anId, m ) -> m != null ? m.update( object ) - : new Metadata<>( object ) ); - log.trace( "storing {}", nm ); - return isNew; + // time: 123 - new Metadata() + // time: 124 - fsync() + // time: 125 - data.put( id, metadata ) + // lastmodified must be set after placing the metadata object in the "data" + final Metadata oldMetadata = data.get( id ); + if( oldMetadata == null ) { + Metadata newMetadata = new Metadata<>( object ); + data.put( id, newMetadata ); + newMetadata.refresh(); + } else { + oldMetadata.update( object ); + } + log.trace( "storing {}", oldMetadata ); + return oldMetadata == null; } ); } diff --git a/pom.xml b/pom.xml index f5083a8d35..b8e5336176 100644 --- a/pom.xml +++ b/pom.xml @@ -65,7 +65,7 @@ - 21.17.0 + 21.17.1 21.0.0 21.0.1