Skip to content

Commit

Permalink
GEODE-3153 Client receives duplicate events during rolling upgrade
Browse files Browse the repository at this point in the history
The previous fix worked fine for 1.0.0 and 1.1.0 clients but there are
old GemFire 8.2 clients still in use that the fix did not work for.
This patch changes the serialization to always send UUID bytes to pre
Version.GFE_90 (1.0.0-incubating) clients.

Added unit for it
  • Loading branch information
Hitesh Khamesra committed Jul 7, 2017
1 parent bc13d70 commit b4ebcba
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1145,7 +1145,9 @@ public void writeEssentialData(DataOutput out) throws IOException {
// write name last to fix bug 45160
DataSerializer.writeString(netMbr.getName(), out);

if (InternalDataSerializer.getVersionForDataStream(out).compareTo(Version.GFE_90) == 0) {
Version outputVersion = InternalDataSerializer.getVersionForDataStream(out);
if (0 <= outputVersion.compareTo(Version.GFE_90)
&& outputVersion.compareTo(Version.GEODE_110) < 0) {
netMbr.writeAdditionalData(out);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,13 +298,13 @@ public InternalDistributedMember getDistributedMember() {
/**
* deserialize the memberID bytes using the given version. The correct thing to do would be to
* have EventID carry the version ordinal of the serialized memberID, or to have it be part of the
* memberID bytes and use that version to deserialize the bytes
* memberID bytes and use that version to deserialize the bytes. Clients prior to 1.1.0 need to
* have UUID bytes in the memberID. Newer clients don't require this.
*/
private InternalDistributedMember getDistributedMember(Version targetVersion) {
public InternalDistributedMember getDistributedMember(Version targetVersion) {
ByteArrayInputStream bais = new ByteArrayInputStream(this.membershipID);
DataInputStream dis = new DataInputStream(bais);
if (0 <= targetVersion.compareTo(Version.GFE_90)
&& targetVersion.compareTo(Version.GEODE_110) < 0) {
if (targetVersion.compareTo(Version.GEODE_110) < 0) {
// GEODE-3153: clients expect to receive UUID bytes, which are only
// read if the stream's version is 1.0.0-incubating
dis = new VersionedDataInputStream(dis, Version.GFE_90);
Expand Down Expand Up @@ -345,10 +345,10 @@ public void toData(DataOutput dop) throws IOException {
// of the identifier
// See GEODE-3072
if (version.compareTo(Version.GEODE_110) < 0) {
InternalDistributedMember member = getDistributedMember(version);
InternalDistributedMember member = getDistributedMember(Version.GFE_90);
// reserialize with the client's version so that we write the UUID
// bytes
HeapDataOutputStream hdos = new HeapDataOutputStream(version);
HeapDataOutputStream hdos = new HeapDataOutputStream(Version.GFE_90);
member.writeEssentialData(hdos);
DataSerializer.writeByteArray(hdos.toByteArray(), dop);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,19 @@

import static org.junit.Assert.*;

import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.nio.ByteBuffer;

import org.apache.geode.test.junit.categories.ClientServerTest;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import org.apache.geode.distributed.internal.membership.InternalDistributedMember;
import org.apache.geode.internal.HeapDataOutputStream;
import org.apache.geode.internal.Version;
import org.apache.geode.internal.VersionedDataInputStream;
import org.apache.geode.internal.VersionedDataOutputStream;
import org.apache.geode.internal.cache.EventID;
import org.apache.geode.test.junit.categories.UnitTest;

Expand Down Expand Up @@ -164,6 +171,33 @@ public void testOptimizationForIntLong() {
writeReadAndVerifyOptimizedByteArray(ID_VALUE_LONG, ID_VALUE_INT, expectedLength);
}

@Test
public void testEventIDForGEODE100Member() throws IOException, ClassNotFoundException {
InternalDistributedMember distributedMember = new InternalDistributedMember("localhost", 10999);
HeapDataOutputStream hdos = new HeapDataOutputStream(256, Version.CURRENT);
distributedMember.writeEssentialData(hdos);
byte[] memberBytes = hdos.toByteArray();
EventID eventID = new EventID(memberBytes, 1, 1);


HeapDataOutputStream hdos90 = new HeapDataOutputStream(256, Version.GFE_90);
VersionedDataOutputStream dop = new VersionedDataOutputStream(hdos90, Version.GFE_90);

eventID.toData(dop);

ByteArrayInputStream bais = new ByteArrayInputStream(hdos90.toByteArray());


VersionedDataInputStream dataInputStream = new VersionedDataInputStream(bais, Version.GFE_90);

EventID eventID2 = new EventID();
eventID2.fromData(dataInputStream);

assertEquals(distributedMember, eventID2.getDistributedMember(Version.GFE_90));

assertEquals(memberBytes.length + 17, eventID2.getMembershipID().length);
}

/**
* Creates the optimized byte array using <code>EventID#getOptimizedByteArrayForEventID</code> api
* with the given threadId and sequenceId and verifies that the length of that byte-array is as
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,28 +285,28 @@ fromData,16,2a2bb700172a2bb900180100b50008b1
toData,16,2a2bb700192b2ab40008b9001a0200b1

org/apache/geode/distributed/internal/membership/InternalDistributedMember,6
fromData,38,2a2bb6009f2ab6009ab900190100b20095b60078a100112ab400012bb900960200a700044db1
fromDataPre_GFE_7_1_0_0,282,2bb800a04d2bb900a101003e2a2bb8008fb500072ab2000499000e2c2ab40007b800a2a700072cb60008b500072bb900a3010036041504047e99000704a700040336051504057e99000704a700040336062a1504077e99000704a7000403b5003a2bb900a1010036072bb900a1010036082bb900a3010036092bb800913a0a02360b2bb8008f3a0c1509100da0000e2a2bb8008fb50014a700152bb8008f3a0d190dc6000a190db800a4360b2bb8008f3a0d2bb80092b60093360e190db600779e0011bb004f59190d150eb70050a70004013a0f2a15042bb700943610bb003159150715081509150b190c190a190fb700323a112a2c1d1505150615101911b80018b500012ab40001b9003e01009e000704a7000403b80047b1
fromDataPre_GFE_9_0_0_0,282,2bb800a04d2bb900a101003e2a2bb8008fb500072ab2000499000e2c2ab40007b800a2a700072cb60008b500072bb900a3010036041504047e99000704a700040336051504057e99000704a700040336062a1504077e99000704a7000403b5003a2bb900a1010036072bb900a1010036082bb900a3010036092bb800913a0a02360b2bb8008f3a0c1509100da0000e2a2bb8008fb50014a700152bb8008f3a0d190dc6000a190db800a4360b2bb8008f3a0d2bb80092b60093360e190db600779e0011bb004f59190d150eb70050a70004013a0f2a15042bb700943610bb003159150715081509150b190c190a190fb700323a112a2c1d1505150615101911b80018b500012ab40001b9003e01009e000704a7000403b80047b1
toData,34,2a2bb600992ab40001b900190100b20095b60078a1000d2ab6009a2bb9008b0200b1
toDataPre_GFE_7_1_0_0,271,2ab40001b9003e01009e000704a7000403b800472ab600592bb8009b2b2ab60058b9009c02002ab400072bb80082033d2ab40001b9008301009900071c04803d2ab40001b9007301009900071c05803d2ab4003a9900071c07803d2b1c1100ff7e91b9009d02002b2ab40001b9003d0100b9009c02002b2ab40001b9004b0100b9009c02002b2ab40001b9003e0100b9009d02002ab40001b9004001002bb800852ab40001b9004c01002bb800822ab40001b9003e01003e1d100da0000e2ab400142bb80082a700132ab40001b9003f0100b8009e2bb800822ab40001b9004e01003a041904c70008124da700081904b600862bb800821904c7000911012ca700081904b60087b800882bb80089b1
toDataPre_GFE_9_0_0_0,266,2ab600592bb8009b2b2ab60058b9009c02002ab400072bb80082033d2ab40001b9008301009900071c04803d2ab40001b9007301009900071c05803d2ab4003a9900071c07803d1c1008803d2b1c1100ff7e91b9009d02002b2ab40001b9003d0100b9009c02002b2ab40001b9004b0100b9009c02002ab40001b9003e01003e2b1db9009d02002ab40001b9004001002bb800852ab40001b9004c01002bb800821d100da0000e2ab400142bb80082a700132ab40001b9003f0100b8009e2bb800822ab40001b9004e01003a041904c70008124da700081904b600862bb800821904c7000911012ca700081904b60087b800882bb800892ab40001b90019010036052b150504b8008ab1
fromData,38,2a2bb600a02ab6009bb900190100b20096b60067a100112ab400012bb900970200a700044db1
fromDataPre_GFE_7_1_0_0,282,2bb800a14d2bb900a201003e2a2bb80090b500072ab2000499000e2c2ab40007b800a3a700072cb60008b500072bb900a4010036041504047e99000704a700040336051504057e99000704a700040336062a1504077e99000704a7000403b5001e2bb900a2010036072bb900a2010036082bb900a4010036092bb800923a0a02360b2bb800903a0c1509100da0000e2a2bb80090b50014a700152bb800903a0d190dc6000a190db800a5360b2bb800903a0d2bb80093b60094360e190db6007d9e0011bb004f59190d150eb70050a70004013a0f2a15042bb700953610bb003259150715081509150b190c190a190fb700333a112a2c1d1505150615101911b80018b500012ab40001b9003e01009e000704a7000403b80047b1
fromDataPre_GFE_9_0_0_0,282,2bb800a14d2bb900a201003e2a2bb80090b500072ab2000499000e2c2ab40007b800a3a700072cb60008b500072bb900a4010036041504047e99000704a700040336051504057e99000704a700040336062a1504077e99000704a7000403b5001e2bb900a2010036072bb900a2010036082bb900a4010036092bb800923a0a02360b2bb800903a0c1509100da0000e2a2bb80090b50014a700152bb800903a0d190dc6000a190db800a5360b2bb800903a0d2bb80093b60094360e190db6007d9e0011bb004f59190d150eb70050a70004013a0f2a15042bb700953610bb003259150715081509150b190c190a190fb700333a112a2c1d1505150615101911b80018b500012ab40001b9003e01009e000704a7000403b80047b1
toData,34,2a2bb6009a2ab40001b900190100b20096b60067a1000d2ab6009b2bb9008c0200b1
toDataPre_GFE_7_1_0_0,271,2ab40001b9003e01009e000704a7000403b800472ab600592bb8009c2b2ab60058b9009d02002ab400072bb80083033d2ab40001b9008401009900071c04803d2ab40001b9007901009900071c05803d2ab4001e9900071c07803d2b1c1100ff7e91b9009e02002b2ab40001b9003d0100b9009d02002b2ab40001b9004b0100b9009d02002b2ab40001b9003e0100b9009e02002ab40001b9004001002bb800862ab40001b9004c01002bb800832ab40001b9003e01003e1d100da0000e2ab400142bb80083a700132ab40001b9003f0100b8009f2bb800832ab40001b9004e01003a041904c70008124da700081904b600872bb800831904c7000911012ca700081904b60088b800892bb8008ab1
toDataPre_GFE_9_0_0_0,266,2ab600592bb8009c2b2ab60058b9009d02002ab400072bb80083033d2ab40001b9008401009900071c04803d2ab40001b9007901009900071c05803d2ab4001e9900071c07803d1c1008803d2b1c1100ff7e91b9009e02002b2ab40001b9003d0100b9009d02002b2ab40001b9004b0100b9009d02002ab40001b9003e01003e2b1db9009e02002ab40001b9004001002bb800862ab40001b9004c01002bb800831d100da0000e2ab400142bb80083a700132ab40001b9003f0100b8009f2bb800832ab40001b9004e01003a041904c70008124da700081904b600872bb800831904c7000911012ca700081904b60088b800892bb8008a2ab40001b90019010036052b150504b8008bb1

org/apache/geode/distributed/internal/membership/NetView,2
fromData,109,2a2bb8006ec0002bb500132a2bb9006f0100b500082a2bb80070b5000bb200409a00122ab4000bc7000bbb004159b70042bf2abb000c592ab4000bb7000db5000e2a2bb80071b500102a2bb80071b500122a2bb80072b500052bb800734d2cc6000d2ab400042cb900180200b1
toData,60,2ab400132bb800682b2ab40008b9006902002a2ab4000b2bb7006a2ab400102bb8006b2ab400122bb8006b2ab400052bb8006c2ab400042bb8006db1

org/apache/geode/distributed/internal/membership/gms/GMSMember,2
fromData,62,2a2bb6004b2a2bb9004c0100b500072a2bb9004d0100b5003c2a2bb9004d0100b500092a2bb9004c0100b500082a2bb8004eb5000a2a2bb8004fb5000bb1
toData,62,2a2bb6003f2b2ab40007b9004002002b2ab4003cb9004102002b2ab40009b9004102002b2ab40008b9004002002ab4000a2bb800422ab4000b2bb80043b1
fromData,62,2a2bb6004b2a2bb9004c0100b500072a2bb9004d0100b5001e2a2bb9004d0100b500092a2bb9004c0100b500082a2bb8004eb5000a2a2bb8004fb5000bb1
toData,62,2a2bb6003f2b2ab40007b9004002002b2ab4001eb9004102002b2ab40009b9004102002b2ab40008b9004002002ab4000a2bb800422ab4000b2bb80043b1

org/apache/geode/distributed/internal/membership/gms/locator/FindCoordinatorRequest,2
fromData,97,2a2bb8001dc0001ab500022bb9001e01003d2abb001f591cb70020b50005033e1d1ca2001a2ab400052bb8001dc0001ab90021020057840301a7ffe72a2bb9001e0100b500062a2bb9001e0100b500082a2bb80022b500042a2bb80023b50007b1
toData,114,2ab400022bb800142ab40005c6003a2b2ab40005b900150100b9001602002ab40005b9001701004d2cb9001801009900152cb900190100c0001a4e2d2bb80014a7ffe8a7000a2b03b9001602002b2ab40006b9001602002b2ab40008b9001602002ab400042bb8001b2ab400072bb8001cb1

org/apache/geode/distributed/internal/membership/gms/locator/FindCoordinatorResponse,2
fromData,105,2a2bb80026c00027b500022a2bb80026c00027b500032a2bb80028b5000a2a2bb80029b5000c2a2bb9002a0100b500092ab400099a00342a2bb9002a0100b500042a2bb9002a0100b500072a2bb9002a0100b500082a2bb80026c0002bb500052a2bb8002cb50006b1
toData,89,2ab400022bb800212ab400032bb800212ab4000a2bb800222ab4000c2bb800232b2ab40009b9002402002b2ab40004b9002402002b2ab40007b9002402002b2ab40008b9002402002ab400052bb800212ab400062bb80025b1
fromData,105,2a2bb80025c00026b500022a2bb80025c00026b500032a2bb80027b5000a2a2bb80028b5000c2a2bb900290100b500092ab400099a00342a2bb900290100b500042a2bb900290100b500072a2bb900290100b500082a2bb80025c0002ab500052a2bb8002bb50006b1
toData,89,2ab400022bb800202ab400032bb800202ab4000a2bb800212ab4000c2bb800222b2ab40009b9002302002b2ab40004b9002302002b2ab40007b9002302002b2ab40008b9002302002ab400052bb800202ab400062bb80024b1

org/apache/geode/distributed/internal/membership/gms/locator/GetViewRequest,2
fromData,1,b1
Expand Down Expand Up @@ -974,7 +974,7 @@ fromData,171,2a2bb700632bb9006401003d1c047e9900142a2bb900650100b500092ab40009b80
toData,173,2a2bb70070033d2ab400099900081c0480933d2ab40006029f00081c0780933d2ab40007c600081c0580933d2ab4000d9900091c104080933d2b1cb9007102002ab4000999000d2b2ab40009b9007202002ab40006029f000d2b2ab40006b9007202002ab40007c6000b2ab400072bb800732ab4000e99000e2ab400082bb80073a700102ab40008b9005901002bb800732ab4000a2bb800732ab4000cc000742bb800752ab4000b2bb80076b1

org/apache/geode/internal/cache/DistributedRemoveAllOperation$RemoveAllEntryData,1
toData,136,2ab4000a4d2c2bb8003f2b2ab40010b40040b9004102002ab400063e2ab40022c600081d0780913e2ab40015c600191d100880913e2ab40015c100429900091d102080913e1d108080913e2b1db9004102002ab40022c6000b2ab400222bb8003f2ab40015c6000b2ab400152bb800432ab6002499000b2ab400122bb800432ab400082bb80044b1
toData,136,2ab4000a4d2c2bb800412b2ab40010b40042b9004302002ab400063e2ab40024c600081d0780913e2ab40015c600191d100880913e2ab40015c100449900091d102080913e1d108080913e2b1db9004302002ab40024c6000b2ab400242bb800412ab40015c6000b2ab400152bb800452ab6002699000b2ab400122bb800452ab400082bb80046b1

org/apache/geode/internal/cache/DistributedRemoveAllOperation$RemoveAllMessage,2
fromData,197,2a2bb700382a2bb80039c0003ab500052a2bb8003b88b500152a2ab40015bd003cb500062ab400159e00722bb8003d4dbb003e59b7003f4e03360415042ab40015a200202ab400061504bb003c592b2ab4000515042c2db7004053840401a7ffdd2bb9004101003604150499002f2bb800423a0503360615062ab40015a2001d2ab4000615063219051506b60043c00044b5002b840601a7ffe02ab400451140007e99000e2a2bb80039c00046b5000b2a2ab400451180007e99000704a7000403b5001ab1
Expand All @@ -999,8 +999,8 @@ toData,22,2b2ab40004c10007b9004002002ab400042bb60041b1
org/apache/geode/internal/cache/EventID,4
fromData,53,2a2bb80041b500042bb80041b800424d2a2cb80043b500092a2cb80043b5000b2a2bb900440100b5000c2a2bb900450100b50001b1
fromDataPre_GFE_8_0_0_0,33,2a2bb80041b500042bb80041b800424d2a2cb80043b500092a2cb80043b5000bb1
toData,93,2bb8003a4d2cb2003bb6003c9d00252a2cb6002e4ebb0010592cb7003d3a042d1904b600151904b600162bb8003ea7000b2ab400042bb8003e2ab400092ab4000bb800382bb8003e2b2ab4000cb9003f02002b2ab40001b900400200b1
toDataPre_GFE_8_0_0_0,24,2ab400042bb8003e2ab400092ab4000bb800382bb8003eb1
toData,97,2bb8003c4d2cb20033b600349c00292ab20036b6002e4ebb001059b20036b7003d3a042d1904b600151904b600162bb8003ea7000b2ab400042bb8003e2ab400092ab4000bb8003a2bb8003e2b2ab4000cb9003f02002b2ab40001b900400200b1
toDataPre_GFE_8_0_0_0,24,2ab400042bb8003e2ab400092ab4000bb8003a2bb8003eb1

org/apache/geode/internal/cache/EventTracker$EventSeqnoHolder,2
fromData,22,2a2bb9000e0100b500042a2bb8000fc00010b50005b1
Expand Down Expand Up @@ -1460,8 +1460,8 @@ fromData,115,2a2bb7002e2bb8002fb6000d3d2abb003059b70031b5000403360415041ca200542
toData,121,2a2bb700272ab40004b900280100b800292bb8002a2ab40004b9000601004d014e013a04013a052cb90009010099004b2cb9000a0100c0000b4e2d2bb8002b2cb9000a0100c0000c3a0419042bb8002a1904b6000d360603360715071506a200172cb9000a01003a0519052bb8002c840701a7ffe8a7ffb2b1

org/apache/geode/internal/cache/ha/ThreadIdentifier,2
fromData,19,2a2bb80028b500022a2bb900290100b50003b1
toData,19,2ab400022bb8002a2b2ab40003b9002b0300b1
fromData,19,2a2bb8002db500022a2bb9002e0100b50003b1
toData,19,2ab400022bb8002f2b2ab40003b900300300b1

org/apache/geode/internal/cache/locks/TXLockBatch,2
fromData,67,2a2bb80014b500032a2bb80015b500052bb9001601003d1c9b002a2abb0008591cb70017b50004033e1d1ca200172ab400042bb80018b90019020057840301a7ffeab1
Expand Down

0 comments on commit b4ebcba

Please sign in to comment.