dump buffer on invalid insert (#3613)

* dump buffer on invalid insert

* dump to PERSISTENT_CACHE_DIR

* fix warning

* ensure dir is not nil
This commit is contained in:
ruslandoga 2023-12-11 22:56:18 +08:00 committed by GitHub
parent 16bfb11701
commit 7a4cafac16
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -291,7 +291,8 @@ config :plausible,
super_admin_user_ids: super_admin_user_ids, super_admin_user_ids: super_admin_user_ids,
is_selfhost: is_selfhost, is_selfhost: is_selfhost,
custom_script_name: custom_script_name, custom_script_name: custom_script_name,
log_failed_login_attempts: log_failed_login_attempts log_failed_login_attempts: log_failed_login_attempts,
persistent_cache_dir: maxmind_cache_dir
config :plausible, :selfhost, config :plausible, :selfhost,
enable_email_verification: enable_email_verification, enable_email_verification: enable_email_verification,

View File

@ -100,6 +100,15 @@ defmodule Plausible.Ingestion.WriteBuffer do
Logger.info("Flushing #{buffer_size} byte(s) RowBinary from #{name}") Logger.info("Flushing #{buffer_size} byte(s) RowBinary from #{name}")
IngestRepo.query!(insert_sql, [header | buffer], insert_opts) IngestRepo.query!(insert_sql, [header | buffer], insert_opts)
end end
rescue
_ ->
path =
Path.join(
Application.get_env(:plausible, :persistent_cache_dir) || System.tmp_dir!(),
"insert_error.dump"
)
File.write!(path, state.buffer)
end end
defp default_flush_interval_ms do defp default_flush_interval_ms do