qiuchenjian opened a new pull request #3130: [CARBONDATA-3297] Fix that the IndexoutOfBoundsException when creating table and dropping table are at the same time
URL:
https://github.com/apache/carbondata/pull/3130
### [Problem]
Throw the IndexoutOfBoundsException when creating table and dropping table are at the same time
`java.lang.IndexOutOfBoundsException: 179
at scala.collection.mutable.ResizableArray$class.apply(ResizableArray.scala:43)
at scala.collection.mutable.ArrayBuffer.apply(ArrayBuffer.scala:48)
at scala.collection.IndexedSeqOptimized$class.segmentLength(IndexedSeqOptimized.scala:195)
at scala.collection.mutable.ArrayBuffer.segmentLength(ArrayBuffer.scala:48)
at scala.collection.GenSeqLike$class.prefixLength(GenSeqLike.scala:93)
at scala.collection.AbstractSeq.prefixLength(Seq.scala:41)
at scala.collection.IndexedSeqOptimized$class.find(IndexedSeqOptimized.scala:50)
at scala.collection.mutable.ArrayBuffer.find(ArrayBuffer.scala:48)
at org.apache.spark.sql.hive.CarbonFileMetastore.getTableFromMetadataCache(CarbonFileMetastore.scala:203)
at org.apache.spark.sql.CarbonEnv$.getCarbonTable(CarbonEnv.scala:203)
at org.apache.spark.sql.CarbonEnv$.getTablePath(CarbonEnv.scala:288)
at org.apache.spark.sql.execution.command.table.CarbonCreateTableCommand$$anonfun$1.apply(CarbonCreateTableCommand.scala:74)
at org.apache.spark.sql.execution.command.table.CarbonCreateTableCommand$$anonfun$1.apply(CarbonCreateTableCommand.scala:74)`
### [Solution]
1. The type of carbonTables in MetaData.class is ArrayBuffer, and the ArrayBuffer is not thread-safe, so it throw this exception when creating table and dropping table are at the same time
2. Use read write lock to guarantee the thread-safe
Be sure to do all of the following checklist to help us incorporate
your contribution quickly and easily:
- [ ] Any interfaces changed?
- [ ] Any backward compatibility impacted?
- [ ] Document update required?
- [ ] Testing done
Please provide details on
- Whether new unit test cases have been added or why no new tests are required?
- How it is tested? Please attach test report.
- Is it a performance related change? Please attach the performance test report.
- Any additional information to help reviewers in testing this change.
- [ ] For large changes, please consider breaking it into sub-tasks under an umbrella JIRA.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[hidden email]
With regards,
Apache Git Services