I can't think of a reason to keep empty directories around, seems like a 
reasonable change, but I don't think you're butting up against a thing that 
most people would run into, as snapshots are enabled by default (auto_snapshot: 
true) and almost nobody changes it.  

The use case you described isn't handled well by Cassandra for a host of other 
reasons, and I would *never* do that in a production environment with any 
released version.  The folder thing is the least of the issues you'll run into, 
so even if you contribute a patch and address it, I'd still wouldn't do it 
until transactional cluster metadata gets released and I've had a chance to 
kick the tires to see what issues you run into besides schema inconsistencies.  
I suspect the drivers won't love it either.

Assuming you're running into an issue now:

find . -type d -empty -exec rmdir {} \;

rmdir only removes empty directories, you'll need to run it twice (once for 
backup, once for the empty table).  It will remove all empty directories in 
that folder so if you've got unused tables, you'd be better off using the find 
command, getting the list, removing the active tables from it and explicitly 
running the rmdir command with the directories you want cleaned up.

Jon

On 2023/12/04 19:55:06 Sébastien Rebecchi wrote:
> Thank you Dipan.
> 
> Do you know if there is a good reason for Cassandra to let tables folder
> even when there is no snapshot?
> 
> I'm thinking of use cases where there is the need to create and delete
> small tables at a high rate. You could quickly end with more than 65K
> (limit of ext4) subdirectories in the KS directory, while 99.9.. % of them
> are residual of deleted tables.
> 
> That looks quite dirty from Cassandra to not clean its own "garbage" by
> itself, and quite dangerous for the end user to have to do it alone, don't
> you think so?
> 
> Thanks,
> 
> Sébastien.
> 
> Le lun. 4 déc. 2023, 11:28, Dipan Shah <dipan....@hotmail.com> a écrit :
> 
> > Hello Sebastien,
> >
> > There are no inbuilt tools that will automatically remove folders of
> > deleted tables.
> >
> > Thanks,
> >
> > Dipan Shah
> > ------------------------------
> > *From:* Sébastien Rebecchi <srebec...@kameleoon.com>
> > *Sent:* 04 December 2023 13:54
> > *To:* user@cassandra.apache.org <user@cassandra.apache.org>
> > *Subject:* Remove folders of deleted tables
> >
> > Hello,
> >
> > When we delete a table with Cassandra, it lets the folder of that table on
> > file system, even if there is no snapshot (auto snapshots disabled).
> > So we end with the empty folder {data folder}/{keyspace name}/{table
> > name-table id} containing only 1  subfolder, backups, which is itself empty.
> > Is there a way to automatically remove folders of deleted tables?
> >
> > Sébastien.
> >
> 

Reply via email to