<@U04S8PLJWMT> I'm trying to update the connection...
# ask-ai
a
@kapa.ai I'm trying to update the connection state json by removing the part related to disabled stream. However, it shows up again every time when I click on the "update state" button. How can we achieve this properly?
k
When you update the connection state JSON in Airbyte and remove the part related to a disabled stream, but it reappears after clicking "update state," this is expected behavior. Airbyte manages state per stream, and if a stream is only disabled (not deleted), Airbyte may retain its state internally. The state for disabled streams can persist and be re-inserted by Airbyte during syncs or state updates, as the platform is designed to maintain state continuity for all streams in the connection, including those that are currently disabled. There is no documented way in the official Airbyte UI or API to permanently remove the state for a disabled (but not deleted) stream—removing it manually from the state JSON will not persist, as Airbyte will restore it based on its internal configuration and metadata. The only way to ensure a stream's state is fully removed is to delete the stream from the connection configuration entirely, not just disable it. Important: Editing connection state should be handled with extreme care, as improper changes can break your syncs and may require a full historical sync to fix. Only make such changes if you are certain of the impact, and preferably as directed by the Airbyte team. For more details, see the documentation on [modifying connection state](https://docs.airbyte.com/platform/cloud/managing-airbyte-cloud/manage-connection-state). If you need to remove state for a stream that is no longer needed, consider deleting the stream from the connection configuration, then updating the state. Otherwise, Airbyte will continue to manage and restore state for all configured streams, including those that are disabled but not deleted. If you require more granular control or have a special use case, you may need to reach out to Airbyte support or consult the community for potential workarounds, as the knowledge sources do not describe a built-in way to remove state for disabled streams only without deleting them from the connection configuration. [Modifying connection state](https://docs.airbyte.com/platform/cloud/managing-airbyte-cloud/manage-connection-state)
a
@kapa.ai Where is the state data managed/saved by Airbyte? Please tell me which tables?
k
A message from kapa.ai
Airbyte manages and saves state data in the
state
table of its internal configuration database. This table contains the state information for each connection and stream, including the state JSON, connection ID, stream name, namespace, and the type of state (
STREAM
,
GLOBAL
, or
LEGACY
). The relevant columns in the
state
table are: - `id`: Primary key, unique identifier for the state record. - `connection_id`: Foreign key referencing the connection. - `state`: JSON blob storing the state information. -
created_at
and `updated_at`: Timestamps for record creation and modification. -
stream_name
and `namespace`: Identify the stream associated with the state. - `type`: Enum indicating the state type (
STREAM
,
GLOBAL
,
LEGACY
). Indexes and constraints include a primary key on (
id
,
connection_id
) and a unique constraint on (
connection_id
,
stream_name
,
namespace
) [Config Database - state table](https://docs.airbyte.com/platform/next/understanding-airbyte/database-data-catalog#state). You can view the contents of this table directly in the Airbyte internal Postgres database using:
Copy code
sql SELECT * FROM state;
[Incremental Data Synchronization Tutorial](https://airbyte.com/tutorials/incremental-data-synchronization#step-2)
a
@kapa.ai Can we see the table from Airbyte's destination databases?
k
A message from kapa.ai
Yes, you can view the tables that Airbyte creates in your destination databases. For example, after running a sync, you can connect to your destination database (such as Postgres) and use SQL commands to list and query the tables. Airbyte typically creates raw tables (e.g.,
_airbyte_raw_<table_name>
) and, depending on your sync mode, may also create normalized or history tables. For example, to list tables in a Postgres destination, you can use:
Copy code
sql \dt;
To view the contents of a raw table:
Copy code
sql SELECT * FROM _airbyte_raw_<table_name>;
The documentation and tutorials provide examples of these queries and show the structure of the tables created by Airbyte in the destination database. These tables include fields such as
_airbyte_ab_id
,
_airbyte_data
, and
_airbyte_emitted_at
among others, depending on the sync mode and normalization settings you have chosen [Explore Airbyte’s incremental data synchronization](https://airbyte.com/tutorials/incremental-data-synchronization#step-7) [Explore Airbyte's Change Data Capture (CDC) synchronization](https://airbyte.com/tutorials/incremental-change-data-capture-cdc-replication).
a
@kapa.ai No, it doesn't help even if I delete the data in _airbyte_raw_<table_name> and re-sync everything. It still synced the wrong number of data
k
A message from kapa.ai
Deleting data from the
_airbyte_raw_<table_name>
table in your destination will not reset or fix the sync state in Airbyte. Airbyte manages sync state internally in its own configuration database (specifically, in the
state
table), not in the destination tables. When you re-sync, Airbyte uses this internal state to determine what data to extract and load, regardless of what you manually delete from the destination tables. If you are seeing the wrong number of records after deleting data from the destination and re-syncing, it is likely because the sync state was not reset or cleared. To fully reset the sync and ensure all data is reloaded from the source, you should use Airbyte's Clear functionality. This will remove all records from your destination tables and reset the sync state, allowing a true full refresh on the next sync. Simply deleting data from the destination does not affect Airbyte's internal state tracking and can lead to inconsistent results [Clearing your data](https://docs.airbyte.com/platform/operator-guides/clear). If you want to ensure a complete re-sync, use the "Clear data" option in the Airbyte UI or API for your connection or stream, and then run a sync. This will properly reset both the destination tables and Airbyte's internal state, ensuring the correct number of records are synced.