Skip to content

Instantly share code, notes, and snippets.

View ajdavis's full-sized avatar

A. Jesse Jiryu Davis ajdavis

View GitHub Profile
@ajdavis
ajdavis / tenant_migration_recipient_majority_read.js
Last active December 23, 2021 03:53
Test majority read after tenant migration
/**
* Test majority reads on the recipient.
*
* 1. Before migration, insert docs on donor D.
* 2. Enable fpAfterCollectionClonerDone failpoint on R.
* 3. Run the migration until it hits fpAfterCollectionClonerDone.
* 4. Hold back R's stable timestamp.
* 5. Insert newDoc on D, applied on R at recipient timestamp 90.
* 6. Disable fpAfterCollectionClonerDone.
* 7. Wait for the migration to commit, it commits at ts 100.
@ajdavis
ajdavis / generic_argument_gen.cpp
Last active November 6, 2020 18:45
Generated classes for generic args/fields
/**
* WARNING: This is a generated file. Do not modify.
*
* Source: buildscripts/idl/idlc.py --include src --base_dir build/mac --target_arch x86_64 --header build/mac/mongo/idl/generic_argument_gen.h --output build/mac/mongo/idl/generic_argument_gen.cpp src/mongo/idl/generic_argument.idl
*/
#include "mongo/platform/basic.h"
#include "mongo/idl/generic_argument_gen.h"
@ajdavis
ajdavis / sort.py
Created August 21, 2020 12:48
Merge-sort logs from resmoke.py, mongod, and mongobridge
import heapq
import re
import sys
from datetime import datetime
from operator import itemgetter
def parse_lines(file_name):
ts = datetime.min
ts_str = ""
@ajdavis
ajdavis / absolutize-paths.py
Created November 14, 2019 21:38
Script for use with CLion to make a custom build tool's path outputs absolute, so they are clickable in CLion's output window.
#!/usr/bin/env python3
import re
import subprocess
import sys
proc = subprocess.Popen(sys.argv[1:], stdout=subprocess.PIPE)
for line in iter(proc.stdout.readline, b''):
match = re.match(rb'src/[\w_/.]+:\d+.*', line)
@ajdavis
ajdavis / swap_h_c.py
Created November 14, 2019 21:26
Script for CLion to switch between editing a C/C++ header and source file
#!/usr/bin/env python3
import os
import sys
if len(sys.argv) != 2:
print("Usage: %s FILE" % (sys.argv[0],))
sys.exit(1)
path = os.path.abspath(sys.argv[1])
# "pip install pytablewriter"
from pytablewriter import MarkdownTableWriter
writer = MarkdownTableWriter()
writer.headers = ["datum", "before rollback", "after rollback"]
writer.value_matrix = [
["last fetched", "> source's lastApplied", "<= source's lastApplied"],
["rollback ID", "N", "N + 1"],
["prepared txns", "in progress", "aborted"],
["stable timestamp", "???", "oplog common point??"],
@ajdavis
ajdavis / connPoolStats-3.4.20
Last active May 7, 2019 13:03
Example connPoolStats output for a 2-shard cluster, each shard is a 3-node replica set, the config replica set has 1 node
MongoDB shell version v0.0.0
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
WARNING: No implicit session: Logical Sessions are only supported on server versions 3.6 and greater.
Implicit session: dummy session
MongoDB server version: 3.4.20
WARNING: shell and server versions do not match
{
"numClientConnections" : 9,
"numAScopedConnections" : 0,
"totalInUse" : 0,
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>local.mirror-client</string>
<key>Program</key>
<string>/usr/bin/java</string>
<key>ProgramArguments</key>
<array>
@ajdavis
ajdavis / storage_timestamp_tests.cpp
Created March 12, 2019 19:08
Test TransactionParticipant::getOldestActiveTimestamp timeout
class TimeoutInGetOldestTransactionTimestamp : public MultiDocumentTransactionTest {
public:
TimeoutInGetOldestTransactionTimestamp()
: MultiDocumentTransactionTest("timeoutInGetOldestTransactionTimestamp") {}
void run() {
auto txnParticipant = TransactionParticipant::get(_opCtx);
ASSERT(txnParticipant);
AutoGetCollection txns(
class AsyncSocketWrapper:
# Sockets are wrapped in this simplified class and passed down
# to the pymongo <=> libmongocrypt integration layer.
def __init__(self, sockinfo):
self._sockinfo = sockinfo
def send(self, buffer):
# libmongocrypt calls this function on one of its worker threads.
event = threading.Event()