This is an automated email from the ASF dual-hosted git repository. bbender pushed a commit to branch develop in repository https://gitbox.apache.org/repos/asf/geode-native.git
The following commit(s) were added to refs/heads/develop by this push: new 7797a12 Revert "GEODE-8436: Several threads calling PdxInstanceFactory::create() causes seg fault (#635)" 7797a12 is described below commit 7797a1266079fd729f40ee1d98709b6f97822b8c Author: Blake Bender <bbl...@vmware.com> AuthorDate: Thu Aug 20 13:32:53 2020 -0700 Revert "GEODE-8436: Several threads calling PdxInstanceFactory::create() causes seg fault (#635)" This reverts commit c791081cb38e225a45c3bb05efb60280fa9caa33. - Appears to be causing a test failure on RHEL platform --- cppcache/integration/test/CMakeLists.txt | 1 - .../integration/test/PdxInstanceFactoryTest.cpp | 107 --------------------- cppcache/src/PdxTypeRegistry.cpp | 7 +- 3 files changed, 4 insertions(+), 111 deletions(-) diff --git a/cppcache/integration/test/CMakeLists.txt b/cppcache/integration/test/CMakeLists.txt index f5c3a06..233e842 100644 --- a/cppcache/integration/test/CMakeLists.txt +++ b/cppcache/integration/test/CMakeLists.txt @@ -48,7 +48,6 @@ add_executable(cpp-integration-test StructTest.cpp TransactionCleaningTest.cpp WanDeserializationTest.cpp - PdxInstanceFactoryTest.cpp ) target_compile_definitions(cpp-integration-test diff --git a/cppcache/integration/test/PdxInstanceFactoryTest.cpp b/cppcache/integration/test/PdxInstanceFactoryTest.cpp deleted file mode 100644 index 348b96a..0000000 --- a/cppcache/integration/test/PdxInstanceFactoryTest.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include <framework/Cluster.h> -#include <framework/Framework.h> -#include <framework/Gfsh.h> - -#include <thread> - -#include <geode/CacheFactory.hpp> -#include <geode/CacheTransactionManager.hpp> -#include <geode/RegionFactory.hpp> -#include <geode/RegionShortcut.hpp> - -namespace { - -using apache::geode::client::Cache; -using apache::geode::client::CacheableString; -using apache::geode::client::CacheFactory; -using apache::geode::client::CacheTransactionManager; -using apache::geode::client::Pool; -using apache::geode::client::Region; -using apache::geode::client::RegionShortcut; -using std::chrono::minutes; - -const std::string regionName = "my_region"; - -std::shared_ptr<Cache> createCache() { - auto cache = CacheFactory() - .set("log-level", "debug") - .setPdxReadSerialized(true) - .create(); - return std::make_shared<Cache>(std::move(cache)); -} - -std::shared_ptr<Region> createRegion(Cluster& cluster, - std::shared_ptr<Cache> cache) { - auto poolFactory = cache->getPoolManager().createFactory(); - cluster.applyLocators(poolFactory); - poolFactory.setPRSingleHopEnabled(true); - - auto pool = poolFactory.create("pool"); - auto regionFactory = cache->createRegionFactory(RegionShortcut::PROXY); - auto region = regionFactory.setPoolName("pool").create(regionName); - - return region; -} - -void doPut(std::shared_ptr<Cache> cache, std::shared_ptr<Region> region) { - auto factory = cache->createPdxInstanceFactory( - "name.string,surname.string,email.string,address.string"); - factory.writeObject("name", CacheableString::create("John")); - factory.writeObject("surname", CacheableString::create("Johnson")); - factory.writeObject("email", CacheableString::create("j...@johnson.mail")); - factory.writeObject("address", CacheableString::create("Fake St 123")); - - auto pdxInstance = factory.create(); - region->put(100, pdxInstance); -} - -TEST(PdxInstanceFactoryTest, testConcurrentCreateCalls) { - const int NUM_THREADS = 8; - - Cluster cluster{LocatorCount{1}, ServerCount{2}}; - - cluster.start(); - - cluster.getGfsh() - .create() - .region() - .withName(regionName) - .withType("PARTITION") - .execute(); - - auto cache = createCache(); - auto region = createRegion(cluster, cache); - - std::vector<std::thread> clientThreads; - - for (int i = 0; i < NUM_THREADS; i++) { - std::thread th(doPut, cache, region); - clientThreads.push_back(std::move(th)); - } - - for (std::thread& th : clientThreads) { - if (th.joinable()) { - th.join(); - } - } - cache->close(); -} // test - -} // namespace diff --git a/cppcache/src/PdxTypeRegistry.cpp b/cppcache/src/PdxTypeRegistry.cpp index 2d305fa..01cd5f4 100644 --- a/cppcache/src/PdxTypeRegistry.cpp +++ b/cppcache/src/PdxTypeRegistry.cpp @@ -88,9 +88,9 @@ int32_t PdxTypeRegistry::getPDXIdForType(std::shared_ptr<PdxType> nType, typeId = cache_->getSerializationRegistry()->GetPDXIdForType(pool, nType); nType->setTypeId(typeId); - pdxTypeToTypeIdMap_.emplace(nType, typeId); - typeIdToPdxType_.emplace(typeId, nType); + pdxTypeToTypeIdMap_.insert(std::make_pair(nType, typeId)); } + addPdxType(typeId, nType); return typeId; } @@ -118,7 +118,8 @@ void PdxTypeRegistry::clear() { void PdxTypeRegistry::addPdxType(int32_t typeId, std::shared_ptr<PdxType> pdxType) { WriteGuard guard(g_readerWriterLock_); - typeIdToPdxType_.emplace(typeId, pdxType); + std::pair<int32_t, std::shared_ptr<PdxType>> pc(typeId, pdxType); + typeIdToPdxType_.insert(pc); } std::shared_ptr<PdxType> PdxTypeRegistry::getPdxType(int32_t typeId) const {