# Race Conditions

**URL:** <https://discourse.chef.io/t/race-conditions/4503>\
**Category:** Chef Infra (archive)\
**Created:** [September 27, 2013, 6:44am UTC](https://discourse.chef.io/t/race-conditions/4503 "2013-09-27T06:44:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Greg\_Zapp](https://avatars.discourse-cdn.com/v4/letter/g/cab0a1/32.png) [@Greg\_Zapp](https://discourse.chef.io/u/Greg_Zapp)\
**Post date:** [September 27, 2013, 6:44am UTC](https://discourse.chef.io/t/race-conditions/4503/1 "2013-09-27T06:44:43Z")

</div>

Hello,

I have a few nagging questions about Chef. One of them revolves around  
potential race conditions in updating nodes and databags on Chef Server.  
For the life of me I am unable to find any information on how Chef updates  
node information on the server side. Does it merge changed keys? Does it  
fully overwrite all json keys? If a client run starts and then some  
external force updates the node on the server, will node.save(s) on the  
client overwrite that information? What about data bags?

I would appreciate any information that could be provided on this topic.  
I’m considering drastic measures to to my lack of understanding of the  
internals:  
\*Only nodes update their attributes  
\*Databags have ONE writer, multiple readers  
\*Desired state stored in data bags  
\*Current state stored in node attributes or other data bags

@.@

Thanks,  
Greg

---

<div class="post-metadata">

**Author:** ![coderanger](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/coderanger/32/5_2.png) [@coderanger](https://discourse.chef.io/u/coderanger)\
**Post date:** [September 27, 2013, 6:49am UTC](https://discourse.chef.io/t/race-conditions/4503/2 "2013-09-27T06:49:19Z")

</div>

All Chef APIs are last-writer-wins at a per-object level.

--Noah

On Sep 27, 2013, at 1:44 AM, Greg Zapp [greg.zapp@gmail.com](mailto:greg.zapp@gmail.com) wrote:

> Hello,
> 
> I have a few nagging questions about Chef. One of them revolves around potential race conditions in updating nodes and databags on Chef Server. For the life of me I am unable to find any information on how Chef updates node information on the server side. Does it merge changed keys? Does it fully overwrite all json keys? If a client run starts and then some external force updates the node on the server, will node.save(s) on the client overwrite that information? What about data bags?
> 
> I would appreciate any information that could be provided on this topic. I'm considering drastic measures to to my lack of understanding of the internals:  
> \*Only nodes update their attributes  
> \*Databags have ONE writer, multiple readers  
> \*Desired state stored in data bags  
> \*Current state stored in node attributes or other data bags
> 
> @.@
> 
> Thanks,  
> Greg

---

<div class="post-metadata">

**Author:** ![Kadel\_Garcia\_Nico](https://avatars.discourse-cdn.com/v4/letter/k/50afbb/32.png) [@Kadel\_Garcia\_Nico](https://discourse.chef.io/u/Kadel_Garcia_Nico)\
**Post date:** [September 27, 2013, 11:02am UTC](https://discourse.chef.io/t/race-conditions/4503/3 "2013-09-27T11:02:31Z")

</div>

Greg, I’m also pretty new to chef. But looking at the content of a Chef server, I see a PostgreSQL database running in /var/opt/chef-server/postgresql, so it looks like a database upload operation. That implies atomic transactions, so uploads one at a time sounds right.

* * *

From: Greg Zapp [greg.zapp@gmail.com]  
Sent: Friday, September 27, 2013 2:44 AM  
To: [chef@lists.opscode.com](mailto:chef@lists.opscode.com)  
Subject: [chef] Race Conditions

Hello,

I have a few nagging questions about Chef. One of them revolves around potential race conditions in updating nodes and databags on Chef Server. For the life of me I am unable to find any information on how Chef updates node information on the server side. Does it merge changed keys? Does it fully overwrite all json keys? If a client run starts and then some external force updates the node on the server, will node.save(s) on the client overwrite that information? What about data bags?

I would appreciate any information that could be provided on this topic. I’m considering drastic measures to to my lack of understanding of the internals:  
\*Only nodes update their attributes  
\*Databags have ONE writer, multiple readers  
\*Desired state stored in data bags  
\*Current state stored in node attributes or other data bags

@.@

Thanks,  
Greg
