Skip to content

CLI-3558: Concurrent Confluent CLI processes can read an inconsistent config.json file #2622

@gphilipp

Description

@gphilipp

I have this shell script which uses the Confluent CLI to delete all subjects in a concurrent fashion:

#!/usr/bin/env bash
delete_subject() {
    echo "Soft deleting subject $1"
    confluent schema-registry schema delete --force --version all --subject "$1"
    echo "Hard deleting subject $1"
    confluent schema-registry schema delete --force --permanent --version all --subject "$1"

}

subjects=$(confluent schema-registry schema list -o json | jq -r ".[].subject")

# Perform deletes in parallel
for subject in ${subjects}; do
    delete_subject "$subject" &
    sleep 0.2
done
wait

echo "All subjects deleted."

It works most of the time, but I sometimes get these error messages:

Successfully soft deleted all versions for subject "insurance_customer_activity-value".
  Version  
-----------
        1  
Successfully soft deleted all versions for subject "payment_transaction-value".
  Version  
-----------
        1  
Hard deleting subject shoestore_clickstream-value
Successfully hard deleted all versions for subject "gaming_player-value".
  Version  
-----------
        2  
Hard deleting subject shoestore_shoe-value
Hard deleting subject fleetmgmt_location-value
Error: unable to read configuration file "/Users/gphilippart/.confluent/config.json": invalid character ']' after top-level value
Hard deleting subject pizzastore_order_cancelled-value
Hard deleting subject insurance_customer_activity-value
Error: unable to read configuration file "/Users/gphilippart/.confluent/config.json": invalid character ']' after top-level value
Error: unable to read configuration file "/Users/gphilippart/.confluent/config.json": invalid character ']' after top-level value
Error: unable to read configuration file "/Users/gphilippart/.confluent/config.json": invalid character ']' after top-level value
Hard deleting subject payment_transaction-value

What is probably happening is that another process reads the config.json file in the middle of the config write operation.
It would be best to write the config.json changes in a temporary file and then renaming it, which is an atomic operation at the OS level.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions