<@U04S8PLJWMT> if i delete a source the connection...
# ask-ai
h
@kapa.ai if i delete a source the connection also gets deleted right ? so does this remove all the data from the warehouse ?
k
If you delete a source connector in Airbyte, any connections that rely on that source will also be deleted. However, deleting a source or its connections does not remove any data that has already been synced to your data warehouse or destination. The data remains in your destination, and if you want to reestablish the connection later, you will need to perform a full re-sync to update the data again [Add and manage sources](https://docs.airbyte.com/platform/next/using-airbyte/getting-started/add-a-source) [Manage existing connections](https://docs.airbyte.com/platform/next/cloud/managing-airbyte-cloud/configuring-connections). In summary: - Deleting a source deletes its connections. - Data already in your warehouse/destination is not deleted automatically.
h
@kapa.ai then how do we link this old data with our new connection.
k
A message from kapa.ai
To link old data in your warehouse with a new Airbyte connection, you generally need to ensure that the new connection writes to the same tables (or schema/namespace) as the old one, or you need to migrate the historical data to the new destination tables. If you are upgrading or recreating a connection and want to avoid re-syncing all historical data, Airbyte recommends a process called "dual-writing" for incremental syncs. This involves: 1. Copying the raw data: Manually copy the already replicated raw data from the old schema/namespace to the new one in your data warehouse. Airbyte provides sample SQL for this step, depending on your warehouse (BigQuery, Snowflake, Redshift, Postgres). 2. Copying the connection state: Copy the state from the old connection to the new one. This ensures that Airbyte knows where to resume syncing, so it doesn't re-import historical data. 3. Enable the new connection: Once the above steps are complete, enable the new connection. Your dashboards or downstream processes can then point to the new tables, and you can pause or delete the old connection when ready. This process ensures continuity and prevents duplication or loss of data when switching connections [Upgrading Connections One by One with Dual-Writing](https://docs.airbyte.com/release_notes/upgrading_to_destinations_v2#upgrading-connections-one-by-one-with-dual-writing). If you do not perform these steps, the new connection will treat the destination as empty and may re-sync all data, potentially duplicating records or creating new tables, depending on your configuration.
h
@kapa.ai from where do i copy the connection state, is it in the db ?
k
A message from kapa.ai
Yes, the connection state is stored in Airbyte's internal database, specifically in the
state
table. This table contains the state information for each connection, including the most recent values for global or stream-level cursors. You can access this database directly if you are self-hosting Airbyte. For example, if you are running Airbyte with Docker, you can connect to the database and view the state with the following commands:
Copy code
bash docker exec -ti airbyte-db psql -U docker -d airbyte SELECT * FROM state;
This will show you the state records, which include the state JSON blob for each connection. The relevant columns are
connection_id
and
state
, among others [How and where are cursors persisted](https://airbyte.com/tutorials/incremental-data-synchronization#step-2). Alternatively, you can also view and edit the connection state directly from the Airbyte UI: - Go to Connections > select your connection > Settings tab > Advanced dropdown. Here, you can view and copy the current connection state for use in a new connection [Modifying connection state](https://docs.airbyte.com/platform/next/cloud/managing-airbyte-cloud/manage-connection-state). So, you can copy the connection state either from the database or from the Airbyte UI, depending on your setup and preference.
h
@kapa.ai but if i have deleted the source and connection, then how will i get that ?
k
A message from kapa.ai
If you have already deleted both the source and the connection in Airbyte, you will not be able to access the connection state from the Airbyte UI, as the connection no longer exists there. However, if you have direct access to Airbyte's internal database and the records have not been purged, you may still be able to retrieve the state from the
state
table by querying for the relevant
connection_id
. But, if the database has been cleaned up or the records have been deleted as part of the deletion process, the state information will no longer be available. The knowledge sources do not explicitly state whether Airbyte retains state records in the database after a connection is deleted, so if you have already deleted both the source and the connection, there is a risk that the state is no longer accessible. In this case, you would likely need to perform a full re-sync with your new connection, as there would be no way to resume from the previous state without a backup or export of the state prior to deletion [Modifying connection state](https://docs.airbyte.com/platform/next/cloud/managing-airbyte-cloud/manage-connection-state) [How and where are cursors persisted](https://airbyte.com/tutorials/incremental-data-synchronization#step-2). In summary: If the connection is deleted, retrieving its state is generally not possible through the UI, and may not be possible from the database unless the records still exist. The knowledge sources do not guarantee state retention after deletion.