#vulnerable code 
                                boolean isMergeComplete() {
        if (compactionQueue.isEmpty()) {
            try {
                stopCompactionThread();
            } catch (IOException e) {
                logger.error("Error in isMergeComplete", e);
            }

            return true;
        }

        for (int fileId : compactionQueue) {
            // current write file and current compaction file will not be compacted.
            // if there are any other pending files return false.
            if (fileId != dbInternal.getCurrentWriteFileId() && fileId != getCurrentWriteFileId()) {
                return false;
            }
        }

        return true;
    } 
                            #location 4 
                            #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code
                                CompactionManager(HaloDBInternal dbInternal) {
        this.dbInternal = dbInternal;
        this.compactionRateLimiter = RateLimiter.create(dbInternal.options.compactionJobRate);
        this.compactionQueue = new LinkedBlockingQueue<>();
    }