Uh oh!
There was an error while loading. Please reload this page.
PHOENIX-6083 View index creation does a checkAndPut on an incorrect r… - #929
Conversation
a3ea120 to
0823711Comparerichardantal
commented
Oct 19, 2020
@ChinmaySKulkarni Can you review this change please? For the view index creation we created a mutex for |
stoty
commented
Oct 19, 2020
💔 -1 overall
This message was automatically generated. |
ChinmaySKulkarni
left a comment
There was a problem hiding this comment.
Overall looks good (have a few small comments). Thanks for fixing this @richardantal!
| String fullViewName = SchemaUtil.getTableName(viewSchemaName, viewName); | ||
| createBaseTable(schemaName, tableName, false, null, null, true); | ||
| Connection conn = getConnection(); |
There was a problem hiding this comment.
nit: try-with-resources for the connection
| try { | ||
| conn.createStatement().execute("CREATE INDEX " + indexName + " ON " + fullViewName + " (v1)"); | ||
| } catch (SQLException e) { | ||
| failedMsg[0] = e.getMessage(); |
There was a problem hiding this comment.
nit: Can we store and hence later assert the SQLException code rather than the exception message?
| for (ColumnName colName : requiredCols) { | ||
| // acquire the mutex using the global physical table name to | ||
| // prevent this column from being dropped while the index is being created | ||
| String colNameSeparatedByDot = colName.getColumnName().replace(':', '.'); |
There was a problem hiding this comment.
Good to either extract this out as a SchemaUtil API and/or add a comment here. Is there some existing API which makes the indexed column name have a ':' instead of '.'?
ChinmaySKulkarni
commented
Oct 19, 2020
Looks like |
stoty
commented
Oct 19, 2020
💔 -1 overall
This message was automatically generated. |
richardantal
commented
Oct 20, 2020
|
richardantal
commented
Oct 20, 2020
Thank you@ChinmaySKulkarni for the review! I have updated the PR according to the comments. |
stoty
commented
Oct 20, 2020
💔 -1 overall
This message was automatically generated. |
74d254c to
64d4b74Comparerichardantal
commented
Oct 30, 2020
I have resolved the conflicts. |
stoty
commented
Oct 30, 2020
💔 -1 overall
This message was automatically generated. |
ChinmaySKulkarni
commented
Oct 30, 2020
@richardantal can you please put up a patch for 4.x branch too? I will commit to both master and 4.x at the same time for consistency. Also, please squash all commits into 1. |
2a0ddfa to
8ef65eeComparerichardantal
commented
Nov 2, 2020
Sure, thank you @ChinmaySKulkarni |
stoty
commented
Nov 2, 2020
💔 -1 overall
This message was automatically generated. |
stoty
commented
Nov 2, 2020
💔 -1 overall
This message was automatically generated. |
virajjasani
left a comment
There was a problem hiding this comment.
Left small comments, looks good otherwise.
Uh oh!
There was an error while loading. Please reload this page.
| conn.createStatement().execute("CREATE VIEW " + fullViewName + " AS SELECT * FROM " + fullTableName); | ||
| conn.commit(); | ||
| final int[] exceptionCode = new int[1]; |
There was a problem hiding this comment.
Not a strong opinion but since we want threads to mutate exceptionCode, maybe we can use AtomicInteger for exceptionCode rather than array with size 1, threads can set values and finally we can assert with assertEquals(exceptionCode.get(), 301) if you would prefer :)
There was a problem hiding this comment.
exceptionCode is accessed from an inner class so has to be final, in order to be able to change its value from the other thread it has to be an array.
We can use AtomicInteger array but I am not sure if it adds any value.
There was a problem hiding this comment.
I meant AtomicInteger as mutable final object similar to an array.
e.g
final AtomicInteger exceptionCode = new AtomicInteger();
&
} catch (SQLException e) {
exceptionCode.set(e.getErrorCode());
throw new RuntimeException(e);
} finally {
doneSignal.countDown();
}
&
assertEquals(exceptionCode.get(), 301);
Thought?
There was a problem hiding this comment.
Yeah I think this a better solution. Nice one :)
Thanks for the review @virajjasani I have updated the commit.
8ef65ee to
291d4d5Compare291d4d5 to
d1403ccComparestoty
commented
Nov 3, 2020
💔 -1 overall
This message was automatically generated. |
stoty
commented
Nov 3, 2020
💔 -1 overall
This message was automatically generated. |
ChinmaySKulkarni
commented
Nov 5, 2020
Thanks @richardantal |
…ow key