Skip to content

Commit d174f9d

Browse files
Jenny Linjenkins
authored andcommitted
finagle-redis: Use StrictKeyCommand for XDEL
Problem Redis XDEL command is incorrectly categorized as a `StrictKeysCommand`. The command semantics are `XDEL key ID [ID ...]`. Using `StrictKeysCommand`, the list of `ids` is used as `keys`. However, XDEL only takes one key and it should be the pkey, rather than `ids`, which are lkeys. Solution Use `StrictKeyCommand` for XDEL JIRA Issues: CSL-8806 Differential Revision: https://phabricator.twitter.biz/D517291
1 parent 396c9a5 commit d174f9d

File tree

4 files changed

+7
-14
lines changed

4 files changed

+7
-14
lines changed

CHANGELOG.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ Breaking API Changes
1313
* finagle-core: Correct the spelling of `Tracing.recordClientSendFrargmet()` to
1414
`Tracing.recordClientSendFragment()` ``PHAB_ID=D505617``
1515

16+
* finagle-redis: Use `StrictKeyCommand` for XDEL ``PHAB_ID=D517291``
17+
1618
* finagle-zipkin-scribe: The scribe.thrift file was moved to finagle-thrift/src/main/thrift under a new
1719
namespace. `com.twitter.finagle.thrift.scribe.(thrift|thriftscala)` ``PHAB_ID=D511471``
1820

finagle-redis/src/it/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Instructions
1313
done via https://redis.io/download or via `brew install redis`.
1414

1515
2. That's all the setup! To run with pants, run
16-
`./pants finagle/finagle-redis/src/it/scala`. To run with sbt, run
16+
`./pants test finagle/finagle-redis/src/it/scala`. To run with sbt, run
1717
`./sbt 'project finagle-redis' 'it:testOnly'`.
1818

1919
Note that running the tests will create the file `dump.rdb` in the directory

finagle-redis/src/main/scala/com/twitter/finagle/redis/RedisPartitioningService.scala

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,6 @@ private[finagle] class RedisPartitioningService(
108108

109109
case kc: KeyCommand => Seq(kc.key)
110110

111-
// NOTE: XDel seems to be categorized incorrectly in the hierarchy of Command traits.
112-
// According to the documentation the semantics are `XDEL mystream id1 id2...`.
113-
// The XDel case class has `keys` overridden as the ids, however these are lkeys,
114-
// not pkeys, so it seems partitioning based on anything but the `key` field would
115-
// be erroneous, therefore we can't rely on the KeysCommand case here to do things
116-
// correctly, unless we want to change the implementation of the XDel command, and
117-
// I'm unsure of the implications of doing that
118-
case xdel: XDel => Seq(xdel.key)
119-
120111
case kcs: KeysCommand => kcs.keys
121112
case _ => unsupportedCommand(command)
122113
}
@@ -211,7 +202,7 @@ private[finagle] class RedisPartitioningService(
211202

212203
protected def isSinglePartition(command: Command): Future[Boolean] =
213204
command match {
214-
case _: KeyCommand | _: XDel | _: Ping.type => Future.True
205+
case _: KeyCommand | _: Ping.type => Future.True
215206
case _ if allKeysForSinglePartition(command) => Future.True
216207
case _ => Future.False
217208
}

finagle-redis/src/main/scala/com/twitter/finagle/redis/protocol/commands/Streams.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ case class XTrim(key: Buf, size: Long, exact: Boolean) extends StrictKeyCommand
6161
}
6262
}
6363

64-
case class XDel(key: Buf, ids: Seq[Buf]) extends StrictKeysCommand {
65-
override def name: Buf = Command.XDEL
64+
case class XDel(key: Buf, ids: Seq[Buf]) extends StrictKeyCommand {
65+
RequireClientProtocol(ids.nonEmpty, "ids must not be empty")
6666

67-
override def keys: Seq[Buf] = ids
67+
override def name: Buf = Command.XDEL
6868

6969
override def body: Seq[Buf] = Seq(key) ++ ids
7070
}

0 commit comments

Comments
 (0)