Skip to content

Commit 9e45dec

Browse files
authored
Fix: aborted transaction (due to watch failure) return value from null string to null array. (#692)
* Fix: aborted transaction (due to watch failure) return value from null string to null array. Also ensure watch works when object store is disabled. * fix test * fix another test * update version
1 parent b70553b commit 9e45dec

File tree

7 files changed

+12
-8
lines changed

7 files changed

+12
-8
lines changed

.azure/pipelines/azure-pipelines-external-release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# 1) update the name: string below (line 6) -- this is the version for the nuget package (e.g. 1.0.0)
44
# 2) update \libs\host\GarnetServer.cs readonly string version (~line 53) -- NOTE - these two values need to be the same
55
######################################
6-
name: 1.0.27
6+
name: 1.0.28
77
trigger:
88
branches:
99
include:

libs/host/GarnetServer.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public class GarnetServer : IDisposable
5252
protected StoreWrapper storeWrapper;
5353

5454
// IMPORTANT: Keep the version in sync with .azure\pipelines\azure-pipelines-external-release.yml line ~6.
55-
readonly string version = "1.0.27";
55+
readonly string version = "1.0.28";
5656

5757
/// <summary>
5858
/// Resp protocol version

libs/server/Transaction/TransactionManager.cs

+4
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,10 @@ internal void Commit(bool internal_txn = false)
247247

248248
internal void Watch(ArgSlice key, StoreType type)
249249
{
250+
// Update watch type if object store is disabled
251+
if (type == StoreType.All && objectStoreBasicContext.IsNull)
252+
type = StoreType.Main;
253+
250254
UpdateTransactionStoreType(type);
251255
watchContainer.AddWatch(key, type);
252256

libs/server/Transaction/TxnRespCommands.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ private bool NetworkEXEC()
7979
else
8080
{
8181
endReadHead = _origReadHead;
82-
while (!RespWriteUtils.WriteNull(ref dcurr, dend))
82+
while (!RespWriteUtils.WriteNullArray(ref dcurr, dend))
8383
SendAndReset();
8484
}
8585

test/Garnet.test/RespHashTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1074,7 +1074,7 @@ public async Task CanFailWhenUseMultiWatchTest()
10741074
await Task.Run(() => UpdateHashMap(key));
10751075

10761076
res = lightClientRequest.SendCommand("EXEC");
1077-
expectedResponse = "$-1";
1077+
expectedResponse = "*-1";
10781078
ClassicAssert.AreEqual(res.AsSpan().Slice(0, expectedResponse.Length).ToArray(), expectedResponse);
10791079

10801080
// This sequence should work

test/Garnet.test/RespSortedSetTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2273,7 +2273,7 @@ public async Task CanFailWhenUseMultiWatchTest()
22732273
await Task.Run(() => UpdateSortedSetKey(key));
22742274

22752275
res = lightClientRequest.SendCommand("EXEC");
2276-
expectedResponse = "$-1";
2276+
expectedResponse = "*-1";
22772277
ClassicAssert.AreEqual(res.AsSpan().Slice(0, expectedResponse.Length).ToArray(), expectedResponse);
22782278

22792279
// This sequence should work

test/Garnet.test/TransactionTests.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ public async Task SimpleWatchTest()
202202
await Task.Run(() => updateKey("key1", "value1_updated"));
203203

204204
res = lightClientRequest.SendCommand("EXEC");
205-
expectedResponse = "$-1";
205+
expectedResponse = "*-1";
206206
ClassicAssert.AreEqual(res.AsSpan().Slice(0, expectedResponse.Length).ToArray(), expectedResponse);
207207

208208
// This one should Commit
@@ -243,7 +243,7 @@ public async Task WatchNonExistentKey()
243243
await Task.Run(() => updateKey("key1", "value1"));
244244

245245
res = lightClientRequest.SendCommand("EXEC");
246-
expectedResponse = "$-1";
246+
expectedResponse = "*-1";
247247
ClassicAssert.AreEqual(res.AsSpan().Slice(0, expectedResponse.Length).ToArray(), expectedResponse);
248248

249249
// This one should Commit
@@ -289,7 +289,7 @@ public async Task WatchKeyFromDisk()
289289
await Task.Run(() => updateKey("key1", "value1_updated"));
290290

291291
res = lightClientRequest.SendCommand("EXEC");
292-
expectedResponse = "$-1";
292+
expectedResponse = "*-1";
293293
ClassicAssert.AreEqual(res.AsSpan().Slice(0, expectedResponse.Length).ToArray(), expectedResponse);
294294

295295
// This one should Commit

0 commit comments

Comments
 (0)