Example ERROR Message
ERROR [insights-5-1] 2020-08-02 21:02:21,536 Directories.java:947 - Could not calculate the size of
/data1/dse_data/cassandra/data/ks1/cf1/snapshots. /data1/dse_data/cassandra/data/ks1/cf1/snapshots/opscenter_adhoc_2020-07-1-21-00-00-UTC
Typically followed with an additional exception like the following:
WARN [CompactionExecutor:11000] 2020-08-02 21:02:21,537 LogReplicaSet.java:228 - Failed to add record to a replica: java.io.IOException: Permission denied
ERROR [CompactionExecutor:11000] 2020-08-02 21:02:21,539 CassandraDaemon.java:129 - Exception in thread Thread[CompactionExecutor:11000,5,main]
org.apache.cassandra.io.FSReadError: java.io.IOException: fstat() failed: Permission denied
What does this ERROR message mean?
The Cassandra/DSE process checks the sizes of files, commonly SStables, for a variety of operations. This error indicates the size of the file in question could not be calculated, with the following messages providing more context.
Why does this ERROR occur?
This error occurs because the Cassandra/DSE process was unable to calculate the size of the file printed in the rest of the exception. In our case you see this line as the general indicator first:
ERROR [insights-5-1] 2020-08-02 21:02:21,536 Directories.java:947 - Could not calculate the size of
/data1/dse_data/cassandra/data/ks1/cf1/snapshots.
/data1/dse_data/cassandra/data/ks1/cf1/snapshots/opscenter_adhoc_2020-07-1-21-00-00-UTC
You will see errors in the logs following which provide more context. In our case permission was denied on a snapshots directory:
ERROR [insights-5-1] 2020-08-02 21:02:21,536 Directories.java:947 - Could not calculate the size of /data1/dse_data/cassandra/data/ks1/cf1/snapshots. /data1/dse_data/cassandra/data/ks1/cf1/snapshots/opscenter_adhoc_2020-07-1-21-00-00-UTC
WARN [CompactionExecutor:11000] 2020-08-02 21:02:21,537 LogReplicaSet.java:228 - Failed to add record to a replica: java.io.IOException: Permission denied
ERROR [CompactionExecutor:11000] 2020-08-02 21:02:21,539 CassandraDaemon.java:129 - Exception in thread Thread[CompactionExecutor:11000,5,main]
org.apache.cassandra.io.FSReadError: java.io.IOException: fstat() failed: Permission denied
How do you fix this ERROR?
The fix for this issue will depend on the lines following the initial "Could not calculate" error. In our case, "fstat() failed: Permission denied", we would correct the permissions needed for the Cassandra/DSE process user to be able to run the linux command
fstat /data1/dse_data/cassandra/data/ks1/cf1/snapshots/opscenter_adhoc_2020-07-1-21-00-00-UTC"
as indicated in the exception.