Skip to content

Commit

Permalink
OAP-260 fix: oap.storage.FilePersistenceTest.fsync
Browse files Browse the repository at this point in the history
  • Loading branch information
nofateg authored Mar 20, 2024
1 parent bd3e57f commit c73bd55
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> oldMetadata = data.get( id );
if( oldMetadata == null ) {
Metadata<T> newMetadata = new Metadata<>( object );
data.put( id, newMetadata );
newMetadata.refresh();
} else {
oldMetadata.update( object );
}
log.trace( "storing {}", oldMetadata );
return oldMetadata == null;
} );
}

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
</repositories>

<properties>
<oap.project.version>21.17.0</oap.project.version>
<oap.project.version>21.17.1</oap.project.version>

<oap.deps.config.version>21.0.0</oap.deps.config.version>
<oap.deps.oap-teamcity.version>21.0.1</oap.deps.oap-teamcity.version>
Expand Down

0 comments on commit c73bd55

Please sign in to comment.