Browse Source

Merge pull request #11986 from jakesmith/hpcc-21156

HPCC-21156 Fix problem with TLK and PARTITION keys

Reviewed-by: Gavin Halliday <ghalliday@hpccsystems.com>
Gavin Halliday 6 years ago
parent
commit
e4b3c4950f
1 changed files with 20 additions and 2 deletions
  1. 20 2
      thorlcr/activities/indexwrite/thindexwriteslave.cpp

+ 20 - 2
thorlcr/activities/indexwrite/thindexwriteslave.cpp

@@ -448,10 +448,22 @@ public:
                         // JCSMORE if refactor==true, is rowsToReceive here right??
                         unsigned rowsToReceive = (refactor ? (tlkDesc->queryOwner().numParts()-1) : container.queryJob().querySlaves()) -1; // -1 'cos got my own in array already
                         ActPrintLog("INDEXWRITE: will wait for info from %d slaves before writing TLK", rowsToReceive);
+
+                        MemoryAttr dummyRow;
+                        if (isLocal)
+                        {
+                            size32_t minSz = helper->queryDiskRecordSize()->getMinRecordSize();
+                            if (hasTrailingFileposition(helper->queryDiskRecordSize()->queryTypeInfo()))
+                                minSz -= sizeof(offset_t);
+                            // dummyRow used if isLocal and a slave had no rows
+                            dummyRow.allocate(minSz);
+                            memset(dummyRow.mem(), 0xff, minSz);
+                        }
                         while (rowsToReceive--)
                         {
                             msg.clear();
-                            receiveMsg(msg, RANK_ALL, mpTag); // NH->JCS RANK_ALL_OTHER not supported for recv
+                            rank_t sender;
+                            receiveMsg(msg, RANK_ALL, mpTag, &sender);
                             if (abortSoon)
                                 return;
                             if (msg.length())
@@ -460,6 +472,12 @@ public:
                                 ni->deserialize(msg);
                                 tlkRows.append(*ni);
                             }
+                            else if (isLocal)
+                            {
+                                // if a local key TLK (including PARTITION keys), need an entry per part
+                                CNodeInfo *ni = new CNodeInfo(sender, dummyRow.get(), dummyRow.length(), totalCount);
+                                tlkRows.append(*ni);
+                            }
                         }
                         tlkRows.sort(CNodeInfo::compare);
 
@@ -469,7 +487,7 @@ public:
                         try
                         {
                             open(*tlkDesc, true, helper->queryDiskRecordSize()->isVariableSize(), true);
-                            if (tlkRows.length())
+                            if (!isLocal && tlkRows.length())
                             {
                                 CNodeInfo &lastNode = tlkRows.item(tlkRows.length()-1);
                                 memset(lastNode.value, 0xff, lastNode.size);