<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Peer Manager deletes only peer while we still need it -- failed flash write race?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/79001/peer-manager-deletes-only-peer-while-we-still-need-it----failed-flash-write-race</link><description>We are using nrf52840 as a peripheral, Nordic SDK 15.3.0_59ac345. 
 We are experiencing issues in the field where users are unable to reconnect with our device from our app on iOS phones. App logs indicate that link encryption is failing because Status</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 02 Nov 2021 08:09:25 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/79001/peer-manager-deletes-only-peer-while-we-still-need-it----failed-flash-write-race" /><item><title>RE: Peer Manager deletes only peer while we still need it -- failed flash write race?</title><link>https://devzone.nordicsemi.com/thread/336983?ContentTypeID=1</link><pubDate>Tue, 02 Nov 2021 08:09:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:99355f77-e25d-4aea-bb23-69987a46c46b</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Yes, this is resolved in 17.1.0. You can see the diff here:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/cache_5F00_fix.diff"&gt;devzone.nordicsemi.com/.../cache_5F00_fix.diff&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Peer Manager deletes only peer while we still need it -- failed flash write race?</title><link>https://devzone.nordicsemi.com/thread/336927?ContentTypeID=1</link><pubDate>Mon, 01 Nov 2021 17:06:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:900b814f-6764-4570-befe-c41aff8ef047</guid><dc:creator>Jackson Burnette</dc:creator><description>[quote user="eith"]&lt;blockquote&gt;&lt;div&gt;Jackson Burnette said:&lt;/div&gt;&lt;div&gt;It seems like there is a lot of GATT DB cache updates that result in flash changes.&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;
&lt;p&gt;Yes, you are right. The peer manager will write to flash every time a bonded peer connects, as discussed in &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/64609/peer-manager-and-fds-new-records-at-each-connection"&gt;this thread&lt;/a&gt;. This issue will be resolved in the next nRF5 SDK release which is right around the corner.&lt;/p&gt;[/quote]
&lt;p&gt;Hi Einar&amp;nbsp;&lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f44b.svg" title="Wave"&gt;&amp;#x1f44b;&lt;/span&gt; Has the issue been resolved in SDK 17.1.0? If so, is there a diff you can provide of the specific change?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Peer Manager deletes only peer while we still need it -- failed flash write race?</title><link>https://devzone.nordicsemi.com/thread/326848?ContentTypeID=1</link><pubDate>Tue, 24 Aug 2021 15:21:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:660816a5-d688-4d92-9489-5caa3e21f139</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;I am glad to hear that. It is good if you close cases when they are resolved. You do not loos access to them, and can also re-open if needed.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Peer Manager deletes only peer while we still need it -- failed flash write race?</title><link>https://devzone.nordicsemi.com/thread/326847?ContentTypeID=1</link><pubDate>Tue, 24 Aug 2021 13:55:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e1ec1fc6-dbb1-4bc3-aa1b-b1d3dbfa05e8</guid><dc:creator>Jackson Burnette</dc:creator><description>&lt;p&gt;Great, thanks very much Einar. Really appreciate your prompt and informative responses.&lt;/p&gt;
&lt;p&gt;One last question. I&amp;#39;m relatively new to devzone, if I feel you&amp;#39;ve answered my question should I click the &amp;quot;Close this Case&amp;quot; button? If I do, will I lose access to the contents of this post?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Peer Manager deletes only peer while we still need it -- failed flash write race?</title><link>https://devzone.nordicsemi.com/thread/326846?ContentTypeID=1</link><pubDate>Tue, 24 Aug 2021 06:19:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bbc63de0-6000-4fab-a040-7f842747b78f</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user="Jackson Burnette"]It seems like there is a lot of GATT DB cache updates that result in flash changes.[/quote]
&lt;p&gt;Yes, you are right. The peer manager will write to flash every time a bonded peer connects, as discussed in &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/64609/peer-manager-and-fds-new-records-at-each-connection"&gt;this thread&lt;/a&gt;. This issue will be resolved in the next nRF5 SDK release which is right around the corner.&lt;/p&gt;
[quote user="Jackson Burnette"]Does the peer manager take care of deleting the stale GATT DB caches so that they are cleaned up on GC?[/quote]
&lt;p&gt;Yes, old caches are deleted, so GC will free that space.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Peer Manager deletes only peer while we still need it -- failed flash write race?</title><link>https://devzone.nordicsemi.com/thread/326845?ContentTypeID=1</link><pubDate>Mon, 23 Aug 2021 16:19:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0500035c-f084-490e-bc53-7e7d6d9a0b95</guid><dc:creator>Jackson Burnette</dc:creator><description>&lt;p&gt;Thanks for the reply!&lt;/p&gt;
[quote user="eith"]That is the case if you have deleted or updated some records without doing garbage collection before. If so, garbage collection will free the old dirty records, so that you get available space. If not, and you actually have too much data stored (typically also from other FDS data, not related to the peer manger), it will not be enough.[/quote]
&lt;p&gt;&amp;nbsp;It seems like there is a lot of GATT DB cache updates that result in flash changes. I think those updates are a big reason why we&amp;#39;re running out of space so frequently. Does the peer manager take care of deleting the stale GATT DB caches so that they are cleaned up on GC?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Peer Manager deletes only peer while we still need it -- failed flash write race?</title><link>https://devzone.nordicsemi.com/thread/326844?ContentTypeID=1</link><pubDate>Mon, 23 Aug 2021 16:11:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b21de3a9-7c83-4376-a13c-382faaf37bcf</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user=""]If I understand the code and sequence of events correctly, garbage collection without peer deletion would actually be sufficient.[/quote]
&lt;p&gt;That is the case if you have deleted or updated some records without doing garbage collection before. If so, garbage collection will free the old dirty records, so that you get available space. If not, and you actually have too much data stored (typically also from other FDS data, not related to the peer manger), it will not be enough.&lt;/p&gt;
&lt;p&gt;There are a few things to note here, some of which are related to a few things not handled very well in the peer manager. First of all, you cannot delete the bond for a peer that is currently being used. That will lead to undefined behavior in the peer manager. However, the peer manager does not prevent deleting the bond for a peer that is currently connected. Secondly, as you note, the peer manger&amp;nbsp;PM_EVT_STORAGE_FULL will trigger deletion of the oldest peer even if it is the only peer.&lt;/p&gt;
[quote user=""]&lt;div&gt;&lt;span&gt;My current plan is to disable peer ranking in our SDK configuration so that the peer manager will never auto delete any peers. We have internal handling that will mark peers for deletion when they are no longer needed.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Any suggestions or corrections based on the summary above?&lt;/span&gt;&lt;/div&gt;[/quote]
&lt;p&gt;That makes sense. Either that, or improve the peer manager handling of this scenario. Altos, another approach sometimes used is to regularly check the amount of free space in FDS, and do a garbage collection if there is a need for that (there is memory to be freed, and amount of free space is limited). Potentially also delete old and no longer needed data before doing the GC.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Einar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>