22.10.2013 17:54, David Lang:

Then, there is need for each global variable to be lockable. But then, it can lead to a deadlocks...

Each global variable needs to eithe be lockable or manipulated with atomic statements.

And if we talk about global containers which can contain properties, it becomes even harder.

Rainer is saying that he thinks they may be able to be used in if statements, you already can't use functions in templates, so I don't see that as a problem.

Let's see, I would say.

I think that, given current SIMD engine, the problem arises every time when a global variable is used more than once for one message. But how to prevent this? Having global(key="$/var") as a function leads to natural expressions like this:

if global(key="$/var") % 3 == 0 then
    Action(1)
else if global(key="$/var") % 3 == 1 then
    Action(2)
else
    Action(3)

But, obviously, it is not better than having $/ directly.

So, what to do?

We can force user to export global value to userspace, having a way to access globals, but not using them in expressions. By an action, for example:

action(type="mmglobal" mode="get" global="$/var" var=".counter")

It is still not prevents a user to access globals twice, but makes it unnatural. (And it can even be useful to count messages in a batch.)


And one more idea. What if engine caches global value to message space on first access, then all subsequent reads of the same global are served locally? It seemes facilitating main issue with batching. Locking and atomicity are still problematic and need to be resolved, but for counters it can be easily done with atomic_increment(). But... If batch size is 10:

set $/var = $/var + 1;
set $!var = $/var;

It is OK so far: each message will get it's number, from 1 to 10, and global is +10.

But what if we change order:

set $!var = $/var;
set $/var = $/var + 1;

Ooops, it will be strange. Every message will get the same number, and global will increment by 1. No, this idea is not as good. Just for the record.


--
Pavel Levshin

_______________________________________________
rsyslog mailing list
http://lists.adiscon.net/mailman/listinfo/rsyslog
http://www.rsyslog.com/professional-services/
What's up with rsyslog? Follow https://twitter.com/rgerhards
NOTE WELL: This is a PUBLIC mailing list, posts are ARCHIVED by a myriad of 
sites beyond our control. PLEASE UNSUBSCRIBE and DO NOT POST if you DON'T LIKE 
THAT.

Reply via email to