foundationdb icon indicating copy to clipboard operation
foundationdb copied to clipboard

FoundationDB fails to read the entire foundationdb.conf file sometimes

Open spullara opened this issue 8 years ago • 4 comments

On Mac, using 5.1.7, I can edit the foundationdb.conf file to add more processes while the cluster is running and sometimes it fails to read the whole file and only a subset are launched. In these cases, additionally I lose the backup_agent since it is at the end of the file as well. I'm not sure if it is because emacs is writing it in chunks and fdb is catching the update before the whole file is written or that fdb is somehow not finishing the file. My guess is the former. Might need to wait to read the file for some short amount of time to ensure the entire file has been written.

I can repo it by adding multiple processes at a time, excluding them, and then removing and adding them back in until it failed to start one.

## An individual fdbserver process with id 4689                                                                                                                          
## Parameters set here override defaults from the [fdbserver] section                                                                                                    
[fdbserver.4689]
[fdbserver.4690]
[fdbserver.4691]
[fdbserver.4692]
[fdbserver.4693]

Here is adding 4, removing 4 and then adding 4 but it only starts 3 the second time — it also stops the backup agent as it is after the fdbserver stanzas:

Time="1525723281.215091" Severity="10" LogGroup="default" Process="fdbmonitor": Updated configuration for fdbserver.4689
Time="1525723281.215162" Severity="10" LogGroup="default" Process="fdbmonitor": Starting fdbserver.4690
Time="1525723281.215691" Severity="10" LogGroup="default" Process="fdbmonitor": Starting fdbserver.4691
Time="1525723281.216554" Severity="10" LogGroup="default" Process="fdbmonitor": Starting fdbserver.4692
Time="1525723281.217249" Severity="10" LogGroup="default" Process="fdbmonitor": Starting fdbserver.4693
Time="1525723281.217920" Severity="10" LogGroup="default" Process="fdbmonitor": Watching conf dir /usr/local/etc/foundationdb
Time="1525723281.218011" Severity="10" LogGroup="default" Process="fdbserver.4690": Launching /usr/local/libexec/fdbserver (91604) for fdbserver.4690
Time="1525723281.218033" Severity="10" LogGroup="default" Process="fdbserver.4691": Launching /usr/local/libexec/fdbserver (91605) for fdbserver.4691
Time="1525723281.218191" Severity="10" LogGroup="default" Process="fdbserver.4692": Launching /usr/local/libexec/fdbserver (91606) for fdbserver.4692
Time="1525723281.218462" Severity="10" LogGroup="default" Process="fdbserver.4693": Launching /usr/local/libexec/fdbserver (91607) for fdbserver.4693
Time="1525723281.281171" Severity="10" LogGroup="default" Process="fdbserver.4693": FDBD joined cluster.
Time="1525723281.284636" Severity="10" LogGroup="default" Process="fdbserver.4691": FDBD joined cluster.
Time="1525723281.284743" Severity="10" LogGroup="default" Process="fdbserver.4692": FDBD joined cluster.
Time="1525723281.287491" Severity="10" LogGroup="default" Process="fdbserver.4690": FDBD joined cluster.
Time="1525723291.241853" Severity="10" LogGroup="default" Process="fdbmonitor": Loading configuration /usr/local/etc/foundationdb/foundationdb.conf
Time="1525723291.242193" Severity="10" LogGroup="default" Process="fdbmonitor": Updated configuration for fdbserver.4693
Time="1525723291.242279" Severity="10" LogGroup="default" Process="fdbmonitor": Updated configuration for fdbserver.4692
Time="1525723291.242357" Severity="10" LogGroup="default" Process="fdbmonitor": Updated configuration for fdbserver.4691
Time="1525723291.242435" Severity="10" LogGroup="default" Process="fdbmonitor": Updated configuration for fdbserver.4690
Time="1525723291.242501" Severity="10" LogGroup="default" Process="fdbmonitor": Updated configuration for backup_agent.1
Time="1525723291.242562" Severity="10" LogGroup="default" Process="fdbmonitor": Updated configuration for fdbserver.4689
Time="1525723291.242665" Severity="10" LogGroup="default" Process="fdbmonitor": Watching conf dir /usr/local/etc/foundationdb
Time="1525723292.826973" Severity="10" LogGroup="default" Process="fdbmonitor": Loading configuration /usr/local/etc/foundationdb/foundationdb.conf
Time="1525723292.827379" Severity="10" LogGroup="default" Process="fdbmonitor": Deconfigured fdbserver.4693
Time="1525723292.827430" Severity="10" LogGroup="default" Process="fdbmonitor": Deconfigured fdbserver.4692
Time="1525723292.827460" Severity="10" LogGroup="default" Process="fdbmonitor": Deconfigured fdbserver.4691
Time="1525723292.827490" Severity="10" LogGroup="default" Process="fdbmonitor": Deconfigured fdbserver.4690
Time="1525723292.827579" Severity="10" LogGroup="default" Process="fdbmonitor": Updated configuration for backup_agent.1
Time="1525723292.827683" Severity="10" LogGroup="default" Process="fdbmonitor": Updated configuration for fdbserver.4689
Time="1525723292.827723" Severity="10" LogGroup="default" Process="fdbmonitor": Killing process 91607
Time="1525723292.829807" Severity="10" LogGroup="default" Process="fdbmonitor": Killing process 91606
Time="1525723292.831741" Severity="10" LogGroup="default" Process="fdbmonitor": Killing process 91605
Time="1525723292.833141" Severity="10" LogGroup="default" Process="fdbmonitor": Killing process 91604
Time="1525723292.834706" Severity="10" LogGroup="default" Process="fdbmonitor": Watching conf dir /usr/local/etc/foundationdb
Time="1525723306.775089" Severity="10" LogGroup="default" Process="fdbmonitor": Loading configuration /usr/local/etc/foundationdb/foundationdb.conf
Time="1525723306.775389" Severity="10" LogGroup="default" Process="fdbmonitor": Updated configuration for backup_agent.1
Time="1525723306.775446" Severity="10" LogGroup="default" Process="fdbmonitor": Updated configuration for fdbserver.4689
Time="1525723306.775502" Severity="10" LogGroup="default" Process="fdbmonitor": Watching conf dir /usr/local/etc/foundationdb
Time="1525723308.686704" Severity="10" LogGroup="default" Process="fdbmonitor": Loading configuration /usr/local/etc/foundationdb/foundationdb.conf
Time="1525723308.688478" Severity="10" LogGroup="default" Process="fdbmonitor": Deconfigured backup_agent.1
Time="1525723308.688628" Severity="10" LogGroup="default" Process="fdbmonitor": Updated configuration for fdbserver.4689
Time="1525723308.688719" Severity="10" LogGroup="default" Process="fdbmonitor": Killing process 91602
Time="1525723308.690145" Severity="10" LogGroup="default" Process="fdbmonitor": Starting fdbserver.4690
Time="1525723308.690680" Severity="10" LogGroup="default" Process="fdbmonitor": Starting fdbserver.4691
Time="1525723308.691328" Severity="10" LogGroup="default" Process="fdbmonitor": Starting fdbserver.4692
Time="1525723308.691848" Severity="10" LogGroup="default" Process="fdbmonitor": Watching conf dir /usr/local/etc/foundationdb
Time="1525723308.692165" Severity="10" LogGroup="default" Process="fdbserver.4690": Launching /usr/local/libexec/fdbserver (91612) for fdbserver.4690
Time="1525723308.692192" Severity="10" LogGroup="default" Process="fdbserver.4691": Launching /usr/local/libexec/fdbserver (91613) for fdbserver.4691
Time="1525723308.692800" Severity="10" LogGroup="default" Process="fdbserver.4692": Launching /usr/local/libexec/fdbserver (91614) for fdbserver.4692
Time="1525723308.757531" Severity="10" LogGroup="default" Process="fdbserver.4690": FDBD joined cluster.
Time="1525723308.758014" Severity="10" LogGroup="default" Process="fdbserver.4692": FDBD joined cluster.
Time="1525723308.758150" Severity="10" LogGroup="default" Process="fdbserver.4691": FDBD joined cluster.

