cheerfulstoic / ecto_watch

EctoWatch allows you to easily get notifications about database changes directly from PostgreSQL.
201 stars 7 forks source link

EctoWatch thinks all triggers are EctoWatch Triggers #23

Closed barrelltech closed 3 months ago

barrelltech commented 3 months ago

I get a massive wall of red now any time I start my server because all my existing triggers are belong to EctoWatch. v0.9.5

[error] Found the following extra EctoWatch triggers:

"ew_inserted_for_phrasing_account_preference_trigger" in the table "public"."preferences"
"ew_updated_for_phrasing_account_preference_trigger" in the table "public"."preferences"

...but they were not specified in the watcher options.

To cleanup unspecified triggers and functions, run your app with the `ECTO_WATCH_CLEANUP`
environment variable set to the value `cleanup`

[error] Found the following extra EctoWatch functions:

"halfvec_negative_inner_product" in the schema "public"
"vector_sub" in the schema "public"
"vector_accum" in the schema "public"
"array_to_halfvec" in the schema "public"
"sparsevec_send" in the schema "public"
"sparsevec_out" in the schema "public"
"vector_cmp" in the schema "public"
"vector_to_sparsevec" in the schema "public"
"l2_distance" in the schema "public"
"sparsevec_gt" in the schema "public"
"vector_send" in the schema "public"
"sparsevec_l2_squared_distance" in the schema "public"
"vector_l2_squared_distance" in the schema "public"
"halfvec_mul" in the schema "public"
"l2_normalize" in the schema "public"
"sparsevec_to_halfvec" in the schema "public"
"halfvec_cmp" in the schema "public"
"vector_negative_inner_product" in the schema "public"
"ivfflat_halfvec_support" in the schema "public"
"vector_combine" in the schema "public"
"halfvec_send" in the schema "public"
"halfvec_ge" in the schema "public"
"vector_ne" in the schema "public"
"binary_quantize" in the schema "public"
"halfvec_to_sparsevec" in the schema "public"
"halfvec_lt" in the schema "public"
"vector_spherical_distance" in the schema "public"
"ew_inserted_for_phrasing_account_preference_func" in the schema "public"
"l1_distance" in the schema "public"
"array_to_vector" in the schema "public"
"hnsw_sparsevec_support" in the schema "public"
"sparsevec" in the schema "public"
"halfvec_typmod_in" in the schema "public"
"halfvec_to_float4" in the schema "public"
"vector_eq" in the schema "public"
"halfvec_concat" in the schema "public"
"avg" in the schema "public"
"vector_lt" in the schema "public"
"halfvec_add" in the schema "public"
"sparsevec_to_vector" in the schema "public"
"halfvec_in" in the schema "public"
"halfvec_l2_squared_distance" in the schema "public"
"vector_recv" in the schema "public"
"halfvec_combine" in the schema "public"
"halfvec" in the schema "public"
"halfvec_gt" in the schema "public"
"sparsevec_le" in the schema "public"
"l2_norm" in the schema "public"
"sparsevec_ne" in the schema "public"
"vector_to_float4" in the schema "public"
"halfvec_avg" in the schema "public"
"sparsevec_typmod_in" in the schema "public"
"vector_avg" in the schema "public"
"hnsw_bit_support" in the schema "public"
"hnsw_halfvec_support" in the schema "public"
"vector" in the schema "public"
"subvector" in the schema "public"
"halfvec_eq" in the schema "public"
"inner_product" in the schema "public"
"sparsevec_negative_inner_product" in the schema "public"
"vector_le" in the schema "public"
"vector_concat" in the schema "public"
"sparsevec_cmp" in the schema "public"
"ew_inserted_for_phrasing_material_ranking_func" in the schema "public"
"vector_to_halfvec" in the schema "public"
"vector_mul" in the schema "public"
"ivfflathandler" in the schema "public"
"sparsevec_eq" in the schema "public"
"vector_norm" in the schema "public"
"halfvec_le" in the schema "public"
"halfvec_out" in the schema "public"
"vector_ge" in the schema "public"
"ivfflat_bit_support" in the schema "public"
"jaccard_distance" in the schema "public"
"halfvec_ne" in the schema "public"
"sparsevec_ge" in the schema "public"
"halfvec_recv" in the schema "public"
"sparsevec_lt" in the schema "public"
"hamming_distance" in the schema "public"
"cosine_distance" in the schema "public"
"ew_updated_for_phrasing_account_preference_func" in the schema "public"
"sparsevec_recv" in the schema "public"
"vector_typmod_in" in the schema "public"
"vector_out" in the schema "public"
"vector_gt" in the schema "public"
"halfvec_to_vector" in the schema "public"
"sum" in the schema "public"
"halfvec_sub" in the schema "public"
"vector_dims" in the schema "public"
"halfvec_accum" in the schema "public"
"vector_in" in the schema "public"
"hnswhandler" in the schema "public"
"vector_add" in the schema "public"
"halfvec_spherical_distance" in the schema "public"
"sparsevec_in" in the schema "public"

To cleanup unspecified triggers and functions, run your app with the `ECTO_WATCH_CLEANUP`
environment variable set to the value `cleanup`
adampash commented 3 months ago

Was about to report the same issue. I do like that it wants to clean up unused ecto_watch triggers, though. Unfortunately if I run it with the environment variable set, it doesn't seem to do anything.

cheerfulstoic commented 3 months ago

Ah, shit 😅 Looking at this now!

cheerfulstoic commented 3 months ago

Ok, thanks for this! ❤️

I tested this in an external app, but I didn't have tests for it 🤦 (annoying because I was making tests for everything else...)

So the error log was showing the correct triggers that needed to be cleaned up, but not the right functions. It was looking for the ew_ prefix for triggers, but not functions. I've made some tests to check that it's reporting the right triggers + functions and fixed that issue.

Also, because I started up just cleaning triggers the environment variable that the code was looking for was ECTO_WATCH_CLEANUP_TRIGGERS, but soon after I changed the variable to ECTO_WATCH_CLEANUP because it was also looking for functions. Unfortunately while I changed the documentation to ECTO_WATCH_CLEANUP, I didn't change the code... That's been fixed now (along with tests that are making sure that the right triggers / functions are being cleaned up)

That's been released as 0.9.10. Please let me know how that works!