<@U0A71G31CDV> I have a strange situation trying t...
# questions-and-troubleshooting
k
@Rocky I have a strange situation trying to
DROP VIEW
. It looks like it's somehow no properly cleaning the view from StarRocks memory. I'm running the following operations:
Copy code
SELECT * FROM myview;    OK

DROP VIEW myview;        OK

SELECT * FROM myview;    PROBLEM: I'm able to read data here.

DROP VIEW myview;        ERROR: Doesn't exist

SELECT * FROM myview;    PROBLEM: Still able to read data here.
Currently on StarRocks version:
Copy code
current_version()|
-----------------+
3.4.8-d507a53    |
Can you elaborate on what could be causing this and provide guidance on how to solve this problem?
r
This behavior typically points to one of three things: a Materialized View being mistaken for a logical view, Result/Query Caching, or Metadata Inconsistency between Frontend (FE) nodes. Since you are on version 3.4.8, here is a step-by-step guide to identify and resolve the issue: 1. Check if it is a Materialized View In StarRocks,
DROP VIEW
is specifically for logical views. If you created an Asynchronous Materialized View, it acts like a table but is managed differently. * The Symptom: If you have an MV named
myview
, running
DROP VIEW myview
might return "OK" if a logical view of that name existed, but the MV itself would remain. * The Test: Run the following:
Copy code
sql
    SHOW MATERIALIZED VIEWS LIKE 'myview';
* The Fix: If it appears in the list, you must use:
Copy code
sql
    DROP MATERIALIZED VIEW myview;
2. Bypass the Result Cache StarRocks has a Result Cache and a Query Cache. If these are enabled, the FE or BE might be returning the cached results of your
SELECT *
query without even checking if the underlying view still exists in the metadata. * The Test: Run the query with a slight modification to bypass the cache, or explicitly disable the cache in your session:
Copy code
sql
    SET enable_result_cache = false;
    SET enable_query_cache = false;
    SELECT * FROM myview;
* If the query now fails with "Table/View does not exist," then the issue was simply a stale cache. 3. Verify the Object Type It is possible (though rare) that there is a name collision or the object is actually a table. * The Test: Run these commands and check which one returns a result:
Copy code
sql
    SHOW CREATE VIEW myview;
    SHOW CREATE TABLE myview;
If
SHOW CREATE TABLE
returns a result but
SHOW CREATE VIEW
fails, then
myview
is actually a table (or an MV), and
DROP VIEW
will not affect it. 4. Check for FE Metadata Lag If you are running StarRocks in a high-availability (HA) cluster with multiple Frontends (one Leader, multiple Followers) and a Load Balancer: * The
DROP VIEW
command is handled by the Leader FE. * If your
SELECT
query is being sent to a Follower FE, there might be a slight lag in replaying the metadata log, or the Follower's metadata might be out of sync. * The Test: Connect directly to the Leader FE (you can find it via
SHOW FRONTENDS;
) and run the
SELECT
. If it fails there but works on Followers, you have a metadata synchronization issue. 5. Force a Metadata Reload (Admin only) If you've confirmed it's not an MV and caching is disabled, but the view still persists in a "ghost" state, you can try to trigger a metadata refresh:
Copy code
sql
-- This is a last resort to see if the FE can re-validate its state
INVALIDATE METADATA;
Recommendation: Start by running
SHOW FULL TABLES LIKE 'myview';
. The
Table_type
column will tell you exactly what StarRocks thinks
myview
is (
BASE TABLE
,
VIEW
, or
MATERIALIZED VIEW
). If it says
BASE TABLE
or
MATERIALIZED VIEW
,
DROP VIEW
is the wrong command.
k
@Rocky Can confirm that
myview
is a view:
Copy code
myview          |VIEW      |
r
Yes, I can confirm that
myview
is a View. In StarRocks, when you run the command
SHOW FULL TABLES;
, the output includes a column named
Table_type
. • A value of
VIEW
indicates it is a logical view. • A value of
BASE TABLE
indicates it is a physical table. Based on your output snippet
myview | VIEW |
, StarRocks is identifying it as a view. If you want to see the SQL definition used to create this view, you can run:
Copy code
sql
SHOW CREATE VIEW myview;
If you need further details about the view's columns, you can also use:
Copy code
sql
DESC myview;
k
@Rocky can you provide more information about your suggestion:
Copy code
5. Force a Metadata Reload (Admin only)
If you've confirmed it's not an MV and caching is disabled, but the view still persists in a "ghost" state, you can try to trigger a metadata refresh:
sql
-- This is a last resort to see if the FE can re-validate its state
INVALIDATE METADATA;
r
Hi there! I’m Rocky. It looks like there might be a bit of a mix-up regarding the command syntax. In StarRocks,
INVALIDATE METADATA
is not a supported command
(that is typically used in Apache Impala). If you are experiencing a "ghost" state where a view or table persists in the metadata despite being dropped, or if the metadata is out of sync with an external source, here are the correct StarRocks commands to use: 1. For External Catalogs (Hive, Iceberg, Hudi, etc.) If the metadata issue is related to an external catalog, StarRocks provides specific refresh commands to sync the FE (Frontend) with the remote metastore: * Refresh an entire catalog:
Copy code
sql
    REFRESH CATALOG <catalog_name>;