spullara avatar May 10 '18 22:05 spullara

We should update the docs to specify the foundationdb.conf file must be replaced atomically. Editing the conf file in this way will avoid this pathology.

hgray1 avatar Oct 22 '18 20:10 hgray1

So the best practice would be to copy the file, edit it and move it on top of the original file? Makes sense but I also think short pause before reading it on update would probably make this a non-issue since it is so small. Being able to edit it or copy over it seems useful. Another option would be to require a HUP to reread it.

spullara avatar Oct 24 '18 04:10 spullara

Yes, that is the best practice. I don't think it's super common for applications to allow outside live editing / partial re-writes of monitored files in an iron-clad way, which perhaps is why many text editors such as vi will save the file contents to a new file and then rename it into place so that any application using the file sees all of the changes atomically.

It's true that in many cases waiting a bit would avoid reading a partially written file, but it's not really a fix for the problem and creates an additional delay before changes take effect. Yes it could be a quite small delay (at least for local filesystems!), but as it is entirely artificial it should be documented (and maybe configurable?) and the existence of such a delay suggests that it is at least somewhat OK to write the file directly (via editing or some config generator) however it's just not OK if you really care about availability.

What all this adds up to is we feel it's best to just document clearly that the config file must be replaced atomically.

satherton avatar Oct 25 '18 23:10 satherton

PR for doc change: https://github.com/apple/foundationdb/pull/900

satherton avatar Nov 08 '18 01:11 satherton