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

[Compatibility] Added CLIENT UNBLOCK command #886

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

Vijay-Nirmal
Copy link
Contributor

Adding the CLIENT UNBLOCK command to garnet

  • Add CLIENT UNBLOCK commands
  • Add Integration Test cases and ACL Test
  • Add documentation

Copy link
Contributor

@TalZaccai TalZaccai left a comment

Choose a reason for hiding this comment

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

Thanks! Please see my comments.

@@ -46,6 +46,11 @@ public class CollectionItemBroker : IDisposable
private bool disposed = false;
private bool isStarted = false;

internal bool TryGetObserver(int sessionId, out CollectionItemObserver observer)
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add an XML comment

}
}

if (Server is GarnetServerBase garnetServer)
Copy link
Contributor

Choose a reason for hiding this comment

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

If this is false you should abort with some error, otherwise the client will hang

return true;
}

if (session.storeWrapper?.itemBroker is not null)
Copy link
Contributor

Choose a reason for hiding this comment

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

If it is null then you should abort with an error

}
}

while (!RespWriteUtils.WriteInteger(1, ref dcurr, dend))
Copy link
Contributor

Choose a reason for hiding this comment

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

The client may be unblocked between you checking if it's blocked and attempting to unblock it (in which case you should return 0). In other words, you should get some feedback from the observer that indicates if you initiated the unblocking or not.

@@ -118,13 +123,15 @@ private async Task<CollectionItemResult> GetCollectionItemAsync(CollectionItemOb
? TimeSpan.FromMilliseconds(-1)
: TimeSpan.FromSeconds(timeoutInSeconds);

var isError = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

Naming: isError is confusing here, since there's no error actually occurring, should be something like isForceUnblocked.

try
{
// Wait for either the result found notification or the timeout to expire
await observer.ResultFoundSemaphore.WaitAsync(timeout, observer.CancellationTokenSource.Token);
}
catch (OperationCanceledException)
catch (OperationCanceledException) when (observer.CancellationTokenSource.IsCancellationRequested)
Copy link
Contributor

Choose a reason for hiding this comment

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

This will also be true if the session was disposed

/// <summary>
/// Indicates whether the result represents an error.
/// </summary>
internal readonly bool IsError { get; }
Copy link
Contributor

Choose a reason for hiding this comment

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

Same issue with naming here, should be something like IsForceUnblocked (update the comment accordingly)

[Test]
[TestCase("ERROR", Description = "Multiple unblock attempts with ERROR")]
[TestCase("TIMEOUT", Description = "Multiple unblock attempts with TIMEOUT")]
public async Task ClientUnblockMultipleAttemptsTest(string mode)
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the difference between this test and ClientUnblockBasicTest?

[Test]
[TestCase("ERROR", Description = "Multiple unblock attempts with ERROR")]
[TestCase("TIMEOUT", Description = "Multiple unblock attempts with TIMEOUT")]
public async Task ClientUnblockMultipleAttemptsTest(string mode)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can add a couple more tests here, for example -
1 client blocks, send 1 force unblock and 1 add in parallel - check that either client gets the data or gets unblocked and data stays in collection, can repeat test multiple times.
Multiple clients blocking, multiple calls for force unblock & add in parallel - check that no added data gets lost (i.e. either stays in the collection or being returned to clients).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants