Skip to content

Instantly share code, notes, and snippets.

@antaflos
antaflos / postgres_recovery.md
Created July 10, 2019 19:37 — forked from supix/postgres_recovery.md
Postgres error: Missing chunk 0 for toast value in pg_toast

The problem

In some cases, it is possible that PostgreSQL tables get corrupted. This can happen in case of hardware failures (e.g. hard disk drives with write-back cache enabled, RAID controllers with faulty/worn out battery backup, etc.), as clearly reported in this wiki page. Furthermore, it can happen in case of incorrect setup, as well.

One of the symptoms of such corruptions is the following message:

ERROR: missing chunk number 0 for toast value 123456 in pg_toast_45678

This almost surely indicates that a corrupted chunk is present within a table file. But there is a good way to get rid of it.

@antaflos
antaflos / unrarer.sh
Created June 11, 2019 23:05 — forked from fmoledina/unrarer.sh
Transmission unrar script to handle Sonarr from prematurely moving files
#!/bin/bash
# The script could use more testing, but it works well for my needs
extract_rar() {
isRar=$(ls ./*.rar)
if [ -n "$isRar" ]; then
# Handle an edge case with some distributors
isPart01="$(ls ./*rar | grep -E part0*1.rar)"
if [ -n "$isPart01" ]; then
isRar=$isPart01
@antaflos
antaflos / unrarer.sh
Created May 21, 2019 23:18 — forked from RobertDeRose/unrarer.sh
Transmission unrar script to handle Sonarr from prematurely moving files
#!/bin/bash
# The script could use more tesing, but it works well for my needs
function extract_rar() {
isRar=$(ls | grep *.rar)
if [ -n "$isRar" ]; then
# Handle an edge case with some distributors
isPart01="$(ls *.rar | egrep -i 'part01.rar|part1.rar')"
if [ -n "$isPart01" ]; then
Puppet::Functions.create_function(:file_eyaml_lookup_key) do
unless Puppet.features.hiera_eyaml?
raise Puppet::DataBinding::LookupError, 'Lookup using function '\
'file_eyaml_lookup_key is only supported when the hiera_eyaml '\
'library is present'
end
dispatch :file_eyaml_lookup_key do
param 'String[1]', :key
param 'Hash[String[1],Any]', :options
Puppet::Functions.create_function(:file_lookup_key) do
dispatch :file_lookup_key do
param 'String[1]', :key
param 'Hash[String[1],Any]', :options
param 'Puppet::LookupContext', :context
end
def file_lookup_key(key, options, context)
# Set interpolate = true by default and override it with the value of
# options['interpolate'], if set.
@antaflos
antaflos / haproxy.cfg
Created March 17, 2017 14:22
Reverse proxy Puppet frontend with HAProxy
# This file managed by Puppet
global
chroot /var/lib/haproxy
daemon
group haproxy
log 127.0.0.1 local1 info
log-send-hostname
maxconn 4096
stats socket /var/lib/haproxy/admin.sock mode 660 level admin
stats socket /var/lib/haproxy/user.sock mode 666 level user
@antaflos
antaflos / erb-render.rb
Created October 12, 2016 01:40 — forked from jasonlai/erb-render.rb
Utility Ruby script to render ERB templates, loading a JSON file as source for instance variables (useful when you need to debug Puppet templates)
#!/usr/bin/env ruby
require 'erb'
require 'json'
require 'optparse'
require 'ostruct'
class ERBContext
def initialize(hash)
raise ArgumentError, 'hash must be a Hash object' unless hash.is_a?(::Hash)
@antaflos
antaflos / jenkins_haproxy_config.cfg
Created February 8, 2016 22:21 — forked from xelwarto/jenkins_haproxy_config.cfg
Jenkins CI haproxy configuration example
global
chroot /var/lib/haproxy
crt-base /etc/pki/tls/certs
daemon
group haproxy
log 127.0.0.1 local0
maxconn 2000
pidfile /var/run/haproxy.pid
stats socket /var/lib/haproxy/stats
tune.ssl.default-dh-param 2048
@antaflos
antaflos / gist:dc4910058eb316029036
Created October 27, 2015 21:36
spec test error when using :undef
Failure/Error: let(:contents) { param_value(catalogue, 'concat::fragment', 'haproxy-base', 'content').split("\n") }
Puppet::Error:
Could not parse for environment production: Syntax error at ':'; expected '}' at line 4 on node foo.example.com
# ./vendor/bundle/ruby/2.1.0/gems/puppet-3.7.5/lib/puppet/parser/parser_support.rb:157:in `on_error'
# ./vendor/bundle/ruby/2.1.0/gems/puppet-3.7.5/lib/puppet/parser/lexer.rb:501:in `scan'
# ./vendor/bundle/ruby/2.1.0/gems/puppet-3.7.5/lib/puppet/parser/parser_support.rb:168:in `parse'
# ./vendor/bundle/ruby/2.1.0/gems/puppet-3.7.5/lib/puppet/node/environment.rb:545:in `perform_initial_import'
# ./vendor/bundle/ruby/2.1.0/gems/puppet-3.7.5/lib/puppet/node/environment.rb:276:in `known_resource_types'
# ./vendor/bundle/ruby/2.1.0/gems/puppet-3.7.5/lib/puppet/resource/type_collection_helper.rb:5:in `known_resource_types'
# ./vendor/bundle/ruby/2.1.0/gems/puppet-3.7.5/lib/puppet/parser/compiler.rb:558:in `block in initvars'
@antaflos
antaflos / configuration
Created September 30, 2015 17:20 — forked from saleeema/configuration
Logstash grok multiline; Java stack trace
input {
file {
path => "/root/mult.log"
start_position => "beginning"
sincedb_path => "/dev/null"
codec => multiline{
pattern => "^ -%{SPACE}%{TIMESTAMP_ISO8601}"
negate => true