Skip to content

Instantly share code, notes, and snippets.

@mgagliardo91
mgagliardo91 / Analysis.md
Last active June 27, 2018 14:35
ANALYTICS-1932: Frequent EOFExceptions

ANALYTICS-1932

There seems to be two different EOFExceptions being thrown: java.io.EOFException and org.eclipse.jetty.io.EofException. The main file in play here (used by both client/server side) is CommitSpool.java

org.eclipse.jetty.io.EofException

This exception is being thrown to indicate an early, unexpected, EOF. The exception is most commonly thrown at the start of an ATH test against staging, but it can be found in prod with clients other than cloudbees. Following the stack trace, it seems like, while reading the input stream, a read is requested with a valid size determined from what is remaining to be read but the read() call throws an exception because the stream returned at -1 here.

I think that it would be safe to just handle

@mgagliardo91
mgagliardo91 / ComparingMetrics.md
Last active August 29, 2018 13:26
Metrics v1 to v2 Client Migration

With the migration to Metrics v2, there are some minor updates required by the client to make it compatible with both versions (deprecation will come later).

Metrics v1

To start, for v1, when you request "Give me metrics for Gate XYZ", you'll get something like this:

[
  {
      "id": {
@mgagliardo91
mgagliardo91 / GitHub_Ingester.md
Last active May 29, 2019 14:53
GitHub Ingester

Completed Work:

  • SDM-141: Create empty GitHub service that is responsible for pulling data in from github
  • SDM-142: GitHub service can be configured to connect to a github organisation
  • SDM-242: Create a "github app" for the SDM
  • SDM-144: GitHub service pushes the list of repos into the System of Record

Work Remaining:

  • SDM-???: [General] CI/CD for Flink Topologies
  • SDM-???: [Repositories] Handle deletions of repositories
@mgagliardo91
mgagliardo91 / Example.java
Last active July 11, 2019 16:01
GitHub Injector Show & Tell
// Square Map Function
stream.map(new RichMapFunction<Integer, Integer>() {
@Override
public Integer map(Integer input) {
return input * input;
}
});
// Flat Map transform a string to an stream of individual characters
stream.flatMap(new RichFlatMapFunction<String, String>() {
@mgagliardo91
mgagliardo91 / react-ts-default-props.tsx
Created September 5, 2019 13:48
Default Props in React with TS
import React from 'react';
interface ComponentProps = {
value: string;
intValue: number;
}
// Inline
const component = ({ value = "default", intValue = 100 }: ComponentProps) => {
@mgagliardo91
mgagliardo91 / Jira_Schema_Migration_Plan.md
Last active January 29, 2020 12:52
Jira Schema Migration Plan

Jira Schema Migration Plan

The following migration plan should be carried out in each environment sequentially, starting with dev. It should be easy to roll-back, if any issues surface.

Stop the web service deployment and the Flink topology

Stop the descriptor using the following command:

kubectl scale deployments/injector-jira --replicas=0
CREATE OR REPLACE FUNCTION pg_temp.rename_scopes(old text, new text) RETURNS void AS $$
BEGIN
UPDATE service_instance_scopes
SET label = new
WHERE label = old;
END;
$$ LANGUAGE plpgsql;
CREATE OR REPLACE FUNCTION pg_temp.clone_scope(existing text, newv text, descv text) RETURNS void AS $$
DECLARE
-- Extensions
CREATE EXTENSION IF NOT EXISTS timescaledb;
-- Data source
CREATE TABLE IF NOT EXISTS sources (
source_id SERIAL PRIMARY KEY,
source_key VARCHAR(64) NOT NULL,
facility_id INT NOT NULL,
description TEXT,
UNIQUE(source_key)
@mgagliardo91
mgagliardo91 / Message_Bus_Client_Retry_Mechanism.md
Last active June 23, 2021 19:01
Message Bus Client Retry Mechanism

Message Bus Client Retry Mechanism

A recent version of the message bus client includes updates that will ensure the client will attempt to retry its connection to the server when lost.

Follow the steps below to include the enhancement:

Instructions

  1. Bump to the latest version of the message bus client
@mgagliardo91
mgagliardo91 / clean_staging_duplicates.sql
Last active January 27, 2022 21:17
Timescale Deletions
-- The following function will work through the staging table by month and delete any data points from the staging table that
-- are duplicates of the data in the source table. This will ensure that the backfill script will not decompress chunks to upsert
-- the same exact data point. Ideally, it should reduce the amount of chunks that need to be decompressed.
CREATE OR REPLACE PROCEDURE public.clean_staging_duplicates(
tenant text
) AS $proc$
DECLARE
earliest_time timestamptz;
latest_time timestamptz;
time_range timestamptz;