phoenix-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [phoenix] gjacoby126 commented on a change in pull request #499: Phoenix 4703 ALTER INDEX REBUILD ALL
Date Mon, 06 May 2019 22:36:22 GMT
gjacoby126 commented on a change in pull request #499: Phoenix 4703 ALTER INDEX REBUILD ALL

URL: https://github.com/apache/phoenix/pull/499#discussion_r281392246
 
 

 ##########
 File path: phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
 ##########
 @@ -4362,18 +4370,40 @@ public MutationState alterIndex(AlterIndexStatement statement) throws
SQLExcepti
                     // Set so that we get the table below with the potentially modified rowKeyOrderOptimizable
flag set
                     indexRef.setTable(result.getTable());
                     if (newIndexState == PIndexState.BUILDING && isAsync) {
-                        try {
-                            tableUpsert = connection.prepareStatement(UPDATE_INDEX_REBUILD_ASYNC_STATE);
-                            tableUpsert.setString(1,
-                                    connection.getTenantId() == null ? null : connection.getTenantId().getString());
-                            tableUpsert.setString(2, schemaName);
-                            tableUpsert.setString(3, indexName);
-                            tableUpsert.setLong(4, result.getTable().getTimeStamp());
-                            tableUpsert.execute();
-                            connection.commit();
-                        } finally {
-                            if (tableUpsert != null) {
-                                tableUpsert.close();
+                        if (isAll) {
+                            List<Task.TaskRecord> tasks = Task.queryTaskTable(connection,
schemaName, tableName, PTable.TaskType.INDEX_REBUILD,
+                                    tenantId, indexName);
+                            if (tasks == null || tasks.size() == 0) {
+                                Timestamp ts = new Timestamp(EnvironmentEdgeManager.currentTimeMillis());
+                                JsonObject jsonObject = new JsonObject();
+                                jsonObject.addProperty(INDEX_NAME, indexName);
+                                jsonObject.addProperty(REBUILD_ALL, true);
+                                try {
+                                    Task.addTask(connection, PTable.TaskType.INDEX_REBUILD,
+                                            tenantId, schemaName,
+                                            dataTableName, PTable.TaskStatus.CREATED.toString(),
+                                            jsonObject.toString(), null, ts, null, true);
+                                    connection.commit();
+                                } catch (IOException e) {
+                                    throw new SQLException("Exception happened while adding
a System.Task" + e.toString());
+                                }
+                            }
+                        } else {
+                            try {
+                                tableUpsert = connection.prepareStatement(UPDATE_INDEX_REBUILD_ASYNC_STATE);
 
 Review comment:
   Would be good to be able to eliminate this else block and just push everything through
Task, just with the rebuild all flag set or not set. However, we need to verify that this
doesn't cause unexpected side effects or regressions. Started a thread above about that. 

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message