[ 
https://issues.apache.org/jira/browse/BROOKLYN-526?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16114192#comment-16114192
 ] 

Aled Sage commented on BROOKLYN-526:
------------------------------------

This is surprising because we are supposed to be doing an atomic move of the 
file (we write to a temp file, then move it to overwrite the original file - 
therefore avoiding the possibility of something reading the file when it is 
half written).

Either our code isn't doing this as well as I thought, or the OS guarantees for 
such an atomic move are not as strong as I thought!

See {{org.apache.brooklyn.core.mgmt.persist.FileBasedStoreObjectAccessor.put}} 
and its call to 
{{org.apache.brooklyn.core.mgmt.persist.FileBasedObjectStore.move}}, which then 
calls:
{noformat}
java.nio.file.Files.move(srcFile.toPath(), destFile.toPath(), 
StandardCopyOption.ATOMIC_MOVE);
{noformat}

On a quick look, I'm not sure how we could improve that code (without making it 
a lot more complicated, such as multiple files with version numbers in their 
names etc)!


> Laptop crash (?) caused empty files in persisted state
> ------------------------------------------------------
>
>                 Key: BROOKLYN-526
>                 URL: https://issues.apache.org/jira/browse/BROOKLYN-526
>             Project: Brooklyn
>          Issue Type: Bug
>    Affects Versions: 0.11.0
>            Reporter: Aled Sage
>
> My mac laptop crashed while Brooklyn was running. After restart the mac, and 
> restarting Brooklyn, I saw exceptions like that below many times:
> {noformat}
> 2017-08-04 09:23:52,889 WARN  122 o.a.b.c.m.r.RebindExceptionHandlerImpl 
> [ooklyn-persister] Rebind: continuing after problem loading memento: memento 
> ielugq12x0 loading raw error
> org.apache.brooklyn.util.exceptions.PropagatedRuntimeException: 
> SAXParseException: Premature end of file.
>         at 
> org.apache.brooklyn.util.exceptions.Exceptions.propagate(Exceptions.java:129)[143:org.apache.brooklyn.utils-common:0.12.0.SNAPSHOT]
>         at 
> org.apache.brooklyn.util.core.xstream.XmlUtil.xpath(XmlUtil.java:78)[122:org.apache.brooklyn.core:0.12.0.SNAPSHOT]
>         at 
> org.apache.brooklyn.util.core.xstream.XmlUtil.xpathHandlingIllegalChars(XmlUtil.java:100)[122:org.apache.brooklyn.core:0.12.0.SNAPSHOT]
>         at 
> org.apache.brooklyn.util.core.xstream.XmlUtil.xpathHandlingIllegalChars(XmlUtil.java:87)[122:org.apache.brooklyn.core:0.12.0.SNAPSHOT]
>         at 
> org.apache.brooklyn.core.mgmt.persist.BrooklynMementoPersisterToObjectStore$2.visit(BrooklynMementoPersisterToObjectStore.java:335)[122:org.apache.brooklyn.core:0.12.0.SNAPSHOT]
>         at 
> org.apache.brooklyn.core.mgmt.persist.BrooklynMementoPersisterToObjectStore$1VisitorWrapper.run(BrooklynMementoPersisterToObjectStore.java:528)[122:org.apache.brooklyn.core:0.12.0.SNAPSHOT]
>         at 
> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_144]
>         at 
> java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_144]
>         at 
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)[:1.8.0_144]
>         at 
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)[:1.8.0_144]
>         at java.lang.Thread.run(Thread.java:748)[:1.8.0_144]
> Caused by: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; 
> Premature end of file.
>         at 
> com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:257)[:1.8.0_144]
>         at 
> com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:339)[:1.8.0_144]
>         at 
> org.apache.brooklyn.util.core.xstream.XmlUtil.xpath(XmlUtil.java:69)[122:org.apache.brooklyn.core:0.12.0.SNAPSHOT]
>         ... 9 more
> {noformat}
> Looking in the persisted state directory, there are a bunch of size-zero 
> files (for 34 enrichers, 4 feeds, 6 locations and 2 policies)!
> The timestamps for these zero-size files are the newest in the persistence 
> directories.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to