* Refresh a specific database:
Copy code
sql
    REFRESH DATABASE <catalog_name>.<db_name>;
* Refresh a specific table:
Copy code
sql
    REFRESH TABLE <catalog_name>.<db_name>.<table_name>;
2. For Materialized Views (MVs) If the "ghost" state relates to an asynchronous Materialized View that isn't reflecting the latest data or state:
Copy code
sql
REFRESH MATERIALIZED VIEW <mv_name>;
_Note: If an MV is stuck in a "locked" or "refreshing" state, you may need to check
SHOW MATERIALIZED VIEWS
and potentially look at the task runs via
SELECT _ FROM information_schema.task_runs;
.* 3. Clearing Query/Result Caches Sometimes the "ghost" state isn't in the metadata but in the Result Cache. If you keep seeing old results for a view that you've changed, try disabling the cache for your session to verify:
Copy code
sql
SET use_query_cache = false;
4. FE Metadata Check (Admin Only) If you are an administrator and internal metadata truly seems corrupted or "ghosted" (e.g., you can't drop a view because it "doesn't exist," but you can't create it because it "already exists"): 1. Check FE Logs: Look for
fe.log
or
fe.warn.log
for any
MetaNotFoundException
or
AlreadyExistsException
. 2. Leader Handover: In a multi-FE deployment, sometimes forcing a new Leader to take over can resolve memory-state inconsistencies (though this is rare). 3. Restart FE: As a last resort, restarting the Leader FE node will force it to reload the image and edit logs from disk, which usually clears any transient "ghost" states in memory. Summary: If you were trying to use
INVALIDATE METADATA
to fix a sync issue with an external data lake, use
REFRESH CATALOG
instead!
s
Hey @Karl R, the DROP itself is working correctly as shown by your error message with the second
DROP
saying "doesn't exist". This real issue is that your
SELECT
is resolving the view from an old source. It could be one of the following causes: 1. Multi-FE metadata sync delay: DDL runs on the FE leader and replicates to followers via EditLog a. If your client is load-balanced across FEs, the DROP hits the leader but subsquent
SELECTs
may route to a follower that hasn't replayed it yet b. So, the
DROP
succeeds on the leader,
SELECT
still works on stale follower, and the second
DROP
fails on leader (which is gone),
SELECT
still works on the stale follower. 2. Query cache serving stale results: a. If
enable_query_cache
is on, a cached result from the first SELECT could be returned without re-resolving view metadata. b. To diagnose, run these and share the output: i.
SHOW FRONTENDS;
SHOW VARIABLES LIKE '%cache%';
ii. Then test this in a single session without reconnecting: 1.
DROP VIEW myview;
and
SELECT * FROM myview;
So if the single-session test fails as expected, the issue is multi-FE routing basically your connection pool or proxy is sending statements to different FEs. Try connecting directly to the FE leader IP from
SHOW FRONTENDS;
or disable query cache:
SET enable_query_cache = false; SET query_cache_type = 0;
and re-test.