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

JSONSET Command throw Exception #897

Open
ercJuL opened this issue Dec 27, 2024 · 0 comments
Open

JSONSET Command throw Exception #897

ercJuL opened this issue Dec 27, 2024 · 0 comments

Comments

@ercJuL
Copy link

ercJuL commented Dec 27, 2024

Describe the bug

run the unit test will failed
https://github.com/microsoft/garnet/blob/main/test/Garnet.test/GarnetJSON/JsonCommandsTest.cs#L73-L73
db.Execute("JSON.SET", "k1", "$..a", 3);
the garnet server will throw Exception
https://github.com/microsoft/garnet/blob/main/playground/GarnetJSON/JsonObject.cs#L235-L235
matchValue.ReplaceWith(valNode);
Exception describe:

System.ArgumentException: A JsonNode cannot be used as a value. (Parameter 'value')
   at System.Text.Json.ThrowHelper.ThrowArgumentException_NodeValueNotAllowed(String paramName)
   at System.Text.Json.Nodes.JsonValue`1..ctor(TValue value, Nullable`1 options)
   at System.Text.Json.Nodes.JsonValue.Create[T](T value, Nullable`1 options)
   at System.Text.Json.Nodes.JsonNode.ReplaceWith[T](T value)
   at GarnetJSON.JsonObject.Set(String path, String value) in /Users/ercjul/source/garnet/playground/GarnetJSON/JsonObject.cs:line 235
   at GarnetJSON.JsonObject.TrySet(String path, String value, ILogger logger) in /Users/ercjul/source/garnet/playground/GarnetJSON/JsonObject.cs:line 163
   at GarnetJSON.JsonSET.Updater(ReadOnlyMemory`1 key, ObjectInput& input, IGarnetObject jsonObject, ValueTuple`2& output, RMWInfo& rmwInfo) in /Users/ercjul/source/garnet/playground/GarnetJSON/JsonCommands.cs:line 29
   at Garnet.server.ObjectSessionFunctions.InPlaceUpdaterWorker(Byte[]& key, ObjectInput& input, IGarnetObject& value, GarnetObjectStoreOutput& output, RMWInfo& rmwInfo, Int64& sizeChange) in /Users/ercjul/source/garnet/libs/server/Storage/Functions/ObjectStore/RMWMethods.cs:line 161
   at Garnet.server.ObjectSessionFunctions.InPlaceUpdater(Byte[]& key, ObjectInput& input, IGarnetObject& value, GarnetObjectStoreOutput& output, RMWInfo& rmwInfo, RecordInfo& recordInfo) in /Users/ercjul/source/garnet/libs/server/Storage/Functions/ObjectStore/RMWMethods.cs:line 84
   at Garnet.server.StorageSession.RMW_ObjectStore[TObjectContext](Byte[]& key, ObjectInput& input, GarnetObjectStoreOutput& output, TObjectContext& objectStoreContext) in /Users/ercjul/source/garnet/libs/server/Storage/Session/ObjectStore/AdvancedOps.cs:line 17
   at Garnet.server.GarnetApi`2.RMW_ObjectStore(Byte[]& key, ObjectInput& input, GarnetObjectStoreOutput& output) in /Users/ercjul/source/garnet/libs/server/API/GarnetApi.cs:line 290
   at Garnet.server.RespServerSession.TryCustomObjectCommand[TGarnetApi](GarnetObjectType objType, Byte subid, CommandType type, TGarnetApi& storageApi) in /Users/ercjul/source/garnet/libs/server/Custom/CustomRespCommands.cs:line 152
   at Garnet.server.RespServerSession.NetworkCustomObjCmd[TGarnetApi](TGarnetApi& storageApi) in /Users/ercjul/source/garnet/libs/server/Resp/RespServerSession.cs:line 843
   at Garnet.server.RespServerSession.ProcessOtherCommands[TGarnetApi](RespCommand command, TGarnetApi& storageApi) in /Users/ercjul/source/garnet/libs/server/Resp/RespServerSession.cs:line 746
   at Garnet.server.RespServerSession.ProcessArrayCommands[TGarnetApi](RespCommand cmd, TGarnetApi& storageApi) in /Users/ercjul/source/garnet/libs/server/Resp/RespServerSession.cs:line 707
   at Garnet.server.RespServerSession.ProcessMessages() in /Users/ercjul/source/garnet/libs/server/Resp/RespServerSession.cs:line 446
   at Garnet.server.RespServerSession.TryConsumeMessages(Byte* reqBuffer, Int32 bytesReceived) in /Users/ercjul/source/garnet/libs/server/Resp/RespServerSession.cs:line 321

I don't known why,but I upgrade System.Text.Json from 8.0.5 to 9.0.0 will fix this

Steps to reproduce the bug

  1. clone this code
  2. run unit test Garnet.test.JsonCommandsTest.JsonSetGetTests

Expected behavior

unit test failed and report

StackExchange.Redis.RedisConnectionException : SocketClosed (ReadEndOfStream, last-recv: 0) on 127.0.0.1:33278/Interactive, Idle/MarkProcessed, last: ...

Screenshots

No response

Release version

No response

IDE

JetBrains Rider 2024.3.3

OS version

System: MacOS 15.2 (24C101)
Cpu: M1 MAX

Additional context

No response

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

No branches or pull requests

1 participant