@Override public boolean commitTransaction() { if (!rawStore.commitTransaction()) { return false; } // In case of event based update, shared cache is not updated directly to avoid inconsistency. // For example, if metastore B add a partition, then metastore A drop a partition later. However, on metastore A, // it first get drop partition request, then from notification, create the partition. If there's no tombstone // entry in partition cache to tell drop is after creation, we end up consumes the creation request. Though // eventually there's drop partition notification, but during the interim, later event takes precedence. // So we will not update the cache during raw store operation but wait during commit transaction to make sure that // the event related to the current transactions are updated in the cache and thus we can support strong // consistency in case there is only one metastore. if (canUseEvents) { triggerUpdateUsingEvent(rawStore); } return true; }
@Override public void add_runtime_stats(RuntimeStat stat) throws TException { startFunction("store_runtime_stats"); Exception ex = null; boolean success = false; RawStore ms = getMS(); try { ms.openTransaction(); ms.addRuntimeStat(stat); success = ms.commitTransaction(); } catch (Exception e) { LOG.error("Caught exception", e); ex = e; throw e; } finally { if (!success) { ms.rollbackTransaction(); } endFunction("store_runtime_stats", success, ex); } }
@Override public void add_serde(SerDeInfo serde) throws TException { startFunction("create_serde", ": " + serde.getName()); Exception ex = null; boolean success = false; RawStore ms = getMS(); try { ms.openTransaction(); ms.addSerde(serde); success = ms.commitTransaction(); } catch (MetaException|AlreadyExistsException e) { LOG.error("Caught exception creating serde", e); ex = e; throw e; } finally { if (!success) { ms.rollbackTransaction(); } endFunction("create_serde", success, ex); } }
EventType.CREATE_ISCHEMA, new CreateISchemaEvent(true, this, schema)); success = ms.commitTransaction(); } finally { if (!success) {
@Override public void alter_function(String dbName, String funcName, Function newFunc) throws TException { String[] parsedDbName = parseDbName(dbName, conf); validateForAlterFunction(parsedDbName[DB_NAME], funcName, newFunc); boolean success = false; RawStore ms = getMS(); try { ms.openTransaction(); ms.alterFunction(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], funcName, newFunc); success = ms.commitTransaction(); } catch (InvalidObjectException e) { // Throwing MetaException instead of InvalidObjectException as the InvalidObjectException // is not defined for the alter_function method in the Thrift interface. throwMetaException(e); } finally { if (!success) { ms.rollbackTransaction(); } } }
EventType.DROP_SCHEMA_VERSION, new DropSchemaVersionEvent(true, this, schemaVersion)); success = ms.commitTransaction(); } finally { if (!success) {
EventType.ADD_SCHEMA_VERSION, new AddSchemaVersionEvent(true, this, schemaVersion)); success = ms.commitTransaction(); } finally { if (!success) {
success = ms.commitTransaction(); } catch (MetaException|NoSuchObjectException e) { ex = e;
success = ms.commitTransaction(); for (MetaStoreEventListener listener : listeners) { listener.onLoadPartitionDone(new LoadPartitionDoneEvent(true, tbl, partName, this));
committed = getMS().commitTransaction(); } finally { if (!committed) {
oldSchemaVersion, newSchemaVersion)); success = ms.commitTransaction(); } finally { if (!success) {
private void create_type_core(final RawStore ms, final Type type) throws AlreadyExistsException, MetaException, InvalidObjectException { if (!MetaStoreUtils.validateName(type.getName(), null)) { throw new InvalidObjectException("Invalid type name"); } boolean success = false; try { ms.openTransaction(); if (is_type_exists(ms, type.getName())) { throw new AlreadyExistsException("Type " + type.getName() + " already exists"); } ms.createType(type); success = ms.commitTransaction(); } finally { if (!success) { ms.rollbackTransaction(); } } }
EventType.ALTER_ISCHEMA, new AlterISchemaEvent(true, this, oldSchema, rqst.getNewSchema())); success = ms.commitTransaction(); } finally { if (!success) {
success = ms.commitTransaction(); } finally { if (!success) {
private void updateTablePartitionColStats(RawStore rawStore, String catName, String dbName, String tblName) { boolean committed = false; rawStore.openTransaction(); try { Table table = rawStore.getTable(catName, dbName, tblName); List<String> colNames = MetaStoreUtils.getColumnNamesForTable(table); List<String> partNames = rawStore.listPartitionNames(catName, dbName, tblName, (short) -1); // Get partition column stats for this table Deadline.startTimer("getPartitionColumnStatistics"); List<ColumnStatistics> partitionColStats = rawStore.getPartitionColumnStatistics(catName, dbName, tblName, partNames, colNames); Deadline.stopTimer(); sharedCache.refreshPartitionColStatsInCache(catName, dbName, tblName, partitionColStats); List<Partition> parts = rawStore.getPartitionsByNames(catName, dbName, tblName, partNames); // Also save partitions for consistency as they have the stats state. for (Partition part : parts) { sharedCache.alterPartitionInCache(catName, dbName, tblName, part.getValues(), part); } committed = rawStore.commitTransaction(); } catch (MetaException | NoSuchObjectException e) { LOG.info("Updating CachedStore: unable to read partitions of table: " + tblName, e); } finally { if (!committed) { sharedCache.removeAllPartitionColStatsFromCache(catName, dbName, tblName); rawStore.rollbackTransaction(); } } }
private void updateTableColStats(RawStore rawStore, String catName, String dbName, String tblName) { boolean committed = false; rawStore.openTransaction(); try { Table table = rawStore.getTable(catName, dbName, tblName); if (!table.isSetPartitionKeys()) { List<String> colNames = MetaStoreUtils.getColumnNamesForTable(table); Deadline.startTimer("getTableColumnStatistics"); ColumnStatistics tableColStats = rawStore.getTableColumnStatistics(catName, dbName, tblName, colNames); Deadline.stopTimer(); if (tableColStats != null) { sharedCache.refreshTableColStatsInCache(StringUtils.normalizeIdentifier(catName), StringUtils.normalizeIdentifier(dbName), StringUtils.normalizeIdentifier(tblName), tableColStats.getStatsObj()); // Update the table to get consistent stats state. sharedCache.alterTableInCache(catName, dbName, tblName, table); } } committed = rawStore.commitTransaction(); } catch (MetaException | NoSuchObjectException e) { LOG.info("Unable to refresh table column stats for table: " + tblName, e); } finally { if (!committed) { sharedCache.removeAllTableColStatsFromCache(catName, dbName, tblName); rawStore.rollbackTransaction(); } } }
success = ms.commitTransaction(); } catch (MetaException|NoSuchObjectException e) { ex = e;
committed = getMS().commitTransaction(); } finally { if (!committed) {
success = ms.commitTransaction(); } catch (NoSuchObjectException e) { ex = e;
committed = getMS().commitTransaction(); } finally { if (!committed) {