Skip to content
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

DData: if lmdb.dir is null or empty, log a warning and set to default #7292

Merged
merged 4 commits into from
Jul 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
using Akka.DistributedData.Durable;
using Akka.Event;
using Akka.Serialization;
using Akka.DistributedData.Internal;
using LightningDB;
using System.Diagnostics;
using System.Linq;
Expand All @@ -37,7 +36,7 @@ namespace Akka.DistributedData.LightningDB
/// to the durable store actor, which must then reply with the <see cref="StoreReply.SuccessMessage"/> or
/// <see cref="StoreReply.FailureMessage"/> to the <see cref="StoreReply.ReplyTo"/>.
/// </summary>
public sealed class LmdbDurableStore : ReceiveActor
public sealed class LmdbDurableStore : ReceiveActor, IWithTimers
{
public static Actor.Props Props(Config config) => Actor.Props.Create(() => new LmdbDurableStore(config));

Expand Down Expand Up @@ -84,6 +83,12 @@ useWriteBehind is "off" or "false" or "no" ?

_path = _config.GetString("dir");

if (string.IsNullOrEmpty(_path))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do quick null check and the log the warning so the user knows that there's something off with their configuration, but then make the system work using its normal defaults afterwards

{
_log.Warning("No directory path configured for LMDB durable store, using default path");
_path = DatabaseName;
}

Init();
}

Expand Down Expand Up @@ -166,7 +171,7 @@ private void Active()
else
{
if (_pending.Count > 0)
Context.System.Scheduler.ScheduleTellOnce(_writeBehindInterval, Self, WriteBehind.Instance, ActorRefs.NoSender);
Timers.StartSingleTimer("write-behind", WriteBehind.Instance, _writeBehindInterval);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolve AK1004 warning

_pending[store.Key] = store.Data;
}

Expand Down Expand Up @@ -269,5 +274,7 @@ private void DoWriteBehind()
}
}
}

public ITimerScheduler Timers { get; set; }
}
}