[ 
https://issues.apache.org/jira/browse/GEODE-9268?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17372655#comment-17372655
 ] 

ASF GitHub Bot commented on GEODE-9268:
---------------------------------------

gaussianrecurrence commented on a change in pull request #806:
URL: https://github.com/apache/geode-native/pull/806#discussion_r662177445



##########
File path: cppcache/integration/test/PdxTypeRegistryTest.cpp
##########
@@ -140,19 +141,60 @@ TEST(PdxTypeRegistryTest, cleanupOnClusterRestart) {
 
   listener->waitConnected();
 
-  key = "after-restart";
-  region->put(key, createTestPdxInstance(cache, key));
+  region->put(key, pdx);
 
   // If PdxTypeRegistry was cleaned up, then the PdxType should have been
   // registered in the new cluster
 
   std::shared_ptr<SelectResults> result;
-  auto query =
-      qs->newQuery("SELECT * FROM /region WHERE entryName = '" + key + "'");
+  auto query = qs->newQuery("SELECT * FROM /region WHERE int_value = -1");
 
   EXPECT_NO_THROW(result = query->execute());
   EXPECT_TRUE(result);
-  EXPECT_GT(result->size(), 0);
+  EXPECT_EQ(result->size(), 1);
 }
 
+TEST(PdxTypeRegistryTest, cleanupOnClusterRestartAndFetchFields) {
+  Cluster cluster{LocatorCount{1}, ServerCount{2}};
+  cluster.start();
+
+  auto& gfsh = cluster.getGfsh();
+  gfsh.create().region().withName("region").withType("PARTITION").execute();
+
+  auto listener = std::make_shared<RegionListener>();
+
+  auto cache = createTestCache();
+  createTestPool(cluster, cache);
+  auto qs = cache.getQueryService("pool");
+  auto region = createTestRegion(cache, listener);
+
+  std::string key = "before-shutdown";
+  region->put(key, createTestPdxInstance(cache, key));
+  auto object = region->get(key);
+  EXPECT_TRUE(object);
+
+  auto pdx = std::dynamic_pointer_cast<PdxInstance>(object);
+  EXPECT_TRUE(pdx);
+
+  // Shutdown and wait for some time
+  gfsh.shutdown().execute();
+  listener->waitDisconnected();
+  std::this_thread::sleep_for(std::chrono::seconds{15});
+
+  for (auto& server : cluster.getServers()) {
+    server.start();
+  }
+
+  listener->waitConnected();
+  auto fields = pdx->getFieldNames();

Review comment:
       Indeed, you've got a point, that at first glance it'd be hard to 
understand why this test exists. I think it would be best to add a comment with 
its description.
   Thing is what's being tested here is the following:
   
   - You create a PdxInstance called pdx
   - Cluster is restarted and the PdxTypeRegister is cleaned up.
   - You try to traverse the PdxInstance and you expect there are no coredumps. 
In this case getFieldNames is used for example.
   
   Thing is, prior to this change, getFieldNames as many other methods tried to 
fetch the PdxType by querying the register with its ID, and given it was just 
cleaned up, it was returning a nullptr, hence coredump.
   
   Being all of this said. You think it would be best to check all of the 
methods that reads the PdxInstance content?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@geode.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Fix coredump whenever getFieldNames is called after a cluster restart
> ---------------------------------------------------------------------
>
>                 Key: GEODE-9268
>                 URL: https://issues.apache.org/jira/browse/GEODE-9268
>             Project: Geode
>          Issue Type: Bug
>          Components: native client
>            Reporter: Mario Salazar de Torres
>            Assignee: Mario Salazar de Torres
>            Priority: Major
>              Labels: pull-request-available
>
> *WHEN* A PdxInstance is fetched from a region
>  *AND* The whole cluster is restarted, triggering PdxTypeRegistry cleanup.
>  *AND* getFieldNames is called on the PdxInstance created just before
>  *THEN* a coredump happens.
> —
> *Additional information:*
> Callstack:
> {noformat}
> [ERROR 2021/05/05 12:57:12.781834 CEST main (139683590957120)] Segmentation 
> fault happened
>  0# handler(int) at nc-pdx/main.cpp:225
>  1# 0x00007F0A9F5F13C0 in /lib/x86_64-linux-gnu/libpthread.so.0
>  2# apache::geode::client::PdxType::getPdxFieldTypes() const at 
> cppcache/src/PdxType.hpp:181
>  3# apache::geode::client::PdxInstanceImpl::getFieldNames() at 
> cppcache/src/PdxInstanceImpl.cpp:1383
>  4# main at nc-pdx/main.cpp:374
>  5# __libc_start_main in /lib/x86_64-linux-gnu/libc.so.6
>  6# _start in build/pdx{noformat}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to