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

Fix accidentally set low priority #5722

Merged
merged 2 commits into from
May 23, 2023
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions src/Nethermind/Nethermind.Db.Rocks/DbOnTheRocks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -514,17 +514,17 @@ internal void SetWithColumnFamily(ReadOnlySpan<byte> key, ColumnFamilyHandle? cf

public WriteOptions? WriteFlagsToWriteOptions(WriteFlags flags)
{
if ((flags & WriteFlags.LowPriorityAndNoWAL) != 0)
if ((flags & WriteFlags.LowPriorityAndNoWAL) == WriteFlags.LowPriorityAndNoWAL)
Copy link
Member

Choose a reason for hiding this comment

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

Would maybe add comment that this is a combined flags enum so needs a strict equality check (rather than not zero)

{
return _lowPriorityAndNoWalWrite;
}

if ((flags & WriteFlags.DisableWAL) != 0)
if ((flags & WriteFlags.DisableWAL) == WriteFlags.DisableWAL)
{
return _noWalWrite;
}

if ((flags & WriteFlags.LowPriority) != 0)
if ((flags & WriteFlags.LowPriority) == WriteFlags.LowPriority)
{
return _lowPriorityWriteOptions;
}
Expand Down
6 changes: 4 additions & 2 deletions src/Nethermind/Nethermind.Db.Test/DbOnTheRocksTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,15 @@ public void WriteOptions_is_correct()

WriteOptions? options = db.WriteFlagsToWriteOptions(WriteFlags.LowPriority);
Native.Instance.rocksdb_writeoptions_get_low_pri(options.Handle).Should().BeTrue();
Native.Instance.rocksdb_writeoptions_get_disable_WAL(options.Handle).Should().BeFalse();

options = db.WriteFlagsToWriteOptions(WriteFlags.LowPriority | WriteFlags.DisableWAL);
Native.Instance.rocksdb_writeoptions_get_low_pri(options.Handle).Should().BeTrue();
Native.Instance.rocksdb_writeoptions_get_disable_WAL(options.Handle).Should().Be(true);
Native.Instance.rocksdb_writeoptions_get_disable_WAL(options.Handle).Should().BeTrue();

options = db.WriteFlagsToWriteOptions(WriteFlags.DisableWAL);
Native.Instance.rocksdb_writeoptions_get_disable_WAL(options.Handle).Should().Be(true);
Native.Instance.rocksdb_writeoptions_get_low_pri(options.Handle).Should().BeFalse();
Native.Instance.rocksdb_writeoptions_get_disable_WAL(options.Handle).Should().BeTrue();
}

[Test]
Expand Down