Github user manishgupta88 commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/2344#discussion_r191122822
--- Diff:
core/src/main/java/org/apache/carbondata/core/metadata/schema/table/CarbonTable.java
---
@@ -892,7 +894,22 @@ public boolean isFileLevelFormat() {
public long size() throws IOException {
- Map<String, Long> dataIndexSize =
CarbonUtil.calculateDataIndexSize(this);
+ LOGGER.info("Acquired lock for table for table status updation");
+ SegmentStatusManager segmentStatusManager =
+ new SegmentStatusManager(this.getAbsoluteTableIdentifier());
+ ICarbonLock carbonLock = segmentStatusManager.getTableStatusLock();
+ Map<String, Long> dataIndexSize = new HashMap<>();
+ try {
+ if (carbonLock.lockWithRetries()) {
+ dataIndexSize = CarbonUtil.calculateDataIndexSize(this, true);
+ }
+ } finally {
+ if (carbonLock.unlock()) {
+ LOGGER.info("Table unlocked successfully after table status
updation");
+ } else {
+ LOGGER.error("Unable to unlock Table lock for table during table
status updation");
+ }
+ }
--- End diff --
Please move the locking logic outside of carbonTable
---