collectd/collectd — pull request #262 by octo (2013-02-23 12:29:46+00:00)
Title: Implement option to create RRD files asynchronously

This adds the *CreateFilesAsync* option to the *rrdtool* and *rrdcached plugins*. This it meant to address scalability issues reported by @ymettier.

Unfortunately, I ran into issues when testing the code: It appears to work in general, but every once in a while *RRDtool* (or, more precisely, *librrd_th*) crashed with a *Bus error* (signal 7) when creating a file:

```
Core was generated by `sbin/collectd -f'.
Program terminated with signal 7, Bus error.
#0 0xb75d924a in rrd_open () from /usr/lib/librrd_th.so.4
(gdb) bt full
#0 0xb75d924a in rrd_open () from /usr/lib/librrd_th.so.4
No symbol table info available.
#1 0xb75e14d0 in ?? () from /usr/lib/librrd_th.so.4
No symbol table info available.
#2 0xb75e1c18 in rrd_create_r () from /usr/lib/librrd_th.so.4
No symbol table info available.
#3 0xb77d887b in srrd_create (filename=0x9f59908 "huhu.verplant.org/memory/memory-buffered.rrd", pdp_step=10, last_up=1361620866, argc=16, argv=0x9f59940) at utils_rrdcreate.c:366
status = 0
filename_copy = 0x9f563e0 "huhu.verplant.org/memory/memory-buffered.rrd"
#4 0xb77d891a in srrd_create_thread (targs=0x9f560c8) at utils_rrdcreate.c:442
args = 0x9f560c8
status = 0
#5 0xb7778955 in start_thread (arg=0xb0dffb70) at pthread_create.c:300
__res =
__ignore1 =
__ignore2 =
pd = 0xb0dffb70
now =
unwind_buf = {cancel_jmp_buf = {{jmp_buf = {-1216835596, 0, 4001536, -1327500136, -283347427, -1075225582}, mask_was_saved = 0}}, priv = {pad = {0x0, 0x0, 0x0, 0x0}, data = {prev = 0x0, cleanup = 0x0, canceltype = 0}}}
not_first_call =
freesize =
__PRETTY_FUNCTION__ = "start_thread"
#6 0xb76ec1de in clone () at ../sysdeps/unix/sysv/linux/i386/clone.S:130
No locals.
```

This might be caused by the plugin trying to update the file before it is (fully) created. Unfortunately, I don't have debugging symbols for librrd available on that machine, so I'll try to reproduce the errors with a different version.

Best regards,
—octo