-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Broker::Store tables with expiration triggering initialization errors (4.2.2 and 5.0.0) #2331
Comments
It does trigger with the latest master, too. Needs
|
I've stepped through the sources. This error gets printed if 10 seconds to load an SQLite database should be plenty. Even with a thousand entries. So it seems like some kind of performance bug or maybe just another symptom of #2332. |
I'm not seeing this anymore on tim@coregeek2 build% zeek ~/Desktop/2331.zeek && sleep 1 && zeek ~/Desktop/2331.zeek @awelzel can you see if you can reproduce it still? |
Ah, nope, still reproduces. I think the timings involved just got much better with the #2332, but the actual problem is still there: Changing this in
And then the following:
The second zeek process spills lots of errors and exits with an initialization error:
|
@awelzel thanks for the confirmation. Isn't |
Yes, it's a busy loop. I'd guess we could use a lower frequency, but run processes for much longer (200 seconds instead of 2, for example). Think the important part is to have enough elements in the table and have some expire during the loading process (this is a bit guesses and hand wavy). Memory goes up, yes. But not something that's concerning IMO. I'd also view the two invocations separately really:
|
I've reproduced this locally with this small patch to Zeek to see what Broker is complaining about: diff --git a/src/broker/Manager.cc b/src/broker/Manager.cc
index 37e7f9d4c..4b1376470 100644
--- a/src/broker/Manager.cc
+++ b/src/broker/Manager.cc
@@ -1936,9 +1936,10 @@ void Manager::BrokerStoreToZeekTable(const std::string& name, const detail::Stor
auto value = handle->store.get(key);
if ( ! value )
{
+ auto err_str = broker::to_string(value.error());
reporter->Error(
- "Failed to load value for key %s while importing Broker store %s to table",
- to_string(key).c_str(), name.c_str());
+ "Failed to load value for key %s while importing Broker store %s to table: %s",
+ to_string(key).c_str(), name.c_str(), err_str.c_str());
table->EnableChangeNotifications();
continue;
} With that, I get a bunch of So it seems like Broker is loading the database, then tells Zeek what keys are initially in there. Then it applies the expiration times (2s) and basically all values time out immediately. This makes sense to me, since the items were created more than 2s in the past (using the absolute time when the first process created them). Then Zeek comes around asking for the values of all the keys and Broker no longer can find them, because they've expired. When ignoring diff --git a/src/broker/Manager.cc b/src/broker/Manager.cc
index 37e7f9d4c..3fb58cf48 100644
--- a/src/broker/Manager.cc
+++ b/src/broker/Manager.cc
@@ -1936,10 +1936,16 @@ void Manager::BrokerStoreToZeekTable(const std::string& name, const detail::Stor
auto value = handle->store.get(key);
if ( ! value )
{
- reporter->Error(
- "Failed to load value for key %s while importing Broker store %s to table",
- to_string(key).c_str(), name.c_str());
- table->EnableChangeNotifications();
+ auto& err = value.error();
+ if ( err != broker::ec::no_such_key )
+ {
+ auto err_str = broker::to_string(err);
+ reporter->Error(
+ "Failed to load value for key %s while importing Broker store %s to table: %s",
+ to_string(key).c_str(), name.c_str(), err_str.c_str());
+ table->EnableChangeNotifications();
+ }
+ // else: ignore; value has expired since retrieving the key
continue;
}
I don't get any errors from the second run. However, I've also played a bit with Before I start debugging under some wrong assumptions: what would be the expected system behavior for Zeek here? I would expect that the expiration time should have no effect on the execution time of the first process. Is something in Zeek is actively waiting for the expiration times? My assumption would be Zeek just shuts down and Broker then uses the SQLite database to initialize the table again with expiration time restored to the original creation time + the relative duration. |
In the reproducer, increasing the expiration time also increases the runtime of the process and the number of items inserted. Sorry, I realize that might be unexpected, but I was just fuzzing around seeing if I could trigger any errors. The following line is responsible for your observation:
With the same number of elements inserted, yes, the expiration time shouldn't have a big effect on the runtime. But how the reproducer is structured, it'll insert ~5x as many elements. Coupled with the slow sqlite implementation that probably makes it very visible. I'm not sure a
That assumption makes sense to me. |
Hey,
while fuzzing around with Broker::Store, ran into the following issue observed also by @mdhawan on systems he has was working on (suspecting unrelated to any freezing, however).
When setting
&write_expire
broker backed table (sqlite) and settingBroker::schedule_policy
tostealing
the following errors are produced with Zeek 5.0 when (presumably) there are expired entries in the broker store:With Zeek 5.0.0, using the
Broker::schedule_policy = "sharing"
doesn't trigger the problem. With Zeek 4.2.2, the problem triggers withBroker::schedule_policy
set either way.It didn't trigger with the dev build I have lying around, but didn't try very hard, but maybe something was fixed here?This is the reproducer script:
The text was updated successfully, but these errors were encountered: